Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/tools/build/v2/test/recursive.jam @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 3.7 KB
Line 
1# (C) Copyright David Abrahams 2001. Permission to copy, use,
2# modify, sell and distribute this software is granted provided this
3# copyright notice appears in all copies. This software is provided
4# "as is" without express or implied warranty, and with no claim as
5# to its suitability for any purpose.
6
7##############################################################
8# Rules and actions that test Jam by invoking it recursively #
9#                                                            #
10# This is necessary for testing anything that requires Jam   #
11# to execute build actions whose results must be checked,    #
12# and anything which exits Jam with a failure code (e.g. a   #
13# failed assertion).                                         #
14##############################################################
15
16# Creates a fake target, always built, which succeeds in building if Invoking a
17# Jamfile containing the given string succeeds. If optional-expected-output is
18# supplied, creates another fake target which succeeds in building if
19# optional-expected-output is in the Jam output.
20#
21# RETURNS: the target name of the Jam command.
22rule Jam ( command : expected-output ? )
23{
24    local jam-cmd = "$(command:G=jam_command)" ;
25   
26    NOTFILE "$(jam-cmd)" ;
27    ALWAYS "$(jam-cmd)" ;
28    DEPENDS all : "$(jam-cmd)" ;
29
30    if ($NT)
31    {
32        redirect on $(jam-cmd) = "nul" ;
33    }
34    else if $(UNIX)
35    {
36        redirect on $(jam-cmd) = "/dev/null" ;
37    }
38
39    if $(VERBOSE)
40    {
41        redirect on $(jam-cmd) = ;
42    }
43
44    invoke-Jam "$(jam-cmd)" ;
45   
46    if $(expected-output)
47    {
48        redirect on $(jam-cmd) = "scratch-output.txt" ;
49        local output-target = "$(expected-output:G=$(command))" ;
50        NOTFILE "$(output-target)" ;
51        ALWAYS "$(output-target)" ;
52        DEPENDS all : "$(output-target)" ;
53        Expect-in-output "$(output-target)" ;
54       
55        if $(VERBOSE)
56        {
57            if $(NT) { VERBOSE on $(output-target) = "type " ; }
58            else { VERBOSE on $(output-target) = "cat " ; }
59        }
60    }
61    return $(jam-cmd) ;
62}
63
64# Just like the "Jam" rule, above, but only succeeds if the Jam command /fails/.
65rule Jam-fail ( command : expected-output ? )
66{
67    local target = [ Jam $(command) : $(expected-output) ] ;
68    FAIL_EXPECTED $(target) ;
69    return $(target) ;
70}
71
72# The temporary jamfile we write is called "temp.jam". If the user has set
73# BOOST_BUILD_ROOT, it will be built there.
74gBOOST_TEST_JAMFILE = temp.jam ;
75LOCATE on gBOOST_TEST_JAMFILE ?= $(BOOST_BUILD_ROOT) ;
76
77# Runs Jam on a temporary Jamfile which contains the string in $(command:G=)
78# and redirects the results into a file whose name is given by $(redirect) on
79# command
80rule invoke-Jam ( command )
81{
82    PREFIX on $(command) = "actions unbuilt { } unbuilt all ;" ;
83    if $(NT)
84    {
85        REMOVE on $(command) = $(SystemRoot)\System32\find ;
86    }
87    REMOVE on $(command) ?= rm ;
88}
89actions invoke-Jam
90{
91    echo $(PREFIX) $(<:G=) > $(gBOOST_TEST_JAMFILE)
92    jam -sBOOST_ROOT=../../.. -sJAMFILE=$(gBOOST_TEST_JAMFILE)  $(JAMARGS) >$(redirect)
93}
94#     $(REMOVE) $(gBOOST_TEST_JAMFILE)
95
96
97# These actions expect to find the ungristed part of $(<) in scratch-output.txt
98# and return a nonzero exit code otherwise
99if $(NT)
100{
101    # Explicitly get the NT find command in case someone has another find in their path.
102    actions quietly Expect-in-output
103    {
104        $(VERBOSE)scratch-output.txt ;
105        $(SystemRoot)\System32\find /C "$(<:G=)" scratch-output.txt >nul
106    }
107}
108else
109{
110    # Not really the right actions for Unix; the argument will be interpreted as
111    # a regular expression. Is there a simpler find?
112    actions quietly Expect-in-output
113    {
114        $(VERBOSE)scratch-output.txt;
115        grep "$(<:G=)" scratch-output.txt
116    }
117}
118
Note: See TracBrowser for help on using the repository browser.