diff --git a/test/Jamfile b/test/Jamfile index d24462332..1b9a73df8 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,36 +1,7 @@ + # establish a project root right here in the test directory, so that we can test # things independently of the boost jambase, etc. project-root ; -include jam-fail.jam ; -include assert-equal.jam ; - -####################################### -# Some example expected failure tests # -####################################### - -# This command always exits with a failure. -Jam-fail "EXIT error ;" ; - -# This should fail to fail -Jam-fail - "include jam-fail.jam ; Jam-fail \"# this innocuous Jamfile should fail to fail\" ;" - ; - -check-arguments goodbye 1 : z ; -check-arguments hello 1-2 3 1-4 : a b : y z z : w ; - -DOLLAR = "\$" ; -Jam-fail "check-arguments hello 1-2 3 1-4 : a b : c d e f : w ;" - : "rule 'hello' expects 3 elements in $(DOLLAR)(2), got arguments ( a b : c d e f : w ) instead." - ; - -Jam-fail "check-arguments goodbye 1 : z x ;" - : "rule 'goodbye' expects 1 elements in $(DOLLAR)(1), got arguments ( z x ) instead." - ; - -Jam-fail "include assert_equal.jam ; assert-equal fubar : ECHO checking that assertions fail ;" - : "ASSERTION FAILURE" - ; - -assert-equal : ECHO checking that assertions succeed ; +include check-test-tools.jam ; +include check-jam-patches.jam ; diff --git a/test/check-bindrule.jam b/test/check-bindrule.jam new file mode 100644 index 000000000..f0045f4e0 --- /dev/null +++ b/test/check-bindrule.jam @@ -0,0 +1,25 @@ +# This rule establishes a dependency, with no special build actions +rule do-nothing +{ + DEPENDS $(<) : $(>) ; +} +actions quietly do-nothing +{ +} + +# Make a non-file target which depends on a file that exists +NOTFILE fake-target ; +SEARCH on file-to-bind = subdir1 ; + +do-nothing fake-target + : file-to-bind ; + +# Set jam up to call our bind-rule +BINDRULE = bind-rule ; + +rule bind-rule +{ + ECHO found: $(<) at $(>) ; +} + +DEPENDS all : fake-target ; \ No newline at end of file diff --git a/test/check-jam-patches.jam b/test/check-jam-patches.jam new file mode 100644 index 000000000..93a97e8f8 --- /dev/null +++ b/test/check-jam-patches.jam @@ -0,0 +1,11 @@ +include recursive.jam ; + +Jam "include check-bindrule.jam ;" + : "found: file-to-bind at subdir1$(SLASH)file-to-bind" + ; + +if $(NT) +{ + # if this one fails, you don't have the line length patch + Jam "include test_nt_line_length.jam ;" ; +} diff --git a/test/check-test-tools.jam b/test/check-test-tools.jam new file mode 100644 index 000000000..a1850052b --- /dev/null +++ b/test/check-test-tools.jam @@ -0,0 +1,34 @@ +include recursive.jam ; +include assert-equal.jam ; + +##################################### +# Test the testing tools right here # +##################################### + +# This command always exits with a failure. +Jam-fail "EXIT error ;" ; + +# This should fail to fail +Jam-fail + "include recursive.jam ; Jam-fail \"# this innocuous Jamfile should fail to fail\" ;" + ; + +check-arguments goodbye 1 : z ; +check-arguments hello 1-2 3 1-4 : a b : y z z : w ; + +DOLLAR = "\$" ; +Jam-fail "check-arguments hello 1-2 3 1-4 : a b : c d e f : w ;" + : "rule 'hello' expects 3 elements in $(DOLLAR)(2), got arguments ( a b : c d e f : w ) instead." + ; + +Jam-fail "check-arguments goodbye 1 : z x ;" + : "rule 'goodbye' expects 1 elements in $(DOLLAR)(1), got arguments ( z x ) instead." + ; + +Jam-fail "include assert-equal.jam ; assert-equal fubar : ECHO checking that assertions fail ;" + : "ASSERTION FAILURE" + ; + +local NOTHING = ; +assert-equal $(NOTHING) : ECHO checking that assertions succeed ; + diff --git a/test/jam-fail.jam b/test/recursive.jam similarity index 51% rename from test/jam-fail.jam rename to test/recursive.jam index 1e5793046..5a75abca2 100644 --- a/test/jam-fail.jam +++ b/test/recursive.jam @@ -1,14 +1,17 @@ -####################################################################### -# Rules and actions for testing the build system's response to errors # -####################################################################### +############################################################## +# Rules and actions that test Jam by invoking it recursively # +############################################################## -# Jam-fail string : optional-expected-output +# Jam string : optional-expected-output # # Creates a fake target, always built, which succeeds in building if -# interpreting the given string causes an error. If optional-expected-output is +# Invoking a Jamfile containing the given string succeeds. If optional-expected-output is # supplied, creates another fake target which succeeds in building if -# optional-expected-output is in the Jam error messages. -rule Jam-fail +# optional-expected-output is in the Jam output. +# +# RETURNS: the target name of the Jam command. +# +rule Jam { local jam-cmd = "$(<:G=jam_command)" ; @@ -16,9 +19,17 @@ rule Jam-fail ALWAYS "$(jam-cmd)" ; DEPENDS all : "$(jam-cmd)" ; - redirect on $(jam-cmd) = "nul" ; - Jam-expect-failure $(jam-cmd) ; + if ($NT) + { + redirect on $(jam-cmd) = "nul" ; + } + else if $(UNIX) + { + redirect on $(jam-cmd) = "/dev/null" ; + } + invoke-Jam "$(jam-cmd)" ; + if $(>) { redirect on $(jam-cmd) = "scratch-output.txt" ; @@ -28,22 +39,39 @@ rule Jam-fail DEPENDS all : "$(output-target)" ; Expect-in-output "$(output-target)" ; } + return $(jam-cmd) ; } -BOOST_TEST_JAMFILE ?= expected-failure.jam ; +# Jam-fail string +rule Jam-fail +{ + FAIL_EXPECTED [ Jam $(<) : $(>) ] ; +} -# Jam-fail-action + +# The temporary jamfile we write is called "temp.jam". If the user has set +# BOOST_BUILD_ROOT, it will be built there. +gBOOST_TEST_JAMFILE = temp.jam ; +LOCATE on gBOOST_TEST_JAMFILE ?= $(BOOST_BUILD_ROOT) ; + +# invoke-Jam # # Will run Jam on a temporary Jamfile which contains the string in $(<:G=) and # redirect the results into a temporary files called scratch-output.txt. -rule Jam-expect-failure +rule invoke-Jam { - FAIL_EXPECTED $(<) ; + PREFIX on $(<) = "actions unbuilt { } unbuilt all ;" ; + if $(NT) + { + REMOVE on $(<) = $(SystemRoot)\System32\find ; + } + REMOVE on $(<) ?= rm ; } -actions Jam-expect-failure +actions invoke-Jam { - echo actions unbuilt { } unbuilt all ; $(<:G=) > expected-failure.jam - jam -f../Jambase -sJAMFILE=expected-failure.jam >$(redirect) + echo $(PREFIX) $(<:G=) > $(gBOOST_TEST_JAMFILE) + jam -f../Jambase -sJAMFILE=$(gBOOST_TEST_JAMFILE) >$(redirect) + $(REMOVE) $(gBOOST_TEST_JAMFILE) } # These actions expect to find the ungristed part of $(<) in scratch-output.txt diff --git a/test/test_nt_line_length.jam b/test/test_nt_line_length.jam new file mode 100644 index 000000000..f6bc046ba --- /dev/null +++ b/test/test_nt_line_length.jam @@ -0,0 +1,24 @@ +if $(NT) +{ + ten = 0 1 2 3 4 5 6 7 8 9 ; + 1x7chars = 0_____ ; + # add a digit and multiply by 10 + 10x8chars = $(ten)$(1x7chars) ; + # add a digit to each of 10 strings and multiply by 10 + 100x9chars = $(ten)$(10x8chars) ; + # add a digit to each of 100 strings and multiply by 10 + 1000x10chars = $(ten)$(100x9chars) ; + + 400x10chars = $(ten[1-4])$(100x9chars) ; + + text on test = $(1000x10chars) $(1000x10chars) ; + JAMSHELL on test = % ; + + actions do_echo + { + echo $(text) + } + do_echo test ; + DEPENDS all : test ; +} + diff --git a/v2/test/Jamfile b/v2/test/Jamfile index d24462332..1b9a73df8 100644 --- a/v2/test/Jamfile +++ b/v2/test/Jamfile @@ -1,36 +1,7 @@ + # establish a project root right here in the test directory, so that we can test # things independently of the boost jambase, etc. project-root ; -include jam-fail.jam ; -include assert-equal.jam ; - -####################################### -# Some example expected failure tests # -####################################### - -# This command always exits with a failure. -Jam-fail "EXIT error ;" ; - -# This should fail to fail -Jam-fail - "include jam-fail.jam ; Jam-fail \"# this innocuous Jamfile should fail to fail\" ;" - ; - -check-arguments goodbye 1 : z ; -check-arguments hello 1-2 3 1-4 : a b : y z z : w ; - -DOLLAR = "\$" ; -Jam-fail "check-arguments hello 1-2 3 1-4 : a b : c d e f : w ;" - : "rule 'hello' expects 3 elements in $(DOLLAR)(2), got arguments ( a b : c d e f : w ) instead." - ; - -Jam-fail "check-arguments goodbye 1 : z x ;" - : "rule 'goodbye' expects 1 elements in $(DOLLAR)(1), got arguments ( z x ) instead." - ; - -Jam-fail "include assert_equal.jam ; assert-equal fubar : ECHO checking that assertions fail ;" - : "ASSERTION FAILURE" - ; - -assert-equal : ECHO checking that assertions succeed ; +include check-test-tools.jam ; +include check-jam-patches.jam ; diff --git a/v2/test/check-bindrule.jam b/v2/test/check-bindrule.jam new file mode 100644 index 000000000..f0045f4e0 --- /dev/null +++ b/v2/test/check-bindrule.jam @@ -0,0 +1,25 @@ +# This rule establishes a dependency, with no special build actions +rule do-nothing +{ + DEPENDS $(<) : $(>) ; +} +actions quietly do-nothing +{ +} + +# Make a non-file target which depends on a file that exists +NOTFILE fake-target ; +SEARCH on file-to-bind = subdir1 ; + +do-nothing fake-target + : file-to-bind ; + +# Set jam up to call our bind-rule +BINDRULE = bind-rule ; + +rule bind-rule +{ + ECHO found: $(<) at $(>) ; +} + +DEPENDS all : fake-target ; \ No newline at end of file diff --git a/v2/test/check-jam-patches.jam b/v2/test/check-jam-patches.jam new file mode 100644 index 000000000..93a97e8f8 --- /dev/null +++ b/v2/test/check-jam-patches.jam @@ -0,0 +1,11 @@ +include recursive.jam ; + +Jam "include check-bindrule.jam ;" + : "found: file-to-bind at subdir1$(SLASH)file-to-bind" + ; + +if $(NT) +{ + # if this one fails, you don't have the line length patch + Jam "include test_nt_line_length.jam ;" ; +} diff --git a/v2/test/check-test-tools.jam b/v2/test/check-test-tools.jam new file mode 100644 index 000000000..a1850052b --- /dev/null +++ b/v2/test/check-test-tools.jam @@ -0,0 +1,34 @@ +include recursive.jam ; +include assert-equal.jam ; + +##################################### +# Test the testing tools right here # +##################################### + +# This command always exits with a failure. +Jam-fail "EXIT error ;" ; + +# This should fail to fail +Jam-fail + "include recursive.jam ; Jam-fail \"# this innocuous Jamfile should fail to fail\" ;" + ; + +check-arguments goodbye 1 : z ; +check-arguments hello 1-2 3 1-4 : a b : y z z : w ; + +DOLLAR = "\$" ; +Jam-fail "check-arguments hello 1-2 3 1-4 : a b : c d e f : w ;" + : "rule 'hello' expects 3 elements in $(DOLLAR)(2), got arguments ( a b : c d e f : w ) instead." + ; + +Jam-fail "check-arguments goodbye 1 : z x ;" + : "rule 'goodbye' expects 1 elements in $(DOLLAR)(1), got arguments ( z x ) instead." + ; + +Jam-fail "include assert-equal.jam ; assert-equal fubar : ECHO checking that assertions fail ;" + : "ASSERTION FAILURE" + ; + +local NOTHING = ; +assert-equal $(NOTHING) : ECHO checking that assertions succeed ; + diff --git a/v2/test/jam-fail.jam b/v2/test/recursive.jam similarity index 51% rename from v2/test/jam-fail.jam rename to v2/test/recursive.jam index 1e5793046..5a75abca2 100644 --- a/v2/test/jam-fail.jam +++ b/v2/test/recursive.jam @@ -1,14 +1,17 @@ -####################################################################### -# Rules and actions for testing the build system's response to errors # -####################################################################### +############################################################## +# Rules and actions that test Jam by invoking it recursively # +############################################################## -# Jam-fail string : optional-expected-output +# Jam string : optional-expected-output # # Creates a fake target, always built, which succeeds in building if -# interpreting the given string causes an error. If optional-expected-output is +# Invoking a Jamfile containing the given string succeeds. If optional-expected-output is # supplied, creates another fake target which succeeds in building if -# optional-expected-output is in the Jam error messages. -rule Jam-fail +# optional-expected-output is in the Jam output. +# +# RETURNS: the target name of the Jam command. +# +rule Jam { local jam-cmd = "$(<:G=jam_command)" ; @@ -16,9 +19,17 @@ rule Jam-fail ALWAYS "$(jam-cmd)" ; DEPENDS all : "$(jam-cmd)" ; - redirect on $(jam-cmd) = "nul" ; - Jam-expect-failure $(jam-cmd) ; + if ($NT) + { + redirect on $(jam-cmd) = "nul" ; + } + else if $(UNIX) + { + redirect on $(jam-cmd) = "/dev/null" ; + } + invoke-Jam "$(jam-cmd)" ; + if $(>) { redirect on $(jam-cmd) = "scratch-output.txt" ; @@ -28,22 +39,39 @@ rule Jam-fail DEPENDS all : "$(output-target)" ; Expect-in-output "$(output-target)" ; } + return $(jam-cmd) ; } -BOOST_TEST_JAMFILE ?= expected-failure.jam ; +# Jam-fail string +rule Jam-fail +{ + FAIL_EXPECTED [ Jam $(<) : $(>) ] ; +} -# Jam-fail-action + +# The temporary jamfile we write is called "temp.jam". If the user has set +# BOOST_BUILD_ROOT, it will be built there. +gBOOST_TEST_JAMFILE = temp.jam ; +LOCATE on gBOOST_TEST_JAMFILE ?= $(BOOST_BUILD_ROOT) ; + +# invoke-Jam # # Will run Jam on a temporary Jamfile which contains the string in $(<:G=) and # redirect the results into a temporary files called scratch-output.txt. -rule Jam-expect-failure +rule invoke-Jam { - FAIL_EXPECTED $(<) ; + PREFIX on $(<) = "actions unbuilt { } unbuilt all ;" ; + if $(NT) + { + REMOVE on $(<) = $(SystemRoot)\System32\find ; + } + REMOVE on $(<) ?= rm ; } -actions Jam-expect-failure +actions invoke-Jam { - echo actions unbuilt { } unbuilt all ; $(<:G=) > expected-failure.jam - jam -f../Jambase -sJAMFILE=expected-failure.jam >$(redirect) + echo $(PREFIX) $(<:G=) > $(gBOOST_TEST_JAMFILE) + jam -f../Jambase -sJAMFILE=$(gBOOST_TEST_JAMFILE) >$(redirect) + $(REMOVE) $(gBOOST_TEST_JAMFILE) } # These actions expect to find the ungristed part of $(<) in scratch-output.txt diff --git a/v2/test/test_nt_line_length.jam b/v2/test/test_nt_line_length.jam new file mode 100644 index 000000000..f6bc046ba --- /dev/null +++ b/v2/test/test_nt_line_length.jam @@ -0,0 +1,24 @@ +if $(NT) +{ + ten = 0 1 2 3 4 5 6 7 8 9 ; + 1x7chars = 0_____ ; + # add a digit and multiply by 10 + 10x8chars = $(ten)$(1x7chars) ; + # add a digit to each of 10 strings and multiply by 10 + 100x9chars = $(ten)$(10x8chars) ; + # add a digit to each of 100 strings and multiply by 10 + 1000x10chars = $(ten)$(100x9chars) ; + + 400x10chars = $(ten[1-4])$(100x9chars) ; + + text on test = $(1000x10chars) $(1000x10chars) ; + JAMSHELL on test = % ; + + actions do_echo + { + echo $(text) + } + do_echo test ; + DEPENDS all : test ; +} +