
RM = \rm -f

# Running the main test: target requires a local installation of TESS,
# the (Te)st (S)ystem for (S)-Lang, and a running display system (such
# as X11) to which Gtk may connect.  Given the nature of GUIs, these
# tests will most often be run interactively.
#
# However, they may be run non-interactively (e.g, from within a cron
# job or automated build script, where it may be inconvenient or 
# impossible to set $DISPLAY correctly) by using the wrapper script at
# ../src/batch/xvfb-run. This will launch a virtual X server, to which
# SLgtk will connect when executing the tests.
# 
# Finally, the simple smoketest: target requires neither TESS nor a
# running display system.  All it does is ensure nominal usability by
# import()-ing the module and checking for the existence of a few
# symbols.  It is well suited for the cases when even xvfb-run is
# problematic to use.

SLIRPSH = ../slirp/slsh
TESS_APP = $(SLIRPSH)
TESS_OPTS=
test:
	@# Verify local installation of TESS, and bulletproof its
	@# use against other packages which may provide their own
	@# slsh or clutter the env with non-default variables
	@for d in `echo $$PATH | tr ':' ' '` ; do \
	    if test -x $$d/tessrun ; then \
		tessrun=$$d/tessrun ; \
		SLSH_PATH=$$d/../share/slsh ; export SLSH_PATH ; \
		SLSH_CONF_DIR=$$d/../etc ; export SLSH_CONF_DIR ; \
	    fi ; \
	done ; \
	if test -z "$$tessrun" ; then \
	   echo "A TESS installation is required to run these tests" ; \
	   false ; \
	fi ; \
	echo "tessrun $(TESS_OPTS) $(TESS_APP) > test.out" ; \
	tessrun $(TESS_OPTS) $(TESS_APP) > test.out 2>&1
	diff test.ref test.out 

smoketest:
	unset DISPLAY && $(SLIRPSH) smoketest.sl
	@echo SLgtk smoketest executed succesfully!

clean:
	$(RM) *~ test.out

distclean: clean
