#
# Makefile for the Calendar Tool testing implementation.
#


# CSC 307 java lib directory
LIB307 =	/home/gfisher/classes/307/lib/JVM

# TestNG library path
TESTNG =	/home/gfisher/classes/307/lib/testng/testng-6.8.jar

# Output directory for tests generated by Spest
SPEST_OUT_DIR =	spest

# Directory for generated executable files
EXECUTABLES =	../../executables/JVM

#
# Define the path to the implementation source files.
#
IMPLE_SRC_DIR = ../../../../implementation/source/java

#
# Schedule test files, including testing stub files.
#
SCHEDULE_TEST_FILES = \
	caltool/model/schedule/*.java \
	$(IMPLE_SRC_DIR)/caltool/model/options/Options.java \
	$(IMPLE_SRC_DIR)/caltool/model/schedule/*.java \
	$(IMPLE_SRC_DIR)/caltool/model/caldb/UserCalendar.java \
	$(IMPLE_SRC_DIR)/caltool/model/caldb/ItemKey.java \
	$(IMPLE_SRC_DIR)/caltool/model/PrecondViolation.java


#
# UserCalendar test files
#
UCAL_TEST_FILES = \
	caltool/caldb/model/UserCalendarTest.java \
	caltool/caldb/model/UserCalendarTestDriver.java

# List of packages
PACKAGES = \
		caltool \
		caltool/model \
		caltool/view \
		caltool/model/admin \
		caltool/model/admin/administrator \
		caltool/model/admin/user \
		caltool/view/admin \
		caltool/view/admin/administrator \
		caltool/view/admin/user \
		caltool/model/caldb \
		caltool/model/edit \
		caltool/view/edit \
		caltool/model/file \
		caltool/view/file \
		caltool/model/help \
		caltool/view/help \
		caltool/model/options \
		caltool/view/options \
		caltool/model/schedule \
		caltool/view/schedule \
		caltool/model/server \
		caltool/model/view \
		caltool/view/view

#
# Compile and execute the Schedule module test.
#
[scheduletest:	compile_schedule run_schedule

compile_schedule:
	echo "Compiling tests ..."
	javac -g \
	  -classpath $(TESTNG):$(LIB307) \
	  -sourcepath .:$(IMPLE_SRC_DIR) \
	  -d $(EXECUTABLES) \
		$(SCHEDULE_TEST_FILES)

run_schedule:
	@echo "Running tests ..."
	@csh -q -c 'cd $(EXECUTABLES); ./.run.csh'

open_test_output:
	@csh -q -c 'open $(EXECUTABLES)/test-output/index.html'

#
# Make the most recent output the good output.
#
good:
	cp -p $(EXECUTABLES)/output/*.out ../../output-good

ucaltest:
	javac -g -classpath $(CLASS_PATH) $(UCAL_TEST_FILES)

# Generate a source dir command for emacs jdb debugging.
emacs-jdb:
	csh -q -c ".make-emacs-jdb-dirs $(PACKAGES)"

# Remove all .class files from the executables/JVM dir.
clean:
	csh -q -c ".make-clean.csh"