mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 13:22:11 +00:00
beginnings of a test framework
[SVN r11080]
This commit is contained in:
35
test/Jamfile
35
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 ;
|
||||
|
||||
25
test/check-bindrule.jam
Normal file
25
test/check-bindrule.jam
Normal file
@@ -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 ;
|
||||
11
test/check-jam-patches.jam
Normal file
11
test/check-jam-patches.jam
Normal file
@@ -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 ;" ;
|
||||
}
|
||||
34
test/check-test-tools.jam
Normal file
34
test/check-test-tools.jam
Normal file
@@ -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 ;
|
||||
|
||||
@@ -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
|
||||
24
test/test_nt_line_length.jam
Normal file
24
test/test_nt_line_length.jam
Normal file
@@ -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 ;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user