diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-04-07 02:11:49 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-04-07 02:11:49 +0000 |
commit | 90b089d7fd6454771b23fdcebb78d3b1a469c3f5 (patch) | |
tree | 7f77600a8b22333d7e8bd9a94446ebd446345409 /test | |
parent | 427ce60a0cf055347b2fd7ac4a37bec59d65c3ac (diff) | |
download | libhubbub-90b089d7fd6454771b23fdcebb78d3b1a469c3f5.tar.gz libhubbub-90b089d7fd6454771b23fdcebb78d3b1a469c3f5.tar.bz2 |
Rework buildsystem so that it no longer calls make recursively and rebuilds the testcases when the library changes.
svn path=/trunk/hubbub/; revision=4077
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 111 | ||||
-rw-r--r-- | test/data/html/INDEX | 5 | ||||
-rw-r--r-- | test/testrunner.pl | 32 |
3 files changed, 90 insertions, 58 deletions
diff --git a/test/Makefile b/test/Makefile index 675b043..3d5788c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,64 +1,85 @@ -# Makefile for Hubbub testcases +# Child makefile fragment for libhubbub # -# Toolchain is exported by top-level makefile +# Toolchain is provided by top-level makefile # -# Top-level makefile also exports the following variables: +# Variables provided by top-level makefile # -# COMPONENT Name of component -# EXPORT Absolute path of export directory -# TOP Absolute path of source tree root +# COMPONENT The name of the component +# EXPORT The location of the export directory +# TOP The location of the source tree root +# RELEASEDIR The place to put release objects +# DEBUGDIR The place to put debug objects # -# The top-level makefile requires the following targets to exist: +# do_include Canned command sequence to include a child makefile # -# clean Clean source tree -# debug Create a debug binary -# distclean Fully clean source tree, back to pristine condition -# export Export distributable components to ${EXPORT} -# release Create a release binary -# setup Perform any setup required prior to compilation -# test Execute any test cases +# Variables provided by parent makefile: +# +# DIR The name of the directory we're in, relative to $(TOP) +# +# Variables we can manipulate: +# +# ITEMS_CLEAN The list of items to remove for "make clean" +# ITEMS_DISTCLEAN The list of items to remove for "make distclean" +# TARGET_TESTS The list of target names to run for "make test" +# +# SOURCES The list of sources to build for $(COMPONENT) +# +# Plus anything from the toolchain + +# Push parent directory onto the directory stack +sp := $(sp).x +dirstack_$(sp) := $(d) +d := $(DIR) # Extend toolchain settings # We require the presence of libjson -- http://oss.metaparadigm.com/json-c/ -CFLAGS += -I${TOP}/src/ -I$(CURDIR) \ - `${PKGCONFIG} ${PKGCONFIGFLAGS} --cflags json` -LDFLAGS += `${PKGCONFIG} ${PKGCONFIGFLAGS} --libs json` - -# Release output -RELEASE = +CFLAGS := $(CFLAGS) -I$(TOP)/src/ -I$(d) \ + `$(PKGCONFIG) $(PKGCONFIGFLAGS) --cflags json` +LDFLAGS := $(LDFLAGS) `$(PKGCONFIG) $(PKGCONFIGFLAGS) --libs json` -# Debug output -DEBUG = - -# Objects -OBJS = aliases cscodec csdetect dict entities filter hubbub \ +# Tests +TESTS_$(d) := aliases cscodec csdetect dict entities filter hubbub \ inputstream parser parser-utf16 tokeniser tokeniser2 \ tree -OBJS += regression/cscodec-segv regression/filter-segv regression/stream-nomem - -.PHONY: clean debug export release setup test +TESTS_$(d) := $(TESTS_$(d)) regression/cscodec-segv regression/filter-segv \ + regression/stream-nomem -# Targets -release: +# Items for top-level makefile to use +ITEMS_CLEAN := $(ITEMS_CLEAN) \ + $(addprefix $(d), $(addsuffix $(EXEEXT), $(TESTS_$(d)))) \ + $(addprefix $(d), $(addsuffix .gcda, $(TESTS_$(d)))) \ + $(addprefix $(d), $(addsuffix .gcno, $(TESTS_$(d)))) +ITEMS_DISTCLEAN := $(ITEMS_DISTCLEAN) $(d)log -debug: +# Targets for top-level makefile to run +TARGET_TESTS := $(TARGET_TESTS) test_$(d) -clean: - -@${RM} ${RMFLAGS} $(addsuffix ${EXEEXT}, $(OBJS)) +# Now we get to hack around so that we know what directory we're in. +# $(d) no longer exists when running the commands for a target, so we can't +# simply use it verbatim. Assigning to a variable doesn't really help, as +# there's no guarantee that someone else hasn't overridden that variable. +# So, what we do is make the target depend on $(d), then pick it out of the +# dependency list when running commands. This isn't pretty, but is effective. +test_$(d): $(d) $(addprefix $(d), $(TESTS_$(d))) + @$(PERL) $(TOP)/$<testrunner.pl $(TOP)/$< $(EXEEXT) -distclean: - -@${RM} ${RMFLAGS} log +# Build rules for each test binary -- they all depend on the debug library +define compile_test +$(2): $$(TOP)/$$(COMPONENT)-debug.a $(1) + @$$(ECHO) $$(ECHOFLAGS) "==> $(1)" + @$$(CC) -c -g $$(DEBUGCFLAGS) -o $$@.o $(1) + @$$(LD) -g -o $$@ $$@.o $$(LDFLAGS) -lhubbub-debug -lgcov + @$$(RM) $$(RMFLAGS) $$@.o -setup: +endef -export: +$(eval $(foreach TEST,$(addprefix $(d), $(TESTS_$(d))), \ + $(call compile_test,$(addsuffix .c, $(TEST)),$(TEST)))) -test: $(OBJS) - @${PERL} testrunner.pl ${EXEEXT} +# Now include any children we may have +MAKE_INCLUDES := $(wildcard $(d)*/Makefile) +$(eval $(foreach INC, $(MAKE_INCLUDES), $(call do_include,$(INC)))) -# Pattern rules -%: %.c - @${ECHO} ${ECHOFLAGS} "==> $<" - @${CC} -c -g ${CFLAGS} -o $@.o $< - @${LD} -g -o $@ $@.o ${LDFLAGS} -lhubbub-debug - @${RM} ${RMFLAGS} $@.o +# Finally, pop off the directory stack +d := $(dirstack_$(sp)) +sp := $(basename $(sp)) diff --git a/test/data/html/INDEX b/test/data/html/INDEX index 25483db..b33a0d5 100644 --- a/test/data/html/INDEX +++ b/test/data/html/INDEX @@ -6,5 +6,6 @@ section-tree-construction.html HTML5 tree construction algorithm #web-apps.html HTML5 specification initial-close-tag.html Page with initial </html> #phonecalls.html HTML document that breaks libxml's HTML parser -misnested.html Misnested tags -isindex.html Test of <isindex> parsing +#firmaer.phtml Large(ish) document with parse errors +misnested.html Misnested tags +isindex.html Test of <isindex> parsing diff --git a/test/testrunner.pl b/test/testrunner.pl index 0aa4586..4b59969 100644 --- a/test/testrunner.pl +++ b/test/testrunner.pl @@ -2,7 +2,7 @@ # # Testcase runner for libhubbub # -# Usage: testrunner <executable extension> +# Usage: testrunner <directory> [<executable extension>] # # Operates upon INDEX files described in the README. # Locates and executes testcases, feeding data files to programs @@ -16,16 +16,24 @@ use strict; use File::Spec; use IPC::Open3; +if (@ARGV < 1) { + print "Usage: testrunner.pl <directory> [<exeext>]\n"; + exit; +} + +# Get directory +my $directory = shift @ARGV; + # Get EXE extension (if any) my $exeext = ""; $exeext = shift @ARGV if (@ARGV > 0); # Open log file and /dev/null -open(LOG, ">log") or die "Failed opening test log"; +open(LOG, ">$directory/log") or die "Failed opening test log"; open(NULL, "+<", File::Spec->devnull) or die "Failed opening /dev/null"; # Open testcase index -open(TINDEX, "<INDEX") or die "Failed opening test INDEX"; +open(TINDEX, "<$directory/INDEX") or die "Failed opening test INDEX"; # Parse testcase index, looking for testcases while (my $line = <TINDEX>) { @@ -50,8 +58,8 @@ while (my $line = <TINDEX>) { # Testcase has external data files # Open datafile index - open(DINDEX, "<./data/$data/INDEX") or - die "Failed opening ./data/$data/INDEX"; + open(DINDEX, "<$directory/data/$data/INDEX") or + die "Failed opening $directory/data/$data/INDEX"; # Parse datafile index, looking for datafiles while (my $dentry = <DINDEX>) { @@ -64,8 +72,9 @@ while (my $line = <TINDEX>) { $dtest =~ s/^\s+|\s+$//g; $ddesc =~ s/^\s+|\s+$//g; - print LOG "Running ./$test ./data/Aliases " . - "./data/$data/$dtest\n"; + print LOG "Running $directory/$test " . + "$directory/data/Aliases " . + "$directory/data/$data/$dtest\n"; # Make message fit on an 80 column terminal my $msg = " ==> $test [$data/$dtest]"; @@ -75,8 +84,9 @@ while (my $line = <TINDEX>) { # Run testcase $pid = open3("&<NULL", \*OUT, \*ERR, - "./$test", "./data/Aliases", - "./data/$data/$dtest"); + "$directory/$test", + "$directory/data/Aliases", + "$directory/data/$data/$dtest"); my $last = "FAIL"; @@ -108,7 +118,7 @@ while (my $line = <TINDEX>) { close(DINDEX); } else { # Testcase has no external data files - print LOG "Running ./$test ./data/Aliases\n"; + print LOG "Running $directory/$test $directory/data/Aliases\n"; # Make message fit on an 80 column terminal my $msg = " ==> $test"; @@ -118,7 +128,7 @@ while (my $line = <TINDEX>) { # Run testcase $pid = open3("&<NULL", \*OUT, \*ERR, - "./$test", "./data/Aliases"); + "$directory/$test", "$directory/data/Aliases"); my $last = "FAIL"; |