2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 01:12:13 +00:00

Boost Build cleanup - minor stylistic internal Boost Build test script & testing system changes.

[SVN r79445]
This commit is contained in:
Jurko Gospodnetić
2012-07-12 12:22:14 +00:00
parent c94e5a36c6
commit f9c5030d40
69 changed files with 834 additions and 1105 deletions

View File

@@ -210,17 +210,17 @@ class Tester(TestCmd.TestCmd):
Optional arguments inherited from the base class:
`description` - Test description string displayed in case of
a failed test.
`description` - Test description string displayed in case
of a failed test.
`subdir' - List of subdirectories to automatically
create under the working directory. Each
subdirectory needs to be specified
separately parent coming before its child.
`verbose` - Flag that may be used to enable more verbose
test system output. Note that it does not
also enable more verbose build system
output like the --verbose command line
option does.
separately, parent coming before its child.
`verbose` - Flag that may be used to enable more
verbose test system output. Note that it
does not also enable more verbose build
system output like the --verbose command
line option does.
"""
def __init__(self, arguments="", executable="bjam",
match=TestCmd.match_exact, boost_build_path=None,

View File

@@ -343,7 +343,7 @@ class TestCmd:
TestCmd environment to be preserved for one or more conditions. If no
conditions are specified, arranges for the temporary working
directories to be preserved for all conditions.
"""
if conditions is ():
conditions = ('pass_test', 'fail_test', 'no_result')
@@ -362,7 +362,7 @@ class TestCmd:
name may be a list, in which case the elements are concatenated with
the os.path.join() method. The file is assumed to be under the
temporary working directory unless it is an absolute path name. The I/O
mode for the file may be specified; it must begin with an 'r'. The
mode for the file may be specified and must begin with an 'r'. The
default is 'rb' (binary read).
"""
@@ -513,8 +513,8 @@ class TestCmd:
run = len(self._stderr)
elif run < 0:
run = len(self._stderr) + run
run = run - 1
if (run < 0):
run -= 1
if run < 0:
return ''
return self._stderr[run]
@@ -530,8 +530,8 @@ class TestCmd:
run = len(self._stdout)
elif run < 0:
run = len(self._stdout) + run
run = run - 1
if (run < 0):
run -= 1
if run < 0:
return ''
return self._stdout[run]
@@ -563,7 +563,7 @@ class TestCmd:
count += 1
return count
def unlink (self, file):
def unlink(self, file):
"""
Unlinks the specified file name. The file name may be a list, in
which case the elements are concatenated using the os.path.join()
@@ -578,8 +578,7 @@ class TestCmd:
os.unlink(file)
def verbose_set(self, verbose):
"""Set the verbose level.
"""
"""Set the verbose level."""
self.verbose = verbose
def workdir_set(self, path):
@@ -618,8 +617,7 @@ class TestCmd:
"""
Returns the absolute path name to a subdirectory or file within the
current temporary working directory. Concatenates the temporary working
directory name with the specified arguments using the os.path.join()
method.
directory name with the specified arguments using os.path.join().
"""
return apply(os.path.join, (self.workdir,) + tuple(args))
@@ -656,8 +654,8 @@ class TestCmd:
file name (first argument). The file name may be a list, in which case
the elements are concatenated using the os.path.join() method. The file
is created under the temporary working directory. Any subdirectories in
the path must already exist. The I/O mode for the file may be specified;
it must begin with a 'w'. The default is 'wb' (binary write).
the path must already exist. The I/O mode for the file may be specified
and must begin with a 'w'. The default is 'wb' (binary write).
"""
if type(file) is ListType:

View File

@@ -10,45 +10,29 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
path-constant TOP : . ;
""")
t.write("jamfile.jam", """
t.write("jamroot.jam", "path-constant TOP : . ;")
t.write("jamfile.jam", """\
local pwd = [ PWD ] ;
ECHO $(pwd) XXXXX ;
exe hello : $(pwd)/hello.cpp $(TOP)/empty.cpp ;
""")
t.write("hello.cpp", "int main() {}\n")
t.write("empty.cpp", "\n")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/hello.exe")
t.rm(".")
# Test a contrived case. There, absolute name is used in a standalone project
# (not Jamfile). Moreover, the target with an absolute name is returned by
# 'alias' and used from another project.
t.write("a.cpp", """
int main() {}
""")
t.write("jamfile.jam", """
exe a : /standalone//a ;
""")
t.write("jamroot.jam", """
import standalone ;
""")
t.write("standalone.jam", """
# Test a contrived case in which an absolute name is used in a standalone
# project (not Jamfile). Moreover, the target with an absolute name is returned
# via an 'alias' and used from another project.
t.write("a.cpp", "int main() {}\n")
t.write("jamfile.jam", "exe a : /standalone//a ;")
t.write("jamroot.jam", "import standalone ;")
t.write("standalone.jam", """\
import project ;
project.initialize $(__name__) ;
project standalone ;
local pwd = [ PWD ] ;
alias a : $(pwd)/a.cpp ;
""")
@@ -75,18 +59,10 @@ t.expect_addition("bin/$toolset/debug/a.exe")
t.rm(".")
t.write("d1/jamroot.jam", "")
t.write("d1/jamfile.jam", """
exe a : a.cpp ;
""")
t.write("d1/a.cpp", """
int main() {}
""")
t.write("d1/jamfile.jam", "exe a : a.cpp ;")
t.write("d1/a.cpp", "int main() {}\n")
t.write("d2/jamroot.jam", "")
t.write("d2/jamfile.jam", """
t.write("d2/jamfile.jam", """\
local pwd = [ PWD ] ;
alias x : $(pwd)/../d1//a ;
""")

View File

@@ -50,8 +50,8 @@ t.expect_addition("bin/$toolset/debug/X-on/a.obj")
t.rm("bin")
# Test that everything works ok even with default build.
t.write("jamfile.jam", """
# Test that everything works ok even with the default build.
t.write("jamfile.jam", """\
exe a : a_empty.cpp : <variant>release ;
exe a : a.cpp : <variant>debug ;
""")
@@ -59,10 +59,10 @@ exe a : a.cpp : <variant>debug ;
t.run_build_system()
t.expect_addition("bin/$toolset/debug/a.exe")
# Test that only properties which are in build request matter for alternative
# selection. IOW, alternative with <variant>release is better than one with
# <variant>debug when building release version.
t.write("jamfile.jam", """
# Test that only properties which are in the build request matter for
# alternative selection. IOW, alternative with <variant>release is better than
# one with <variant>debug when building the release variant.
t.write("jamfile.jam", """\
exe a : a_empty.cpp : <variant>debug ;
exe a : a.cpp : <variant>release ;
""")
@@ -82,7 +82,7 @@ t.run_build_system("release define=FOO")
t.expect_addition("bin/$toolset/release/a.exe")
# Test that ambiguity is reported correctly.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a_empty.cpp ;
exe a : a.cpp ;
""")
@@ -91,7 +91,7 @@ t.fail_test(string.find(t.stdout(), "No best alternative") == -1)
# Another ambiguity test: two matches properties in one alternative are neither
# better nor worse than a single one in another alternative.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a_empty.cpp : <optimization>off <profiling>off ;
exe a : a.cpp : <debug-symbols>on ;
""")
@@ -100,7 +100,7 @@ t.run_build_system("--no-error-backtrace", status=None)
t.fail_test(string.find(t.stdout(), "No best alternative") == -1)
# Test that we can have alternative without sources.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
alias specific-sources ;
import feature ;
feature.extend os : MAGIC ;

View File

@@ -17,7 +17,7 @@ t = BoostBuild.Tester()
# Test that top-level project can affect build dir.
t.write("jamroot.jam", "import gcc ;")
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
project : build-dir build ;
exe a : a.cpp ;
build-project src ;
@@ -40,12 +40,12 @@ t.ignore("build/config.log")
t.expect_nothing_more()
# Test that project can override build dir.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp ;
build-project src ;
""")
t.write("src/jamfile.jam", """
t.write("src/jamfile.jam", """\
project : build-dir build ;
exe b : b.cpp ;
""")
@@ -63,7 +63,7 @@ t.run_build_system("--build-dir=foo")
t.fail_test(string.find(t.stdout(),
"warning: the --build-dir option will be ignored") == -1)
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
project foo ;
exe a : a.cpp ;
build-project sub ;
@@ -76,7 +76,7 @@ t.run_build_system("--build-dir=build")
t.expect_addition(["build/foo/$toolset/debug/a.exe",
"build/foo/sub/$toolset/debug/b.exe"])
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
project foo : build-dir bin.v2 ;
exe a : a.cpp ;
build-project sub ;
@@ -87,13 +87,13 @@ t.expect_addition(["build/foo/bin.v2/$toolset/debug/a.exe",
"build/foo/bin.v2/sub/$toolset/debug/b.exe"])
# Try building in subdir. We expect that the entire build tree with be in
# 'sub/build'. Today, I am not sure if this is what the user expects, but let it
# be.
# 'sub/build'. Today, I am not sure if this is what the user expects, but let
# it be.
t.rm('build')
t.run_build_system("--build-dir=build", subdir="sub")
t.expect_addition(["sub/build/foo/bin.v2/sub/$toolset/debug/b.exe"])
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
project foo : build-dir %s ;
exe a : a.cpp ;
build-project sub ;

View File

@@ -6,34 +6,34 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Tests that we explicitly request a file (not target) to be built by specifying
# its name on the command line.
# Tests that we explicitly request a file (not target) to be built by
# specifying its name on the command line.
import BoostBuild
################################################################################
###############################################################################
#
# test_building_file_from_specific_project()
# ------------------------------------------
#
################################################################################
###############################################################################
def test_building_file_from_specific_project():
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
build-project sub ;
""")
t.write("hello.cpp", "int main() {}")
t.write("hello.cpp", "int main() {}\n")
t.write("sub/jamfile.jam", """
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
exe sub : hello.cpp ;
""")
t.write("sub/hello.cpp", "int main() {}")
t.write("sub/hello.cpp", "int main() {}\n")
t.run_build_system("sub " + t.adjust_suffix("hello.obj"))
t.expect_output_line("*depends on itself*", False)
@@ -43,24 +43,24 @@ exe sub : hello.cpp ;
t.cleanup()
################################################################################
###############################################################################
#
# test_building_file_from_specific_target()
# -----------------------------------------
#
################################################################################
###############################################################################
def test_building_file_from_specific_target():
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello1 : hello1.cpp ;
exe hello2 : hello2.cpp ;
exe hello3 : hello3.cpp ;
""")
t.write("hello1.cpp", "int main() {}")
t.write("hello2.cpp", "int main() {}")
t.write("hello3.cpp", "int main() {}")
t.write("hello1.cpp", "int main() {}\n")
t.write("hello2.cpp", "int main() {}\n")
t.write("hello3.cpp", "int main() {}\n")
t.run_build_system("hello1 " + t.adjust_suffix("hello1.obj"))
t.expect_addition("bin/$toolset/debug/hello1.obj")
@@ -69,54 +69,54 @@ exe hello3 : hello3.cpp ;
t.cleanup()
################################################################################
###############################################################################
#
# test_building_missing_file_from_specific_target()
# -------------------------------------------------
#
################################################################################
###############################################################################
def test_building_missing_file_from_specific_target():
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello1 : hello1.cpp ;
exe hello2 : hello2.cpp ;
exe hello3 : hello3.cpp ;
""")
t.write("hello1.cpp", "int main() {}")
t.write("hello2.cpp", "int main() {}")
t.write("hello3.cpp", "int main() {}")
t.write("hello1.cpp", "int main() {}\n")
t.write("hello2.cpp", "int main() {}\n")
t.write("hello3.cpp", "int main() {}\n")
t.run_build_system("hello1 " + t.adjust_suffix("hello2.obj"), status=1)
t.expect_output_line("don't know how to make*" + t.adjust_suffix("hello2.obj"))
obj = t.adjust_suffix("hello2.obj")
t.run_build_system("hello1 " + obj, status=1)
t.expect_output_line("don't know how to make*" + obj)
t.expect_nothing_more()
t.cleanup()
################################################################################
###############################################################################
#
# test_building_multiple_files_with_different_names()
# ---------------------------------------------------
#
################################################################################
###############################################################################
def test_building_multiple_files_with_different_names():
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello1 : hello1.cpp ;
exe hello2 : hello2.cpp ;
exe hello3 : hello3.cpp ;
""")
t.write("hello1.cpp", "int main() {}")
t.write("hello2.cpp", "int main() {}")
t.write("hello3.cpp", "int main() {}")
t.write("hello1.cpp", "int main() {}\n")
t.write("hello2.cpp", "int main() {}\n")
t.write("hello3.cpp", "int main() {}\n")
t.run_build_system(
t.adjust_suffix("hello1.obj") + " " +
t.adjust_suffix("hello2.obj"))
t.run_build_system(t.adjust_suffix("hello1.obj") + " " + t.adjust_suffix(
"hello2.obj"))
t.expect_addition("bin/$toolset/debug/hello1.obj")
t.expect_addition("bin/$toolset/debug/hello2.obj")
t.expect_nothing_more()
@@ -124,28 +124,28 @@ exe hello3 : hello3.cpp ;
t.cleanup()
################################################################################
###############################################################################
#
# test_building_multiple_files_with_the_same_name()
# -------------------------------------------------
#
################################################################################
###############################################################################
def test_building_multiple_files_with_the_same_name():
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
build-project sub ;
""")
t.write("hello.cpp", "int main() {}")
t.write("hello.cpp", "int main() {}\n")
t.write("sub/jamfile.jam", """
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
exe sub : hello.cpp ;
""")
t.write("sub/hello.cpp", "int main() {}")
t.write("sub/hello.cpp", "int main() {}\n")
t.run_build_system(t.adjust_suffix("hello.obj"))
t.expect_output_line("*depends on itself*", False)
@@ -156,12 +156,12 @@ exe sub : hello.cpp ;
t.cleanup()
################################################################################
###############################################################################
#
# main()
# ------
#
################################################################################
###############################################################################
test_building_file_from_specific_project()
test_building_file_from_specific_target()

View File

@@ -11,13 +11,8 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
exe hello : hello.cpp : <variant>debug:<build>no ;
""")
t.write("hello.cpp", """
int main() {}
""")
t.write("jamroot.jam", "exe hello : hello.cpp : <variant>debug:<build>no ;")
t.write("hello.cpp", "int main() {}\n")
t.run_build_system()
t.expect_nothing_more()

View File

@@ -9,19 +9,19 @@
import BoostBuild
def test_echo(name):
t = BoostBuild.Tester(pass_toolset=0)
t = BoostBuild.Tester("-ffile.jam", pass_toolset=0)
t.write("file.jam", """
%s ;
UPDATE ;
""" % name)
t.run_build_system("-ffile.jam", stdout="\n")
t.write("file.jam", """\
%s ;
UPDATE ;
""" % name)
t.run_build_system(stdout="\n")
t.write("file.jam", """
%s a message ;
UPDATE ;
""" % name)
t.run_build_system("-ffile.jam", stdout="a message\n")
t.write("file.jam", """\
%s a message ;
UPDATE ;
""" % name)
t.run_build_system(stdout="a message\n")
t.cleanup()

View File

@@ -9,42 +9,30 @@
import BoostBuild
def test_exit(name):
t = BoostBuild.Tester(pass_toolset=0)
t = BoostBuild.Tester("-ffile.jam", pass_toolset=0)
t.write("file.jam", """
%s ;
""" % name)
t.run_build_system("-ffile.jam", status=1, stdout="\n")
t.write("file.jam", "%s ;" % name)
t.run_build_system(status=1, stdout="\n")
t.rm(".")
t.write("file.jam", """
%s : 0 ;
""" % name)
t.run_build_system("-ffile.jam", stdout="\n")
t.write("file.jam", "%s : 0 ;" % name)
t.run_build_system(stdout="\n")
t.rm(".")
t.write("file.jam", """
%s : 1 ;
""" % name)
t.run_build_system("-ffile.jam", status=1, stdout="\n")
t.write("file.jam", "%s : 1 ;" % name)
t.run_build_system(status=1, stdout="\n")
t.rm(".")
t.write("file.jam", """
%s : 2 ;
""" % name)
t.run_build_system("-ffile.jam", status=2, stdout="\n")
t.write("file.jam", "%s : 2 ;" % name)
t.run_build_system(status=2, stdout="\n")
t.rm(".")
t.write("file.jam", """
%s a message ;
""" % name)
t.run_build_system("-ffile.jam", status=1, stdout="a message\n")
t.write("file.jam", "%s a message ;" % name)
t.run_build_system(status=1, stdout="a message\n")
t.rm(".")
t.write("file.jam", """
%s a message : 0 ;
""" % name)
t.run_build_system("-ffile.jam", stdout="a message\n")
t.write("file.jam", "%s a message : 0 ;" % name)
t.run_build_system(stdout="a message\n")
t.rm(".")
t.cleanup()

View File

@@ -10,15 +10,15 @@ import BoostBuild
def test_invalid(params, expected_error_line):
t = BoostBuild.Tester(pass_toolset=0)
t.write("file.jam", "SPLIT_BY_CHARACTERS %s ;\n" % params)
t.write("file.jam", "SPLIT_BY_CHARACTERS %s ;" % params)
t.run_build_system("-ffile.jam", status=1)
t.expect_output_line("[*] %s" % expected_error_line)
t.cleanup()
def test_valid():
t = BoostBuild.Tester(pass_toolset=0)
t.write("jamroot.jam",
"""import assert ;
t.write("jamroot.jam", """\
import assert ;
assert.result FooBarBaz : SPLIT_BY_CHARACTERS FooBarBaz : "" ;
assert.result FooBarBaz : SPLIT_BY_CHARACTERS FooBarBaz : x ;

View File

@@ -9,56 +9,44 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("a.cpp", """
int main() {}
""")
t.write("jamroot.jam", """
exe a : a.cpp sub1//sub1 sub2//sub2 sub3//sub3 ;
""")
t.write("sub1/jamfile.jam", """
t.write("a.cpp", "int main() {}\n")
t.write("jamroot.jam", "exe a : a.cpp sub1//sub1 sub2//sub2 sub3//sub3 ;")
t.write("sub1/jamfile.jam", """\
lib sub1 : sub1.cpp sub1_2 ../sub2//sub2 ;
lib sub1_2 : sub1_2.cpp ;
""")
t.write("sub1/sub1.cpp", """
t.write("sub1/sub1.cpp", """\
#ifdef _WIN32
__declspec(dllexport)
#endif
void sub1() {}
""")
t.write("sub1/sub1_2.cpp", """
t.write("sub1/sub1_2.cpp", """\
#ifdef _WIN32
__declspec(dllexport)
#endif
void sub1() {}
""")
t.write("sub2/jamfile.jam", """
lib sub2 : sub2.cpp ;
""")
t.write("sub2/sub2.cpp", """
t.write("sub2/jamfile.jam", "lib sub2 : sub2.cpp ;")
t.write("sub2/sub2.cpp", """\
#ifdef _WIN32
__declspec(dllexport)
#endif
void sub2() {}
""")
t.write("sub3/jamroot.jam", """
lib sub3 : sub3.cpp ;
""")
t.write("sub3/sub3.cpp", """
t.write("sub3/jamroot.jam", "lib sub3 : sub3.cpp ;")
t.write("sub3/sub3.cpp", """\
#ifdef _WIN32
__declspec(dllexport)
#endif
void sub3() {}
""")
# The 'clean' should not remove files under separate jamroot.jam.
# 'clean' should not remove files under separate jamroot.jam.
t.run_build_system()
t.run_build_system("--clean")
t.expect_removal("bin/$toolset/debug/a.obj")
@@ -67,7 +55,7 @@ t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
t.expect_removal("sub2/bin/$toolset/debug/sub2.obj")
t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
# The 'clean-all' removes everything it can reach.
# 'clean-all' removes everything it can reach.
t.run_build_system()
t.run_build_system("--clean-all")
t.expect_removal("bin/$toolset/debug/a.obj")
@@ -76,7 +64,7 @@ t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
t.expect_removal("sub2/bin/$toolset/debug/sub2.obj")
t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
# The 'clean' together with project target removes only under that project.
# 'clean' together with project target removes only under that project.
t.run_build_system()
t.run_build_system("sub1 --clean")
t.expect_nothing("bin/$toolset/debug/a.obj")
@@ -85,7 +73,7 @@ t.expect_removal("sub1/bin/$toolset/debug/sub1_2.obj")
t.expect_nothing("sub2/bin/$toolset/debug/sub2.obj")
t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
# And 'clean-all' removes everything.
# 'clean-all' removes everything.
t.run_build_system()
t.run_build_system("sub1 --clean-all")
t.expect_nothing("bin/$toolset/debug/a.obj")
@@ -105,7 +93,7 @@ t.expect_nothing("sub3/bin/$toolset/debug/sub3.obj")
# Regression test: sources of the 'cast' rule were mistakenly deleted.
t.rm(".")
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import cast ;
cast a cpp : a.h ;
""")

View File

@@ -13,7 +13,7 @@ t = BoostBuild.Tester()
# Arrange a project which will build only if 'a.cpp' is compiled with "STATIC"
# define.
t.write("a.cpp", """
t.write("a.cpp", """\
#ifdef STATIC
int main() {}
#endif
@@ -34,8 +34,8 @@ t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/a.exe")
t.rm("bin")
# Regression test for a bug found by Ali Azarbayejani. Conditionals inside usage
# requirement were not being evaluated.
# Regression test for a bug found by Ali Azarbayejani. Conditionals inside
# usage requirement were not being evaluated.
t.write("jamroot.jam", """
lib l : l.cpp : : : <link>static:<define>STATIC ;
exe a : a.cpp l ;

View File

@@ -18,26 +18,24 @@ import BoostBuild
################################################################################
def test_multiple_conditions():
"""Basic tests for properties conditioned on multiple other properties.
"""
"""Basic tests for properties conditioned on multiple other properties."""
t = BoostBuild.Tester("--user-config= --ignore-site-config toolset=testToolset",
pass_toolset=False, use_test_config=False)
t = BoostBuild.Tester("--user-config= --ignore-site-config "
"toolset=testToolset", pass_toolset=False, use_test_config=False)
t.write("testToolset.jam", """
t.write("testToolset.jam", """\
import feature ;
feature.extend toolset : testToolset ;
rule init ( ) { }
""")
t.write("testToolset.py", """
t.write("testToolset.py", """\
from b2.build import feature
feature.extend('toolset', ["testToolset"])
def init ( ):
pass
def init ( ): pass
""")
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import feature ;
import notfile ;
import toolset ;
@@ -127,30 +125,31 @@ notfile testTarget1 : @buildRule : :
################################################################################
def test_multiple_conditions_with_toolset_version():
"""Regression tests for properties conditioned on the toolset version
subfeature and some additional properties.
"""
Regression tests for properties conditioned on the toolset version
subfeature and some additional properties.
"""
toolset = "testToolset" ;
t = BoostBuild.Tester("--user-config= --ignore-site-config", pass_toolset=False, use_test_config=False)
t = BoostBuild.Tester("--user-config= --ignore-site-config",
pass_toolset=False, use_test_config=False)
t.write( toolset + ".jam", """
t.write(toolset + ".jam", """\
import feature ;
feature.extend toolset : %(toolset)s ;
feature.subfeature toolset %(toolset)s : version : 0 1 ;
rule init ( version ? ) { }
""" % {"toolset": toolset})
t.write( "testToolset.py", """
t.write("testToolset.py", """\
from b2.build import feature
feature.extend('toolset', ["testToolset"])
feature.subfeature('toolset',"testToolset","version",['0','1'])
def init ( version ):
pass
""")
feature.extend('toolset', ["%(toolset)s"])
feature.subfeature('toolset', "%(toolset)s", "version", ['0','1'])
def init ( version ): pass
""" % {"toolset": toolset})
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import feature ;
import notfile ;
import toolset ;

View File

@@ -1,21 +1,19 @@
#!/usr/bin/python
#
# Copyright (c) 2008
# Steven Watanabe
# Copyright (c) 2008 Steven Watanabe
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Test that the common.copy rule set the modification
# date of the new file the current time.
# Test that the common.copy rule set the modification date of the new file to
# the current time.
import BoostBuild
tester = BoostBuild.Tester()
tester.write("test1.cpp", """
#include <iostream>
tester.write("test1.cpp", """\
template<bool, int M, class Next>
struct time_waster {
typedef typename time_waster<true, M-1, time_waster>::type type1;
@@ -30,8 +28,7 @@ typedef time_waster<true, 10, void>::type type;
int f() { return 0; }
""")
tester.write("test2.cpp", """
#include <iostream>
tester.write("test2.cpp", """\
template<bool, int M, class Next>
struct time_waster {
typedef typename time_waster<true, M-1, time_waster>::type type1;
@@ -46,14 +43,13 @@ typedef time_waster<true, 10, void>::type type;
int g() { return 0; }
""")
tester.write("jamroot.jam", """
tester.write("jamroot.jam", """\
obj test2 : test2.cpp ;
obj test1 : test1.cpp : <dependency>test2 ;
install test2i : test2 : <dependency>test1 ;
""")
tester.run_build_system()
tester.expect_addition("bin/$toolset/debug/test2.obj")
tester.expect_addition("bin/$toolset/debug/test1.obj")
tester.expect_addition("test2i/test2.obj")
@@ -61,14 +57,11 @@ tester.expect_nothing_more()
test2src = tester.read("test2i/test2.obj")
test2dest = tester.read("bin/$toolset/debug/test2.obj")
if test2src != test2dest:
BoostBuild.annotation("failure", "The object file was not copied correctly")
BoostBuild.annotation("failure", "The object file was not copied "
"correctly")
tester.fail_test(1)
del test2src
del test2dest
tester.run_build_system("-d1")
tester.expect_output_line("common.copy*", expected_to_exist=False)
tester.expect_nothing_more()

View File

@@ -2,24 +2,24 @@
# Copyright 2007 Rene Rivera.
# Copyright 2011 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.write("file.jam", """
actions quietly .a. { $(ACTION) }
t.write("file.jam", """\
actions quietly .a. { $(ACTION) }
rule .a.
{
DEPENDS $(<) : $(>) ;
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
DEPENDS all : subtest_a ;
NOTFILE subtest ;
.a. subtest_a : subtest ;
DEPENDS all : subtest_a ;
""")
t.run_build_system("-ffile.jam -sACTION=invalid", status=1)

View File

@@ -2,40 +2,41 @@
# Copyright 2007 Rene Rivera.
# Copyright 2011 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.write("file.jam", """
actions quietly .a.
{
t.write("file.jam", """\
actions quietly .a.
{
echo [$(<:B)] 0
echo [$(<:B)] 1
echo [$(<:B)] 2
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
.a. subtest_b : subtest ;
DEPENDS all : subtest_a subtest_b ;
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
.a. subtest_b : subtest ;
DEPENDS all : subtest_a subtest_b ;
""")
t.run_build_system("-ffile.jam -d2", stdout="""...found 4 targets...
t.run_build_system("-ffile.jam -d2", stdout="""\
...found 4 targets...
...updating 2 targets...
.a. subtest_a
echo [subtest_a] 0
echo [subtest_a] 1
echo [subtest_a] 2
[subtest_a] 0
[subtest_a] 1
[subtest_a] 2
@@ -44,14 +45,15 @@ echo [subtest_a] 2
echo [subtest_b] 0
echo [subtest_b] 1
echo [subtest_b] 2
[subtest_b] 0
[subtest_b] 1
[subtest_b] 2
...updated 2 targets...
""")
t.run_build_system("-ffile.jam -d1", stdout="""...found 4 targets...
t.run_build_system("-ffile.jam -d1", stdout="""\
...found 4 targets...
...updating 2 targets...
...updated 2 targets...
""")

View File

@@ -31,7 +31,7 @@ def test_varargs(t, *args, **kwargs):
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("echo_args.jam", """
t.write("echo_args.jam", """\
NOCARE all ;
rule echo_args ( a b ? c ? : d + : e * )

View File

@@ -8,68 +8,56 @@
import BoostBuild
import os
t = BoostBuild.Tester(pass_toolset=0)
t = BoostBuild.Tester("-ffile.jam", pass_toolset=0)
t.write("file.jam", """
t.write("file.jam", """\
name = n1 n2 ;
contents = M1 M2 ;
EXIT file: "@(o$(name) .txt:E= test -D$(contents))" : 0 ;
""")
t.run_build_system("-ffile.jam")
t.run_build_system()
t.expect_output_line("file: on1 on2 .txt");
t.expect_addition("on1 on2 .txt")
t.expect_content("on1 on2 .txt", " test -DM1 -DM2", True)
t.rm(".")
t.write("file.jam", """
t.write("file.jam", """\
name = n1 n2 ;
contents = M1 M2 ;
actions run {
echo file: "@(o$(name) .txt:E= test -D$(contents))"
}
actions run { echo file: "@(o$(name) .txt:E= test -D$(contents))" }
run all ;
""")
t.run_build_system("-ffile.jam -d2")
t.run_build_system("-d2")
t.expect_output_line('echo file: "on1 on2 .txt"');
t.expect_addition("on1 on2 .txt")
t.expect_content("on1 on2 .txt", " test -DM1 -DM2", True)
t.rm(".")
t.write("file.jam", """
t.write("file.jam", """\
name = n1 n2 ;
contents = M1 M2 ;
file = "@($(STDOUT):E= test -D$(contents)\n)" ;
actions run {
$(file)
}
actions run { $(file) }
run all ;
""")
t.run_build_system("-ffile.jam -d1")
t.run_build_system("-d1")
t.expect_output_line(" test -DM1 -DM2")
t.rm(".")
t.write("file.jam", """
t.write("file.jam", """\
name = n1 n2 ;
contents = M1 M2 ;
actions run {
@($(STDOUT):E= test -D$(contents)\n)
}
actions run { @($(STDOUT):E= test -D$(contents)\n) }
run all ;
""")
t.run_build_system("-ffile.jam -d1")
t.run_build_system("-d1")
t.expect_output_line(" test -DM1 -DM2")
t.cleanup()

View File

@@ -12,21 +12,18 @@ t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("subdir1/file-to-bind", "# This file intentionally left blank")
t.write("file.jam", """
t.write("file.jam", """\
rule do-nothing ( target : source )
{
DEPENDS $(target) : $(source) ;
}
actions quietly do-nothing
{
}
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 ;
do-nothing fake-target : file-to-bind ;
# Set jam up to call our bind-rule
BINDRULE = bind-rule ;
@@ -39,7 +36,8 @@ rule bind-rule ( target : path )
DEPENDS all : fake-target ;
""")
t.run_build_system("-ffile.jam", stdout="""found: all at all
t.run_build_system("-ffile.jam", stdout="""\
found: all at all
found: file-to-bind at subdir1%sfile-to-bind
...found 3 targets...
""" % os.sep)

View File

@@ -8,7 +8,7 @@
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t = BoostBuild.Tester("-ffile.jam", pass_toolset=0)
t.write("file.jam", """
actions a { }
@@ -18,13 +18,13 @@ a all ;
b all ;
""")
t.run_build_system("-ffile.jam -d0", stdout="")
t.run_build_system("-d0", stdout="")
t.run_build_system("-ffile.jam -d1")
t.run_build_system("-d1")
t.expect_output_line("a all")
t.expect_output_line("b all", False)
t.run_build_system("-ffile.jam -d2")
t.run_build_system("-d2")
t.expect_output_line("a all")
t.expect_output_line("b all")

View File

@@ -8,7 +8,7 @@ import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.write("code", """
t.write("code", """\
module a
{
rule r1 ( )
@@ -70,7 +70,8 @@ actions do-nothing { }
do-nothing all ;
""")
t.run_build_system("-fcode", stdout="""R1
t.run_build_system("-fcode", stdout="""\
R1
R2
L1
A.L1

View File

@@ -7,8 +7,6 @@
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.set_tree("core-language")
t.run_build_system(extra_args="-ftest.jam")
t.run_build_system("-ftest.jam")
t.cleanup()

View File

@@ -2,45 +2,41 @@
# Copyright 2007 Rene Rivera.
# Copyright 2011 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("sleep.bat","""@setlocal
@echo off
timeout /T %1 /NOBREAK >nul
""")
t.write("file.jam", """
actions .a.
{
t.write("file.jam", """\
actions .a.
{
echo [$(<:B)] 0
echo [$(<:B)] 1
echo [$(<:B)] 2
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
.a. subtest_b : subtest ;
DEPENDS all : subtest_a subtest_b ;
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
.a. subtest_b : subtest ;
DEPENDS all : subtest_a subtest_b ;
""")
t.run_build_system("-ffile.jam -d2", stdout="""...found 4 targets...
t.run_build_system("-ffile.jam -d2", stdout="""\
...found 4 targets...
...updating 2 targets...
.a. subtest_a
echo [subtest_a] 0
echo [subtest_a] 1
echo [subtest_a] 2
[subtest_a] 0
[subtest_a] 1
[subtest_a] 2
@@ -49,7 +45,7 @@ echo [subtest_a] 2
echo [subtest_b] 0
echo [subtest_b] 1
echo [subtest_b] 2
[subtest_b] 0
[subtest_b] 1
[subtest_b] 2

View File

@@ -2,24 +2,21 @@
# Copyright 2007 Rene Rivera.
# Copyright 2011 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.write("sleep.bat","""@setlocal
@echo off
@REM timeout /T %1 /NOBREAK >nul
ping 127.0.0.1 -n 2 -w 1000 >nul
ping 127.0.0.1 -n %1 -w 1000 >nul
@endlocal
t.write("sleep.bat", """\
::@timeout /T %1 /NOBREAK >nul
@ping 127.0.0.1 -n 2 -w 1000 >nul
@ping 127.0.0.1 -n %1 -w 1000 >nul
@exit /B 0
""")
t.write("file.jam", """
t.write("file.jam", """\
if $(NT)
{
SLEEP = @call sleep.bat ;
@@ -41,7 +38,6 @@ DEPENDS all : sleeper ;
""")
t.run_build_system("-ffile.jam -d1 -l2", status=1)
t.expect_output_line("2 second time limit exceeded")
t.cleanup()

View File

@@ -2,50 +2,50 @@
# Copyright 2007 Rene Rivera.
# Copyright 2011 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("file.jam", """
actions .a.
{
t.write("file.jam", """\
actions .a.
{
echo [$(<:B)] 0
echo [$(<:B)] 1
echo [$(<:B)] 2
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
.a. subtest_b : subtest ;
FAIL_EXPECTED subtest_b ;
DEPENDS all : subtest_a subtest_b ;
}
rule .a.
{
DEPENDS $(<) : $(>) ;
}
NOTFILE subtest ;
.a. subtest_a : subtest ;
.a. subtest_b : subtest ;
FAIL_EXPECTED subtest_b ;
DEPENDS all : subtest_a subtest_b ;
""")
t.run_build_system("-ffile.jam -n", stdout="""...found 4 targets...
t.run_build_system("-ffile.jam -n", stdout="""\
...found 4 targets...
...updating 2 targets...
.a. subtest_a
echo [subtest_a] 0
echo [subtest_a] 1
echo [subtest_a] 2
.a. subtest_b
echo [subtest_b] 0
echo [subtest_b] 1
echo [subtest_b] 2
...updated 2 targets...
""")
t.expect_nothing_more()
t.cleanup()

View File

@@ -10,58 +10,56 @@ import BoostBuild
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("sleep.bat", """\
@setlocal
@REM timeout /T %1 /NOBREAK >nul
::@timeout /T %1 /NOBREAK >nul
@ping 127.0.0.1 -n 2 -w 1000 >nul
@ping 127.0.0.1 -n %1 -w 1000 >nul
@endlocal
@exit /B 0
""")
t.write("file.jam", """\
if $(NT)
if $(NT)
{
actions sleeper
{
actions sleeper
{
echo [$(<:S)] 0
@call sleep.bat 1
echo [$(<:S)] 1
@call sleep.bat 1
echo [$(<:S)] 2
@call sleep.bat $(<:B)
}
echo [$(<:S)] 0
call sleep.bat 1
echo [$(<:S)] 1
call sleep.bat 1
echo [$(<:S)] 2
call sleep.bat $(<:B)
}
else
}
else
{
actions sleeper
{
actions sleeper
{
echo "[$(<:S)] 0" 1>&2
sleep 1
echo "[$(<:S)] 1"
sleep 1
echo "[$(<:S)] 2" 1>&2
sleep $(<:B)
}
echo "[$(<:S)] 0"
sleep 1
echo "[$(<:S)] 1"
sleep 1
echo "[$(<:S)] 2"
sleep $(<:B)
}
}
rule sleeper
{
DEPENDS $(<) : $(>) ;
}
rule sleeper
{
DEPENDS $(<) : $(>) ;
}
NOTFILE front ;
sleeper 1.a : front ;
sleeper 2.a : front ;
sleeper 3.a : front ;
sleeper 4.a : front ;
NOTFILE choke ;
DEPENDS choke : 1.a 2.a 3.a 4.a ;
sleeper 1.b : choke ;
sleeper 2.b : choke ;
sleeper 3.b : choke ;
sleeper 4.b : choke ;
DEPENDS bottom : 1.b 2.b 3.b 4.b ;
DEPENDS all : bottom ;
NOTFILE front ;
sleeper 1.a : front ;
sleeper 2.a : front ;
sleeper 3.a : front ;
sleeper 4.a : front ;
NOTFILE choke ;
DEPENDS choke : 1.a 2.a 3.a 4.a ;
sleeper 1.b : choke ;
sleeper 2.b : choke ;
sleeper 3.b : choke ;
sleeper 4.b : choke ;
DEPENDS bottom : 1.b 2.b 3.b 4.b ;
DEPENDS all : bottom ;
""")
t.run_build_system("-ffile.jam -j4", stdout="""\

View File

@@ -10,46 +10,48 @@ import BoostBuild
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("sleep.bat", """\
@setlocal
@REM timeout /T %1 /NOBREAK >nul
::@timeout /T %1 /NOBREAK >nul
@ping 127.0.0.1 -n 2 -w 1000 >nul
@ping 127.0.0.1 -n %1 -w 1000 >nul
@endlocal
@exit /B 0
""")
t.write("file.jam", """\
if $(NT)
{
SLEEP = @call sleep.bat ;
}
else
{
SLEEP = sleep ;
}
actions .gen. {
echo 001
$(SLEEP) 4
echo 002
if $(NT)
{
SLEEP = @call sleep.bat ;
}
rule .use.1 { DEPENDS $(<) : $(>) ; }
actions .use.1 {
echo 003
}
rule .use.2 { DEPENDS $(<) : $(>) ; }
actions .use.2 {
$(SLEEP) 1
echo 004
else
{
SLEEP = sleep ;
}
.gen. g1.generated g2.generated ;
.use.1 u1.user : g1.generated ;
.use.2 u2.user : g2.generated ;
actions .gen.
{
echo 001
$(SLEEP) 4
echo 002
}
rule .use.1 { DEPENDS $(<) : $(>) ; }
actions .use.1
{
echo 003
}
NOTFILE root ;
DEPENDS g1.generated g2.generated : root ;
DEPENDS all : u1.user u2.user ;
rule .use.2 { DEPENDS $(<) : $(>) ; }
actions .use.2
{
$(SLEEP) 1
echo 004
}
.gen. g1.generated g2.generated ;
.use.1 u1.user : g1.generated ;
.use.2 u2.user : g2.generated ;
NOTFILE root ;
DEPENDS g1.generated g2.generated : root ;
DEPENDS all : u1.user u2.user ;
""")
t.run_build_system("-ffile.jam -j2", stdout="""\

View File

@@ -22,41 +22,39 @@ import BoostBuild
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("sleep.bat", """\
@setlocal
@REM timeout /T %1 /NOBREAK >nul
::@timeout /T %1 /NOBREAK >nul
@ping 127.0.0.1 -n 2 -w 1000 >nul
@ping 127.0.0.1 -n %1 -w 1000 >nul
@endlocal
@exit /B 0
""")
t.write("file.jam", """\
if $(NT)
{
SLEEP = @call sleep.bat ;
}
else
{
SLEEP = sleep ;
}
if $(NT)
{
SLEEP = @call sleep.bat ;
}
else
{
SLEEP = sleep ;
}
actions link
{
$(SLEEP) 1
echo 001 - linked
}
actions link
{
$(SLEEP) 1
echo 001 - linked
}
link dll lib ;
link dll lib ;
actions install
{
echo 002 - installed
}
actions install
{
echo 002 - installed
}
install installed_dll : dll ;
DEPENDS installed_dll : dll ;
install installed_dll : dll ;
DEPENDS installed_dll : dll ;
DEPENDS all : lib installed_dll ;
DEPENDS all : lib installed_dll ;
""")
t.run_build_system("-ffile.jam -j2", stdout="""\

View File

@@ -1,21 +1,21 @@
#!/usr/bin/python
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# This tests the typechecking facilities.
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t = BoostBuild.Tester("-ffile.jam", pass_toolset=0)
t.write("file.jam", """
module .typecheck
module .typecheck
{
rule [path] ( x )
{
if ! [ MATCH "^(::)" : $(x) ]
if ! [ MATCH "^(::)" : $(x) ]
{
ECHO "Error: $(x) is not a path" ;
return true ;
@@ -29,13 +29,13 @@ rule do ( [path] a )
do $(ARGUMENT) ;
actions dummy { }
actions dummy { }
dummy all ;
""")
t.run_build_system("-ffile.jam -sARGUMENT=::a/b/c")
t.run_build_system("-ffile.jam -sARGUMENT=a/b/c", status=1,
stdout="""Error: a/b/c is not a path
t.run_build_system("-sARGUMENT=::a/b/c")
t.run_build_system("-sARGUMENT=a/b/c", status=1, stdout="""\
Error: a/b/c is not a path
file.jam:18: in module scope
*** argument error
* rule do ( [path] a )

View File

@@ -1,19 +1,17 @@
#!/usr/bin/python
# Copyright 2011 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
import os
def basic():
# Basic test
def basic():
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("file.jam", """
t.write("file.jam", """\
actions do-print
{
echo updating $(<)
@@ -28,7 +26,8 @@ UPDATE_NOW target1 ;
DEPENDS all : target1 ;
""")
t.run_build_system("-ffile.jam", stdout="""...found 1 target...
t.run_build_system("-ffile.jam", stdout="""\
...found 1 target...
...updating 1 target...
do-print target1
updating target1
@@ -38,13 +37,11 @@ updating target1
t.cleanup()
def ignore_minus_n():
# ignore-minus-n
def ignore_minus_n():
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("file.jam", """
t.write("file.jam", """\
actions do-print
{
echo updating $(<)
@@ -59,7 +56,8 @@ UPDATE_NOW target1 : : ignore-minus-n ;
DEPENDS all : target1 ;
""")
t.run_build_system("-ffile.jam -n", stdout="""...found 1 target...
t.run_build_system("-ffile.jam -n", stdout="""\
...found 1 target...
...updating 1 target...
do-print target1
@@ -72,12 +70,11 @@ updating target1
t.cleanup()
def failed_target():
def failed_target():
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("file.jam", """
t.write("file.jam", """\
actions fail
{
exit 1
@@ -101,7 +98,8 @@ UPDATE_NOW target1 : : ignore-minus-n ;
DEPENDS all : target1 target2 ;
""")
t.run_build_system("-ffile.jam -n", stdout="""...found 1 target...
t.run_build_system("-ffile.jam -n", stdout="""\
...found 1 target...
...updating 1 target...
fail target1
@@ -120,11 +118,11 @@ do-print target2
t.cleanup()
def missing_target():
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("file.jam", """
t.write("file.jam", """\
actions do-print
{
echo updating $(<)
@@ -139,7 +137,8 @@ UPDATE_NOW target1 : : ignore-minus-n ;
DEPENDS all : target1 target2 ;
""")
t.run_build_system("-ffile.jam -n", status=1, stdout="""don't know how to make target1
t.run_build_system("-ffile.jam -n", status=1, stdout="""\
don't know how to make target1
...found 1 target...
...can't find 1 target...
...found 2 targets...
@@ -148,15 +147,17 @@ DEPENDS all : target1 target2 ;
t.cleanup()
# Make sure that if we call UPDATE_NOW with ignore-minus-n,
# the target gets updated exactly once regardless of previous
# calls to UPDATE_NOW with -n in effect.
def build_once():
"""
Make sure that if we call UPDATE_NOW with ignore-minus-n, the target gets
updated exactly once regardless of previous calls to UPDATE_NOW with -n in
effect.
"""
t = BoostBuild.Tester(pass_toolset=0, pass_d0=False)
t.write("file.jam", """
t.write("file.jam", """\
actions do-print
{
echo updating $(<)
@@ -173,7 +174,8 @@ UPDATE_NOW target1 : : ignore-minus-n ;
DEPENDS all : target1 ;
""")
t.run_build_system("-ffile.jam -n", stdout="""...found 1 target...
t.run_build_system("-ffile.jam -n", stdout="""\
...found 1 target...
...updating 1 target...
do-print target1
@@ -191,6 +193,7 @@ updating target1
t.cleanup()
basic()
ignore_minus_n()
failed_target()

View File

@@ -4,20 +4,20 @@
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Tests that variables in actions get expanded but double quote characters get
# treated as regular characters and not string literal delimiters when
# Tests that variables in actions get expanded but double quote characters
# get treated as regular characters and not string literal delimiters when
# determining string tokens concatenated to the variable being expanded.
#
# We also take care to make this test work correctly when run using both
# Windows and Unix echo command variant. That is why we add the extra single
# quotes around the text being echoed - they will make the double quotes be
# displayed as regular characters in both cases but will be displayed themselves
# only when using the Windows cmd shell's echo command.
# displayed as regular characters in both cases but will be displayed
# themselves only when using the Windows cmd shell's echo command.
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.write("file.jam", """
t.write("file.jam", """\
rule dummy ( i )
{
local a = 1 2 3 ;

View File

@@ -10,7 +10,7 @@ import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.write("file.jam", """
t.write("file.jam", """\
module foo
{
rule bar { }

View File

@@ -11,7 +11,7 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", "import gcc ;")
t.write("jamroot.jam", "")
t.write("jamfile.jam", "exe a : a.cpp : : debug release ;")
t.write("a.cpp", "int main() {}\n")
@@ -32,42 +32,32 @@ t.expect_addition("bin/$toolset/debug/optimization-space/a.exe")
t.expect_addition("bin/$toolset/release/optimization-space/a.exe")
# Test that default-build must be identical in all alternatives. Error case.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp : : debug ;
exe a : b.cpp : : ;
""")
expected="""error: default build must be identical in all alternatives
main target is ./a
with
differing from previous default build <variant>debug
"""
t.run_build_system("-n --no-error-backtrace", status=1)
t.fail_test(t.stdout().find("default build must be identical in all alternatives") == -1)
# Test that default-build must be identical in all alternatives. No Error case,
# empty default build.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp : <variant>debug ;
exe a : b.cpp : <variant>release ;
""")
t.run_build_system("-n --no-error-backtrace", status=0)
# Now try a harder example: default build which contains <define> should cause
# <define> to be present when "b" is compiled. This happens only if
# "build-project b" is placed first.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
project : default-build <define>FOO ;
build-project a ;
build-project b ;
""")
t.write("a/jamfile.jam", """
exe a : a.cpp ../b//b ;
""")
t.write("a/a.cpp", """
t.write("a/jamfile.jam", "exe a : a.cpp ../b//b ;")
t.write("a/a.cpp", """\
#ifdef _WIN32
__declspec(dllimport)
#endif
@@ -75,11 +65,8 @@ void foo();
int main() { foo(); }
""")
t.write("b/jamfile.jam", """
lib b : b.cpp ;
""")
t.write("b/b.cpp", """
t.write("b/jamfile.jam", "lib b : b.cpp ;")
t.write("b/b.cpp", """\
#ifdef FOO
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -6,8 +6,8 @@
# Regression test: virtual targets with different dependency properties were
# considered different by 'virtual-target.register', but the code which
# determined target paths ignored dependency properties --- so both targets used
# to be placed to the same location.
# determined the actual target paths ignored dependency properties so both
# targets ended up being in the same location.
import BoostBuild
import string
@@ -15,7 +15,7 @@ import string
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
lib foo : foo.cpp ;
exe hello : hello.cpp ;
exe hello2 : hello.cpp : <library>foo ;
@@ -23,7 +23,7 @@ exe hello2 : hello.cpp : <library>foo ;
t.write("hello.cpp", "int main() {}\n")
t.write("foo.cpp", """
t.write("foo.cpp", """\
#ifdef _WIN32
__declspec(dllexport)
#endif

View File

@@ -7,67 +7,62 @@ t = BoostBuild.Tester()
# First check some startup.
t.write("jamroot.jam", "")
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp b ;
lib b : b.cpp ;
""")
t.write("a.cpp", """
t.write("a.cpp", """\
void
# ifdef _WIN32
__declspec(dllimport)
# endif
# endif
foo();
int main()
{
foo();
}
int main() { foo(); }
""")
t.write("b.cpp", """
t.write("b.cpp", """\
#ifdef MACROS
void
# ifdef _WIN32
__declspec(dllexport)
# endif
# endif
foo() {}
#endif
# ifdef _WIN32
int __declspec(dllexport) force_implib_creation;
# endif
# endif
""")
t.run_build_system(extra_args="define=MACROS")
t.expect_addition("bin/$toolset/debug/"
t.run_build_system("define=MACROS")
t.expect_addition("bin/$toolset/debug/"
* (BoostBuild.List("a.obj b.obj b.dll a.exe")))
# When building a debug version, the 'define' still applies.
t.rm("bin")
t.run_build_system(extra_args="debug define=MACROS")
t.expect_addition("bin/$toolset/debug/"
t.run_build_system("debug define=MACROS")
t.expect_addition("bin/$toolset/debug/"
* (BoostBuild.List("a.obj b.obj b.dll a.exe")))
# When building release version, the 'define' still applies.
t.write("jamfile.jam", """
# When building a release version, the 'define' still applies.
t.write("jamfile.jam", """\
exe a : a.cpp b : <variant>debug ;
lib b : b.cpp ;
""")
t.rm("bin")
t.run_build_system(extra_args="release define=MACROS")
t.run_build_system("release define=MACROS")
# Regression test: direct build request was not working when there was more than
# one level of 'build-project'.
# Regression test: direct build request was not working when there was more
# than one level of 'build-project'.
t.rm(".")
t.write('jamroot.jam', '')
t.write('jamfile.jam', 'build-project a ;')
t.write('a/jamfile.jam', 'build-project b ;')
t.write('a/b/jamfile.jam', '')
t.write("jamroot.jam", "")
t.write("jamfile.jam", "build-project a ;")
t.write("a/jamfile.jam", "build-project b ;")
t.write("a/b/jamfile.jam", "")
t.run_build_system("release")
t.cleanup()

View File

@@ -13,32 +13,26 @@ import BoostBuild
t = BoostBuild.Tester()
# The point of this test is to have exe "main" which uses library "b", which
# uses library "a". When "main" is built with <hardcode-dll-paths>true, paths to
# both libraries should be present as values of <dll-path> feature. We create a
# special target type which reports <dll-path> values on its sources and compare
# the list of found values with out expectations.
# uses library "a". When "main" is built with <hardcode-dll-paths>true, paths
# to both libraries should be present as values of <dll-path> feature. We
# create a special target type which reports <dll-path> values on its sources
# and compare the list of found values with out expectations.
t.write("jamfile.jam", """
t.write("jamroot.jam", "using dll_paths ;")
t.write("jamfile.jam", """\
exe main : main.cpp b//b ;
explicit main ;
path-list mp : main ;
""")
t.write("main.cpp", """
int main() {}
""")
t.write("jamroot.jam", """
using dll_paths ;
""")
t.write("dll_paths.jam", """
import type ;
import generators ;
import feature ;
import sequence ;
import print ;
t.write("main.cpp", "int main() {}\n")
t.write("dll_paths.jam", """\
import "class" : new ;
import feature ;
import generators ;
import print ;
import sequence ;
import type ;
rule init ( )
{
@@ -81,7 +75,7 @@ rule list ( target : sources * : properties * )
}
""")
t.write("dll_paths.py", """
t.write("dll_paths.py", """\
import bjam
import b2.build.type as type
@@ -95,10 +89,10 @@ def init():
class DllPathsListGenerator(generators.Generator):
def __init__(self):
generators.Generator.__init__(self, "dll_paths.list", False, ["EXE"], ["PATH_LIST"])
generators.Generator.__init__(self, "dll_paths.list", False,
["EXE"], ["PATH_LIST"])
def generated_targets(self, sources, ps, project, name):
dll_paths = []
for s in sources:
a = s.action()
@@ -106,9 +100,9 @@ def init():
p = a.properties()
dll_paths += p.get('dll-path')
dll_paths.sort()
return generators.Generator.generated_targets(self,
sources, ps.add_raw(["<dll-path>" + p for p in dll_paths]),
project, name)
return generators.Generator.generated_targets(self, sources,
ps.add_raw(["<dll-path>" + p for p in dll_paths]), project,
name)
generators.register(DllPathsListGenerator())
@@ -117,11 +111,13 @@ echo $(PATHS) > $(<[1])
\"\"\"
def function(target, sources, ps):
bjam.call('set-target-variable', target, "PATHS", ps.get('dll-path'))
get_manager().engine().register_action("dll_paths.list", command, function=function)
get_manager().engine().register_action("dll_paths.list", command,
function=function)
""")
t.write("a/a.cpp", """
t.write("a/jamfile.jam", "lib a : a.cpp ;")
t.write("a/a.cpp", """\
void
#if defined(_WIN32)
__declspec(dllexport)
@@ -129,11 +125,8 @@ __declspec(dllexport)
foo() {}
""")
t.write("a/jamfile.jam", """
lib a : a.cpp ;
""")
t.write("b/b.cpp", """
t.write("b/jamfile.jam", "lib b : b.cpp ../a//a ;")
t.write("b/b.cpp", """\
void
#if defined(_WIN32)
__declspec(dllexport)
@@ -141,10 +134,6 @@ __declspec(dllexport)
bar() {}
""")
t.write("b/jamfile.jam", """
lib b : b.cpp ../a//a ;
""")
t.run_build_system("hardcode-dll-paths=true")
t.expect_addition("bin/$toolset/debug/mp.pathlist")

View File

@@ -8,15 +8,13 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
explicit hello2 ;
""")
t.write("hello.cpp", """
int main() {}
""")
t.write("hello.cpp", "int main() {}\n")
t.run_build_system()
t.ignore("*.tds")
@@ -32,7 +30,7 @@ t.rm(".")
# Test that 'explicit' used in a helper rule applies to the current project, and
# not to the Jamfile where the helper rule is defined.
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
rule myinstall ( name : target )
{
install $(name)-bin : $(target) ;
@@ -41,19 +39,15 @@ rule myinstall ( name : target )
}
""")
t.write("sub/a.cpp", """
""")
t.write("sub/jamfile.jam", """
myinstall dist : a.cpp ;
""")
t.write("sub/a.cpp", "\n")
t.write("sub/jamfile.jam", "myinstall dist : a.cpp ;")
t.run_build_system(subdir="sub")
t.expect_addition("sub/dist-bin/a.cpp")
t.rm("sub/dist-bin")
t.write("sub/jamfile.jam", """
t.write("sub/jamfile.jam", """\
myinstall dist : a.cpp ;
explicit dist ;
""")

View File

@@ -5,26 +5,26 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Tests that a free feature specified on the command line applies to all targets
# ever built.
# Tests that a free feature specified on the command line applies to all
# targets ever built.
import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello : hello.cpp foo ;
lib foo : foo.cpp ;
""")
t.write("hello.cpp", """
t.write("hello.cpp", """\
extern void foo();
#ifdef FOO
int main() { foo(); }
#endif
""")
t.write("foo.cpp", """
t.write("foo.cpp", """\
#ifdef FOO
#ifdef _WIN32
__declspec(dllexport)

View File

@@ -9,10 +9,9 @@ import string
t = BoostBuild.Tester(pass_toolset=0)
t.write("a.cpp", """
""")
t.write("a.cpp", "\n")
t.write("yfc1.jam", """
t.write("yfc1.jam", """\
import feature ;
import generators ;
@@ -26,7 +25,7 @@ actions compile { yfc1-compile }
actions link { yfc1-link }
""")
t.write("yfc2.jam", """
t.write("yfc2.jam", """\
import feature ;
import toolset ;
@@ -37,21 +36,14 @@ rule init ( ) { }
actions link { yfc2-link }
""")
t.write("jamfile.jam", """
exe a : a.cpp ;
""")
t.write("jamroot.jam", """
using yfc1 ;
""")
t.write("jamfile.jam", "exe a : a.cpp ;")
t.write("jamroot.jam", "using yfc1 ;")
t.run_build_system("-n -d2 yfc1")
t.fail_test(string.find(t.stdout(), "yfc1-link") == -1)
# Make sure we do not have to explicitly 'use' yfc1.
t.write("jamroot.jam", """
using yfc2 ;
""")
t.write("jamroot.jam", "using yfc2 ;")
t.run_build_system("-n -d2 yfc2")
t.fail_test(string.find(t.stdout(), "yfc2-link") == -1)

View File

@@ -8,19 +8,17 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
project : requirements <link>static ;
exe a : a.cpp [ lib helper : helper.cpp ] ;
""")
t.write("a.cpp", """
t.write("a.cpp", """\
extern void helper();
int main() {}
""")
t.write("helper.cpp", """
void helper() {}
""")
t.write("helper.cpp", "void helper() {}\n")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/link-static/a__helper.lib")
@@ -34,7 +32,7 @@ t.rm("bin")
# Now check that inline targets with the same name but present in different
# places are not confused between each other, and with top-level targets.
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
project : requirements <link>static ;
exe a : a.cpp [ lib helper : helper.cpp ] ;
exe a2 : a.cpp [ lib helper : helper.cpp ] ;
@@ -48,7 +46,7 @@ t.expect_addition("bin/$toolset/debug/link-static/a2__helper.lib")
# Check that the 'alias' target does not change the name of inline targets, and
# that inline targets are explicit.
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
project : requirements <link>static ;
alias a : [ lib helper : helper.cpp ] ;
explicit a ;

View File

@@ -8,27 +8,26 @@
# linking.
import BoostBuild
import string
import os
import string
t = BoostBuild.Tester()
t.write("jamfile.jam", """
# Stage the binary, so that it will be relinked without hardcode-dll-paths. That
# will chech that we pass correct -rpath-link, even if not passing -rpath.
# Stage the binary, so that it will be relinked without hardcode-dll-paths.
# That will check that we pass correct -rpath-link, even if not passing -rpath.
t.write("jamfile.jam", """\
stage dist : main ;
exe main : main.cpp b ;
""")
t.write("main.cpp", """
t.write("main.cpp", """\
void foo();
int main() { foo(); }
""")
t.write("jamroot.jam", """
""")
t.write("jamroot.jam", "")
t.write("a/a.cpp", """
t.write("a/a.cpp", """\
void
#if defined(_WIN32)
__declspec(dllexport)
@@ -41,11 +40,9 @@ __declspec(dllexport)
geek() {}
""")
t.write("a/jamfile.jam", """
lib a : a.cpp ;
""")
t.write("a/jamfile.jam", "lib a : a.cpp ;")
t.write("b/b.cpp", """
t.write("b/b.cpp", """\
void geek();
void
#if defined(_WIN32)
@@ -54,9 +51,7 @@ __declspec(dllexport)
foo() { geek(); }
""")
t.write("b/jamfile.jam", """
lib b : b.cpp ../a//a ;
""")
t.write("b/jamfile.jam", "lib b : b.cpp ../a//a ;")
t.run_build_system("-d2", stderr=None)
t.expect_addition("bin/$toolset/debug/main.exe")
@@ -68,18 +63,14 @@ t.rm(["bin", "a/bin", "b/bin"])
# Check that <library> works for static linking.
t.write("b/jamfile.jam", """
lib b : b.cpp : <library>../a//a ;
""")
t.write("b/jamfile.jam", "lib b : b.cpp : <library>../a//a ;")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/main.exe")
t.rm(["bin", "a/bin", "b/bin"])
t.write("b/jamfile.jam", """
lib b : b.cpp ../a//a/<link>shared : <link>static ;
""")
t.write("b/jamfile.jam", "lib b : b.cpp ../a//a/<link>shared : <link>static ;")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/main.exe")
@@ -88,7 +79,7 @@ t.rm(["bin", "a/bin", "b/bin"])
# Test that putting a library in sources of a searched library works.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe main : main.cpp png ;
lib png : z : <name>png ;
lib z : : <name>zzz ;
@@ -110,13 +101,12 @@ else:
t.rm(".")
t.write("jamroot.jam", "")
t.write("a/jamfile.jam", """
t.write("a/jamfile.jam", """\
lib a : a.cpp ;
install dist : a ;
""")
t.write("a/a.cpp", """
t.write("a/a.cpp", """\
#if defined(_WIN32)
__declspec(dllexport)
#endif
@@ -126,18 +116,16 @@ void a() {}
t.run_build_system(subdir="a")
t.expect_addition("a/dist/a.dll")
if ( ( os.name == 'nt' ) or os.uname()[0].lower().startswith('cygwin') ) and \
( BoostBuild.get_toolset() != 'gcc' ):
# This is windows import library -- we know the exact name.
if ( os.name == 'nt' or os.uname()[0].lower().startswith('cygwin') ) and \
BoostBuild.get_toolset() != 'gcc':
# This is a Windows import library -- we know the exact name.
file = "a/dist/a.lib"
else:
file = t.adjust_names(["a/dist/a.dll"])[0]
file = t.adjust_names("a/dist/a.dll")[0]
t.write("b/jamfile.jam", """
lib b : b.cpp ../%s ;
""" % file)
t.write("b/jamfile.jam", "lib b : b.cpp ../%s ;" % file)
t.write("b/b.cpp", """
t.write("b/b.cpp", """\
#if defined(_WIN32)
__declspec(dllimport)
#endif
@@ -148,11 +136,9 @@ __declspec(dllexport)
void b() { a(); }
""")
t.write("jamroot.jam", """
exe main : main.cpp b//b ;
""")
t.write("jamroot.jam", "exe main : main.cpp b//b ;")
t.write("main.cpp", """
t.write("main.cpp", """\
#if defined(_WIN32)
__declspec(dllimport)
#endif

View File

@@ -9,13 +9,12 @@ import string
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
lib main : main.cpp l ;
lib l : l.cpp main ;
""")
t.write("main.cpp", "")
t.write("l.cpp", "")
t.run_build_system("--no-error-backtrace", status=1)

View File

@@ -12,7 +12,7 @@ import string
t = BoostBuild.Tester(pass_toolset=1)
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import feature ;
feature.feature test_feature : : free ;
@@ -35,21 +35,17 @@ t.fail_test(string.find(t.read("bin/$toolset/debug/foo.bar"), "12345678") == -1)
# Regression test. Make sure that if a main target is requested two times, and
# build requests differ only in incidental properties, the main target is
# created only once. The bug was discovered by Kirill Lapshin.
t.write("jamroot.jam", """
# Make sure that incidental property does not cause second creation of
# 'hello1.cpp'.
t.write("jamroot.jam", """\
exe a : dir//hello1.cpp ;
exe b : dir//hello1.cpp/<hardcode-dll-paths>true ;
""")
t.write("dir/jamfile.jam", """
t.write("dir/jamfile.jam", """\
import common ;
make hello1.cpp : hello.cpp : common.copy ;
""")
t.write("dir/hello.cpp", """
int main() {}
""")
t.write("dir/hello.cpp", "int main() {}\n")
# Show only action names.
t.run_build_system("-d1 -n")

View File

@@ -12,28 +12,22 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
exe hello : hello.cpp lib//lib1 ;
""")
t.write("hello.cpp", """
t.write("jamroot.jam", "exe hello : hello.cpp lib//lib1 ;")
t.write("hello.cpp", """\
#ifdef NDEBUG
void foo();
int main() { foo(); }
#endif
""")
t.write("lib/jamfile.jam", """
lib lib1 : lib1.cpp ;
""")
t.write("lib/lib1.cpp", """
t.write("lib/jamfile.jam", "lib lib1 : lib1.cpp ;")
t.write("lib/lib1.cpp", """\
#ifdef NDEBUG
void foo() {}
#endif
""")
# 'release' builds should get the NDEBUG define. We use static linking to avoid
# messing with imports/exports on windows.
# messing with imports/exports on Windows.
t.run_build_system("link=static release")
t.cleanup()

View File

@@ -1,8 +1,8 @@
#!/usr/bin/python
# Copyright 2002 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2002 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Test that we cannot specify targets of unknown type as sources. This is based
# on the fact that Unix 'ar' will happily consume just about anything.
@@ -11,11 +11,7 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
import gcc ;
static-lib a : a.foo ;
""")
t.write("jamroot.jam", "static-lib a : a.foo ;")
t.write("a.foo", "")
t.run_build_system(status=1)

View File

@@ -13,7 +13,7 @@ import os
t = BoostBuild.Tester()
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import notfile ;
notfile say : "echo hi" ;
@@ -22,23 +22,21 @@ notfile hello_valgrind : @valgrind : hello ;
actions valgrind
{
valgrind $(>[1])
valgrind $(>[1])
}
""")
t.write("hello.cpp", """
t.write("hello.cpp", """\
#include <iostream>
int main() { std::cout << "Hello!\\n"; }
""")
t.run_build_system("-n -d+2")
t.fail_test(string.find(t.stdout(), "echo hi") == -1)
name = t.adjust_names(["bin/$toolset/debug/hello.exe"])[0]
name = t.adjust_names("bin/$toolset/debug/hello.exe")[0]
name = apply(os.path.join, string.split(name, "/"));
c = "valgrind *" + name
t.expect_output_line(c)
t.expect_output_line("valgrind *%s" % name)
t.cleanup()

View File

@@ -1,6 +1,6 @@
#!/usr/bin/python
# Copyright (C) FILL SOMETHING HERE 2005.
# Copyright (C) Vladimir Prus 2005.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
@@ -14,25 +14,15 @@ import BoostBuild
t = BoostBuild.Tester()
# Create the needed files.
t.write("p1/jamroot.jam", """
exe hello : hello.cpp ;
""")
t.write("p1/hello.cpp", """
int main() {}
""")
t.write("p2/jamroot.jam", """
t.write("p1/jamroot.jam", "exe hello : hello.cpp ;")
t.write("p1/hello.cpp", "int main() {}\n")
t.write("p2/jamroot.jam", """\
exe hello2 : hello.cpp ;
exe hello3 : hello.cpp ;
""")
t.write("p2/hello.cpp", """
int main() {}
""")
t.write("p2/hello.cpp", "int main() {}\n")
t.run_build_system("p1 p2//hello3")
t.expect_addition("p1/bin/$toolset/debug/hello.exe")
t.expect_addition("p2/bin/$toolset/debug/hello3.exe")

View File

@@ -1,14 +1,14 @@
#!/usr/bin/python
# Copyright 2002, 2003, 2004 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2002, 2003, 2004 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Test that we can use already built sources
import BoostBuild
t = BoostBuild.Tester()
t = BoostBuild.Tester("debug release")
t.set_tree('prebuilt')
@@ -16,17 +16,17 @@ t.expand_toolset("ext/jamroot.jam")
t.expand_toolset("jamroot.jam")
# First, build the external project.
t.run_build_system("debug release", subdir="ext")
t.run_build_system(subdir="ext")
# Then pretend that we do not have the sources for the external project, and can
# only use compiled binaries.
# Then pretend that we do not have the sources for the external project, and
# can only use compiled binaries.
t.copy("ext/jamfile2.jam", "ext/jamfile.jam")
t.expand_toolset("ext/jamfile.jam")
# Now check that we can build the main project, and that correct prebuilt file
# is picked, depending of variant. This also checks that correct includes for
# prebuilt libraries are used.
t.run_build_system("debug release")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/hello.exe")
t.expect_addition("bin/$toolset/release/hello.exe")
@@ -36,7 +36,7 @@ t.rm("bin")
# Now test that prebuilt file specified by absolute name works too.
t.copy("ext/jamfile3.jam", "ext/jamfile.jam")
t.expand_toolset("ext/jamfile.jam")
t.run_build_system("debug release")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/hello.exe")
t.expect_addition("bin/$toolset/release/hello.exe")

View File

@@ -13,8 +13,8 @@ t = BoostBuild.Tester(translate_suffixes=0)
# First check some startup.
t.set_tree("project-test3")
os.remove("jamroot.jam")
t.run_build_system(status=1, stdout=
"""error: Could not find parent for project at '.'
t.run_build_system(status=1, stdout="""\
error: Could not find parent for project at '.'
error: Did not find Jamfile.jam or Jamroot.jam in any parent directory.
""")
@@ -22,8 +22,8 @@ t.set_tree("project-test3")
t.run_build_system()
t.expect_addition("bin/$toolset/debug/a.obj")
t.expect_content("bin/$toolset/debug/a.obj",
"""$toolset/debug
t.expect_content("bin/$toolset/debug/a.obj", """\
$toolset/debug
a.cpp
""")
@@ -37,44 +37,44 @@ t.expect_content("bin/$toolset/debug/a.exe",
)
t.expect_addition("lib/bin/$toolset/debug/b.obj")
t.expect_content("lib/bin/$toolset/debug/b.obj",
"""$toolset/debug
t.expect_content("lib/bin/$toolset/debug/b.obj", """\
$toolset/debug
lib/b.cpp
""")
t.expect_addition("lib/bin/$toolset/debug/m.exe")
t.expect_content("lib/bin/$toolset/debug/m.exe",
"""$toolset/debug
t.expect_content("lib/bin/$toolset/debug/m.exe", """\
$toolset/debug
lib/bin/$toolset/debug/b.obj lib2/bin/$toolset/debug/c.obj
""")
t.expect_addition("lib2/bin/$toolset/debug/c.obj")
t.expect_content("lib2/bin/$toolset/debug/c.obj",
"""$toolset/debug
t.expect_content("lib2/bin/$toolset/debug/c.obj", """\
$toolset/debug
lib2/c.cpp
""")
t.expect_addition("lib2/bin/$toolset/debug/d.obj")
t.expect_content("lib2/bin/$toolset/debug/d.obj",
"""$toolset/debug
t.expect_content("lib2/bin/$toolset/debug/d.obj", """\
$toolset/debug
lib2/d.cpp
""")
t.expect_addition("lib2/bin/$toolset/debug/l.exe")
t.expect_content("lib2/bin/$toolset/debug/l.exe",
"""$toolset/debug
t.expect_content("lib2/bin/$toolset/debug/l.exe", """\
$toolset/debug
lib2/bin/$toolset/debug/c.obj bin/$toolset/debug/a.obj
""")
t.expect_addition("lib2/helper/bin/$toolset/debug/e.obj")
t.expect_content("lib2/helper/bin/$toolset/debug/e.obj",
"""$toolset/debug
t.expect_content("lib2/helper/bin/$toolset/debug/e.obj", """\
$toolset/debug
lib2/helper/e.cpp
""")
t.expect_addition("lib3/bin/$toolset/debug/f.obj")
t.expect_content("lib3/bin/$toolset/debug/f.obj",
"""$toolset/debug
t.expect_content("lib3/bin/$toolset/debug/f.obj", """\
$toolset/debug
lib3/f.cpp lib2/helper/bin/$toolset/debug/e.obj
""")
@@ -84,13 +84,13 @@ t.expect_touch(["bin/$toolset/debug/a.obj",
"bin/$toolset/debug/a.exe",
"lib2/bin/$toolset/debug/l.exe"])
t.run_build_system(extra_args="release optimization=off,speed")
t.run_build_system("release optimization=off,speed")
t.expect_addition(["bin/$toolset/release/a.exe",
"bin/$toolset/release/a.obj",
"bin/$toolset/release/optimization-off/a.exe",
"bin/$toolset/release/optimization-off/a.obj"])
t.run_build_system(extra_args='--clean-all')
t.run_build_system("--clean-all")
t.expect_removal(["bin/$toolset/debug/a.obj",
"bin/$toolset/debug/a.exe",
"lib/bin/$toolset/debug/b.obj",

View File

@@ -1,8 +1,8 @@
#!/usr/bin/python
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Test that free property inside.
@@ -10,15 +10,14 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", """
project ;
t.write("jamroot.jam", """\
variant debug-AA : debug : <define>AA ;
alias all : hello ;
exe hello : hello.cpp ;
explicit hello ;
""")
t.write("hello.cpp", """
t.write("hello.cpp", """\
#ifdef AA
int main() {}
#endif

View File

@@ -6,9 +6,9 @@
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t = BoostBuild.Tester("-ffile.jam", pass_toolset=0)
t.write('file.jam', '''
t.write("file.jam", """\
rule make
{
DEPENDS $(<) : $(>) ;
@@ -25,27 +25,27 @@ make foo : bar ;
REBUILDS foo : bar ;
make bar : baz ;
make aux2 : bar ;
''')
""")
t.write('baz', 'nothing\n')
t.write("baz", "nothing")
t.run_build_system('-ffile.jam bar')
t.expect_addition('bar')
t.run_build_system("bar")
t.expect_addition("bar")
t.expect_nothing_more()
t.wait_for_time_change_since_last_build()
t.run_build_system('-ffile.jam foo')
t.expect_touch('bar')
t.expect_addition('foo')
t.run_build_system("foo")
t.expect_touch("bar")
t.expect_addition("foo")
t.expect_nothing_more()
t.run_build_system('-ffile.jam')
t.expect_addition(['aux1', 'aux2'])
t.run_build_system()
t.expect_addition(["aux1", "aux2"])
t.expect_nothing_more()
t.touch('bar')
t.run_build_system('-ffile.jam')
t.expect_touch(['foo', 'aux1', 'aux2'])
t.touch("bar")
t.run_build_system()
t.expect_touch(["foo", "aux1", "aux2"])
t.expect_nothing_more()
t.cleanup()

View File

@@ -13,8 +13,7 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("c.cpp", "\n")
t.write("r.cpp", """
t.write("r.cpp", """\
void helper();
#include <iostream>
@@ -25,17 +24,11 @@ int main( int ac, char * av[] )
std::cout << av[ i ] << '\\n';
}
""")
t.write("c-f.cpp", "int\n")
t.write("r-f.cpp", "int main() { return 1; }\n")
t.write("c-f.cpp", """
int
""")
t.write("r-f.cpp", """
int main() { return 1; }
""")
t.write("jamfile.jam", """
t.write("jamroot.jam", "")
t.write("jamfile.jam", """\
import testing ;
compile c.cpp ;
compile-fail c-f.cpp ;
@@ -43,11 +36,8 @@ run r.cpp libs//helper : foo bar ;
run-fail r-f.cpp ;
""")
t.write("libs/jamfile.jam", """
lib helper : helper.cpp ;
""")
t.write("libs/helper.cpp", """
t.write("libs/jamfile.jam", "lib helper : helper.cpp ;")
t.write("libs/helper.cpp", """\
void
#if defined(_WIN32)
__declspec(dllexport)
@@ -55,8 +45,6 @@ __declspec(dllexport)
helper() {}
""")
t.write("jamroot.jam", "")
# First test that when outcomes are expected, all .test files are created.
t.run_build_system("hardcode-dll-paths=false", stderr=None, status=None)
t.expect_addition("bin/c.test/$toolset/debug/c.test")
@@ -69,7 +57,7 @@ t.expect_content("bin/r.test/$toolset/debug/r.output",
"foo\nbar\n*\nEXIT STATUS: 0*\n", True)
# Test that input file is handled as well.
t.write("r.cpp", """
t.write("r.cpp", """\
#include <iostream>
#include <fstream>
int main( int ac, char * av[] )
@@ -84,7 +72,7 @@ int main( int ac, char * av[] )
t.write("dir/input.txt", "test input")
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
import testing ;
compile c.cpp ;
obj c-obj : c.cpp ;
@@ -95,18 +83,19 @@ time execution : r ;
time compilation : c-obj ;
""")
t.run_build_system('hardcode-dll-paths=false')
t.expect_content("bin/r.test/$toolset/debug/r.output",
"test input\nEXIT STATUS: 0\n")
t.run_build_system("hardcode-dll-paths=false")
t.expect_content("bin/r.test/$toolset/debug/r.output", """\
test input
EXIT STATUS: 0
""")
t.expect_addition('bin/$toolset/debug/execution.time')
t.expect_addition('bin/$toolset/debug/compilation.time')
# Make sure test failures are detected. Reverse expectation and see if .test
# files are created or not.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
import testing ;
compile-fail c.cpp ;
compile c-f.cpp ;
run-fail r.cpp : : dir/input.txt ;

View File

@@ -1,28 +1,24 @@
#!/usr/bin/python
# Copyright 2012 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
import os
t = BoostBuild.Tester()
# Test a header loop that depends on (but does not contain)
# a generated header.
t.write("test.cpp", """
#include "header1.h"
""")
# Test a header loop that depends on (but does not contain) a generated header.
t.write("test.cpp", '#include "header1.h"\n')
t.write("header1.h", """
t.write("header1.h", """\
#ifndef HEADER1_H
#define HEADER1_H
#include "header2.h"
#endif
""")
t.write("header2.h", """
t.write("header2.h", """\
#ifndef HEADER2_H
#define HEADER2_H
#include "header1.h"
@@ -30,16 +26,12 @@ t.write("header2.h", """
#endif
""")
t.write("header3.in", """
/* empty file */
""")
t.write("header3.in", "/* empty file */\n")
t.write("Jamroot.jam", """
t.write("jamroot.jam", """\
import common ;
make header3.h : header3.in : @common.copy ;
obj test : test.cpp : <implicit-dependency>header3.h ;
""")
t.run_build_system("-j2")
@@ -50,39 +42,33 @@ t.expect_nothing_more()
t.rm(".")
# Test a linear sequence of generated headers.
t.write("test.cpp", """
#include "header1.h"
""")
t.write("test.cpp", '#include "header1.h"\n')
t.write("header1.in", """
t.write("header1.in", """\
#ifndef HEADER1_H
#define HEADER1_H
#include "header2.h"
#endif
""")
t.write("header2.in", """
t.write("header2.in", """\
#ifndef HEADER2_H
#define HEADER2_H
#include "header3.h"
#endif
""")
t.write("header3.in", """
/* empty file */
""")
t.write("header3.in", "/* empty file */\n")
t.write("Jamroot.jam", """
t.write("jamroot.jam", """\
import common ;
make header1.h : header1.in : @common.copy ;
make header2.h : header2.in : @common.copy ;
make header3.h : header3.in : @common.copy ;
obj test : test.cpp :
<implicit-dependency>header1.h
<implicit-dependency>header2.h
<implicit-dependency>header3.h
;
<implicit-dependency>header1.h
<implicit-dependency>header2.h
<implicit-dependency>header3.h ;
""")
t.run_build_system("-j2 test")
@@ -95,32 +81,30 @@ t.expect_nothing_more()
t.rm(".")
# Test a loop in generated headers.
t.write("test.cpp", """
#include "header1.h"
""")
t.write("test.cpp", '#include "header1.h"\n')
t.write("header1.in", """
t.write("header1.in", """\
#ifndef HEADER1_H
#define HEADER1_H
#include "header2.h"
#endif
""")
t.write("header2.in", """
t.write("header2.in", """\
#ifndef HEADER2_H
#define HEADER2_H
#include "header3.h"
#endif
""")
t.write("header3.in", """
t.write("header3.in", """\
#ifndef HEADER2_H
#define HEADER2_H
#include "header1.h"
#endif
""")
t.write("Jamroot.jam", """
t.write("jamroot.jam", """\
import common ;
actions copy {
@@ -132,10 +116,9 @@ make header1.h : header1.in : @common.copy ;
make header2.h : header2.in : @common.copy ;
make header3.h : header3.in : @common.copy ;
obj test : test.cpp :
<implicit-dependency>header1.h
<implicit-dependency>header2.h
<implicit-dependency>header3.h
;
<implicit-dependency>header1.h
<implicit-dependency>header2.h
<implicit-dependency>header3.h ;
""")
t.run_build_system("-j2 test")
@@ -147,26 +130,23 @@ t.expect_nothing_more()
t.rm(".")
# Test that all the dependencies of a loop are
# updated before any of the dependents.
t.write("test1.cpp", """
#include "header1.h"
""")
# Test that all the dependencies of a loop are updated before any of the
# dependents.
t.write("test1.cpp", '#include "header1.h"\n')
t.write("test2.cpp", """
t.write("test2.cpp", """\
#include "header2.h"
int main() {}
""")
t.write("header1.h", """
t.write("header1.h", """\
#ifndef HEADER1_H
#define HEADER1_H
#include "header2.h"
#endif
""")
t.write("header2.h", """
t.write("header2.h", """\
#ifndef HEADER2_H
#define HEADER2_H
#include "header1.h"
@@ -174,19 +154,16 @@ t.write("header2.h", """
#endif
""")
t.write("header3.in", """
""")
t.write("header3.in", "\n")
t.write("sleep.bat","""@setlocal
@echo off
@REM timeout /T %1 /NOBREAK >nul
ping 127.0.0.1 -n 2 -w 1000 >nul
ping 127.0.0.1 -n %1 -w 1000 >nul
@endlocal
t.write("sleep.bat", """\
::@timeout /T %1 /NOBREAK >nul
@ping 127.0.0.1 -n 2 -w 1000 >nul
@ping 127.0.0.1 -n %1 -w 1000 >nul
@exit /B 0
""")
t.write("Jamroot.jam", """
t.write("jamroot.jam", """\
import common ;
import os ;
@@ -199,18 +176,11 @@ else
SLEEP = sleep ;
}
rule copy {
common.copy $(<) : $(>) ;
}
actions copy {
$(SLEEP) 1
}
rule copy { common.copy $(<) : $(>) ; }
actions copy { $(SLEEP) 1 }
make header3.h : header3.in : @copy ;
exe test : test2.cpp test1.cpp :
<implicit-dependency>header3.h
;
exe test : test2.cpp test1.cpp : <implicit-dependency>header3.h ;
""")
t.run_build_system("-j2 test")
@@ -231,47 +201,41 @@ t.expect_nothing_more()
t.rm(".")
# Test a loop that includes a generated header
t.write("test1.cpp", """
#include "header1.h"
""")
t.write("test2.cpp", """
t.write("test1.cpp", '#include "header1.h"\n')
t.write("test2.cpp", """\
#include "header2.h"
int main() {}
""")
t.write("header1.h", """
t.write("header1.h", """\
#ifndef HEADER1_H
#define HEADER1_H
#include "header2.h"
#endif
""")
t.write("header2.in", """
t.write("header2.in", """\
#ifndef HEADER2_H
#define HEADER2_H
#include "header3.h"
#endif
""")
t.write("header3.h", """
t.write("header3.h", """\
#ifndef HEADER3_H
#define HEADER3_H
#include "header1.h"
#endif
""")
t.write("sleep.bat","""@setlocal
@echo off
@REM timeout /T %1 /NOBREAK >nul
ping 127.0.0.1 -n 2 -w 1000 >nul
ping 127.0.0.1 -n %1 -w 1000 >nul
@endlocal
t.write("sleep.bat", """\
::@timeout /T %1 /NOBREAK >nul
@ping 127.0.0.1 -n 2 -w 1000 >nul
@ping 127.0.0.1 -n %1 -w 1000 >nul
@exit /B 0
""")
t.write("Jamroot.jam", """
t.write("jamroot.jam", """\
import common ;
import os ;
@@ -284,19 +248,11 @@ else
SLEEP = sleep ;
}
rule copy {
common.copy $(<) : $(>) ;
}
actions copy {
$(SLEEP) 1
}
rule copy { common.copy $(<) : $(>) ; }
actions copy { $(SLEEP) 1 }
make header2.h : header2.in : @copy ;
exe test : test2.cpp test1.cpp :
<implicit-dependency>header2.h
<include>.
;
exe test : test2.cpp test1.cpp : <implicit-dependency>header2.h <include>. ;
""")
t.run_build_system("-j2 test")
@@ -306,5 +262,4 @@ t.expect_addition("bin/$toolset/debug/test2.obj")
t.expect_addition("bin/$toolset/debug/test.exe")
t.expect_nothing_more()
t.cleanup()

View File

@@ -13,16 +13,14 @@ import BoostBuild
t = BoostBuild.Tester()
# Create the needed files
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
exe hello : hello.cpp ;
# This should use the 'hello' target, even if there is a 'hello' file in the
# current dir.
install s : hello : <location>. ;
""")
t.write("hello.cpp", """
int main() {}
""")
t.write("hello.cpp", "int main() {}\n")
t.run_build_system()
@@ -30,8 +28,8 @@ t.expect_addition("bin/$toolset/debug/hello.obj")
t.touch("hello.cpp")
t.run_build_system("s")
# If 'hello' in the 's' target resolved to file in the current dir, nothing will
# be rebuilt.
# If 'hello' in the 's' target resolved to file in the current dir, nothing
# will be rebuilt.
t.expect_touch("bin/$toolset/debug/hello.obj")
t.cleanup()

View File

@@ -18,7 +18,7 @@ t = BoostBuild.Tester()
# To start with, we have to prepare a library to link with.
t.write("lib/jamroot.jam", "")
t.write("lib/jamfile.jam", "lib test_lib : test_lib.cpp ;")
t.write("lib/test_lib.cpp", """
t.write("lib/test_lib.cpp", """\
#ifdef _WIN32
__declspec(dllexport)
#endif
@@ -42,21 +42,20 @@ else:
# Test that the simplest usage of searched library works.
t.write("jamroot.jam", "")
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
import path ;
import project ;
exe main : main.cpp helper ;
lib helper : helper.cpp test_lib ;
lib test_lib : : <name>test_lib <search>lib ;
""")
t.write("main.cpp", """
t.write("main.cpp", """\
void helper();
int main() { helper(); }
""")
t.write("helper.cpp", """
t.write("helper.cpp", """\
void foo();
void
#if defined(_WIN32)
@@ -71,8 +70,7 @@ t.rm("bin/$toolset/debug/main.exe")
# Test that 'unit-test' will correctly add runtime paths to searched libraries.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
import path ;
import project ;
import testing ;
@@ -91,7 +89,7 @@ t.rm("bin/$toolset/debug/main.exe")
# Now try using searched lib from static lib. Request shared version of searched
# lib, since we do not have a static one handy.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe main : main.cpp helper ;
lib helper : helper.cpp test_lib/<link>shared : <link>static ;
lib test_lib : : <name>test_lib <search>lib ;
@@ -109,17 +107,17 @@ t.rm("bin/$toolset/debug/main.exe")
# works nicely in some cases, sending output from compiler to file 'z'. This
# problem shows up when searched libs are in usage requirements.
t.write("jamfile.jam", "exe main : main.cpp d/d2//a ;")
t.write("main.cpp", """
t.write("main.cpp", """\
void foo();
int main() { foo(); }
""")
t.write("d/d2/jamfile.jam", """
t.write("d/d2/jamfile.jam", """\
lib test_lib : : <name>test_lib <search>../../lib ;
lib a : a.cpp : : : <library>test_lib ;
""")
t.write("d/d2/a.cpp", """
t.write("d/d2/a.cpp", """\
#ifdef _WIN32
__declspec(dllexport) int force_library_creation_for_a;
#endif
@@ -138,7 +136,7 @@ t.write("a.cpp", "")
# The 'l' library will be built in two variants: 'debug' (directly requested)
# and 'release' (requested from 'a').
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp l/<variant>release ;
lib l : : <name>l_d <variant>debug ;
lib l : : <name>l_r <variant>release ;
@@ -152,10 +150,8 @@ t.run_build_system("-n")
# targets. The final error is correct, but we should not create two duplicated
# targets. Thanks to Andre Hentz for finding this bug.
t.write("jamroot.jam", "")
t.write("a.cpp", "")
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
project a : requirements <runtime-link>static ;
static-lib a : a.cpp l ;
lib l : : <name>l_f ;
@@ -165,7 +161,7 @@ t.run_build_system("-n")
# Make sure plain "lib foobar ; " works.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp foobar ;
lib foobar ;
""")
@@ -175,7 +171,7 @@ t.fail_test(string.find(t.stdout(), "foobar") == -1)
# Make sure plain "lib foo bar ; " works.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
exe a : a.cpp foo bar ;
lib foo bar ;
""")

View File

@@ -11,19 +11,10 @@ import BoostBuild
# Create a temporary working directory.
t = BoostBuild.Tester()
t.write("a.cpp", """
int main() {}
""")
t.write("b.cpp", """
int main() {}
""")
t.write("c.cpp", """
int main() {}
""")
t.write("jamroot.jam", """
t.write("a.cpp", "int main() {}\n")
t.write("b.cpp", "int main() {}\n")
t.write("c.cpp", "int main() {}\n")
t.write("jamroot.jam", """\
import feature ;
feature.feature foo : 1 2 : link-incompatible ;
exe a : a.cpp : <foo>1 ;

View File

@@ -1,6 +1,6 @@
#!/usr/bin/python
# Copyright (C) Jurko Gospodnetic 2008.
# Copyright (C) 2008. Jurko Gospodnetic
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
@@ -10,20 +10,19 @@
import BoostBuild
################################################################################
###############################################################################
#
# testSORTCorrectness()
# ---------------------
#
################################################################################
###############################################################################
def testSORTCorrectness():
"""Testing that Boost Jam's SORT builtin rule actually sorts correctly.
"""
t = BoostBuild.Tester("-f test.jam -d1", pass_toolset=False,
"""Testing that Boost Jam's SORT builtin rule actually sorts correctly."""
t = BoostBuild.Tester("-ftest.jam -d1", pass_toolset=False,
use_test_config=False)
t.write("test.jam", """
t.write("test.jam", """\
NOCARE all ;
source-data = 1 8 9 2 7 3 4 7 1 27 27 9 98 98 1 1 4 5 6 2 3 4 8 1 -2 -2 0 0 0 ;
target-data = -2 -2 0 0 0 1 1 1 1 1 2 2 27 27 3 3 4 4 4 5 6 7 7 8 8 9 9 98 98 ;
@@ -47,18 +46,20 @@ if $(sorted-data) != $(target-data)
t.cleanup()
################################################################################
###############################################################################
#
# testSORTDuration()
# ------------------
#
################################################################################
###############################################################################
def testSORTDuration():
"""Regression test making sure Boost Jam's SORT builtin rule does not get
quadratic behaviour again in this use case.
"""
t = BoostBuild.Tester("-f test.jam -d1", pass_toolset=False,
Regression test making sure Boost Jam's SORT builtin rule does not get
quadratic behaviour again in this use case.
"""
t = BoostBuild.Tester("-ftest.jam -d1", pass_toolset=False,
use_test_config=False)
f = open(t.workpath("test.jam"), "w")
@@ -84,12 +85,12 @@ NOCARE all ;
t.cleanup()
################################################################################
###############################################################################
#
# main()
# ------
#
################################################################################
###############################################################################
testSORTCorrectness()
testSORTDuration()

View File

@@ -16,14 +16,11 @@ class unsplit(object):
t = BoostBuild.Tester()
t.write("has space/Jamroot.jam", """
t.write("has space/jamroot.jam", """\
import testing ;
unit-test test : test.cpp ;
""")
t.write("has space/test.cpp", """
int main() {}
""")
t.write("has space/test.cpp", "int main() {}\n")
t.run_build_system(unsplit(["has space"]))

View File

@@ -11,7 +11,7 @@ import BoostBuild
t = BoostBuild.Tester()
t.write("jamroot.jam", "import gcc ;")
t.write("jamroot.jam", "")
t.write("jamfile.jam", """\
lib a : a.cpp ;
stage dist : a a.h auxilliary/1 ;

View File

@@ -37,7 +37,7 @@ Please remove this file or change the test's working folder and rerun the test.
def find_up_to_root(folder, name):
last = ''
last = ""
while last != folder:
candidate = os.path.join(folder, name)
if os.path.exists(candidate):
@@ -50,46 +50,45 @@ def match_re(actual, expected):
return re.match(expected, actual, re.DOTALL) != None
t = BoostBuild.Tester(match=match_re, boost_build_path='', pass_toolset=0)
t.set_tree('startup')
t = BoostBuild.Tester(match=match_re, boost_build_path="", pass_toolset=0)
t.set_tree("startup")
check_for_existing_boost_build_jam(t)
t.run_build_system(status=1, stdout=
r'''Unable to load Boost\.Build: could not find "boost-build\.jam"
.*Attempted search from .* up to the root''')
r"""Unable to load Boost\.Build: could not find "boost-build\.jam"
.*Attempted search from .* up to the root""")
t.run_build_system(status=1, subdir='no-bootstrap1',
stdout=r'''Unable to load Boost\.Build: could not find build system\.'''
r'''.*attempted to load the build system by invoking'''
r'''.*'boost-build ;'.*'''
r'''but we were unable to find "bootstrap\.jam"''')
t.run_build_system(status=1, subdir="no-bootstrap1",
stdout=r"Unable to load Boost\.Build: could not find build system\."
r".*attempted to load the build system by invoking"
r".*'boost-build ;'"
r'.*but we were unable to find "bootstrap\.jam"')
# Descend to a subdirectory which /does not/ contain a boost-build.jam file,
# and try again to test the crawl-up behavior.
t.run_build_system(status=1, subdir=os.path.join('no-bootstrap1', 'subdir'),
stdout=r'''Unable to load Boost\.Build: could not find build system\.'''
r'''.*attempted to load the build system by invoking'''
r'''.*'boost-build ;'.*'''
r'''but we were unable to find "bootstrap\.jam"''')
t.run_build_system(status=1, subdir=os.path.join("no-bootstrap1", "subdir"),
stdout=r"Unable to load Boost\.Build: could not find build system\."
r".*attempted to load the build system by invoking"
r".*'boost-build ;'"
r'.*but we were unable to find "bootstrap\.jam"')
t.run_build_system(status=1, subdir='no-bootstrap2',
stdout=r'''Unable to load Boost\.Build: could not find build system\.'''
r'''.*attempted to load the build system by invoking'''
r'''.*'boost-build \. ;'.*'''
r'''but we were unable to find "bootstrap\.jam"''')
t.run_build_system(status=1, subdir="no-bootstrap2",
stdout=r"Unable to load Boost\.Build: could not find build system\."
r".*attempted to load the build system by invoking"
r".*'boost-build \. ;'"
r'.*but we were unable to find "bootstrap\.jam"')
t.run_build_system(status=1, subdir='no-bootstrap3', stdout=
r'''Unable to load Boost.Build
r"""Unable to load Boost.Build
.*boost-build\.jam" was found.*
However, it failed to call the "boost-build" rule''')
However, it failed to call the "boost-build" rule""")
# Test bootstrapping based on BOOST_BUILD_PATH.
t.run_build_system(subdir='bootstrap-env',
extra_args='-sBOOST_BUILD_PATH=../boost-root/build',
stdout='build system bootstrapped')
t.run_build_system("-sBOOST_BUILD_PATH=../boost-root/build",
subdir="bootstrap-env", stdout="build system bootstrapped")
# Test bootstrapping based on an explicit path in boost-build.jam.
t.run_build_system(subdir='bootstrap-explicit',
stdout='build system bootstrapped')
t.run_build_system(subdir="bootstrap-explicit",
stdout="build system bootstrapped")
t.cleanup()

View File

@@ -6,8 +6,6 @@
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
import os.path
import shutil
t = BoostBuild.Tester()
t.write("jamroot.jam", "")
@@ -18,7 +16,7 @@ lib auxilliary2 : c.cpp ;
""")
def reset():
shutil.rmtree(os.path.join(t.workdir, "lib", "bin"))
t.rm("lib/bin")
t.run_build_system(subdir='lib')
t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("c.obj "
@@ -26,13 +24,13 @@ t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("c.obj "
t.expect_nothing_more()
reset()
t.run_build_system(subdir='lib', extra_args="link=shared")
t.run_build_system("link=shared", subdir="lib")
t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("c.obj "
"auxilliary1.lib auxilliary2.dll"))
t.expect_nothing_more()
reset()
t.run_build_system(subdir='lib', extra_args="link=static")
t.run_build_system("link=static", subdir="lib")
t.expect_addition("lib/bin/$toolset/debug/link-static/" * BoostBuild.List(
"c.obj auxilliary1.lib auxilliary2.lib"))
t.expect_nothing_more()

View File

@@ -16,11 +16,12 @@ import BoostBuild
################################################################################
def test_folder_with_dot_in_name(t):
""" Regression test: the 'tag' feature did not work in directories that had
a dot in their name.
"""
Regression test: the 'tag' feature did not work in directories that had a
dot in their name.
t.write("version-1.32.0/jamroot.jam", """
"""
t.write("version-1.32.0/jamroot.jam", """\
project test : requirements <tag>@$(__name__).tag ;
rule tag ( name : type ? : property-set )
@@ -45,10 +46,9 @@ exe a : a.cpp ;
################################################################################
def test_tag_property(t):
"""Basic tag property test.
"""
"""Basic tag property test."""
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import virtual-target ;
rule tag ( name : type ? : property-set )
@@ -77,26 +77,26 @@ lib b : a.cpp : <tag>@tag ;
stage c : a ;
""")
t.write("a.cpp", """
t.write("a.cpp", """\
int main() {}
#ifdef _MSC_VER
__declspec (dllexport) void x () {}
#endif
""")
file_list = \
BoostBuild.List("bin/$toolset/debug/a_ds.exe") + \
BoostBuild.List("bin/$toolset/debug/b_ds.dll") + \
BoostBuild.List("c/a_ds.exe") + \
BoostBuild.List("bin/$toolset/release/a_rs.exe") + \
BoostBuild.List("bin/$toolset/release/b_rs.dll") + \
BoostBuild.List("c/a_rs.exe") + \
BoostBuild.List("bin/$toolset/debug/link-static/a_dt.exe") + \
BoostBuild.List("bin/$toolset/debug/link-static/b_dt.lib") + \
BoostBuild.List("c/a_dt.exe") + \
BoostBuild.List("bin/$toolset/release/link-static/a_rt.exe") + \
BoostBuild.List("bin/$toolset/release/link-static/b_rt.lib") + \
BoostBuild.List("c/a_rt.exe")
file_list = (
BoostBuild.List("bin/$toolset/debug/a_ds.exe") +
BoostBuild.List("bin/$toolset/debug/b_ds.dll") +
BoostBuild.List("c/a_ds.exe") +
BoostBuild.List("bin/$toolset/release/a_rs.exe") +
BoostBuild.List("bin/$toolset/release/b_rs.dll") +
BoostBuild.List("c/a_rs.exe") +
BoostBuild.List("bin/$toolset/debug/link-static/a_dt.exe") +
BoostBuild.List("bin/$toolset/debug/link-static/b_dt.lib") +
BoostBuild.List("c/a_dt.exe") +
BoostBuild.List("bin/$toolset/release/link-static/a_rt.exe") +
BoostBuild.List("bin/$toolset/release/link-static/b_rt.lib") +
BoostBuild.List("c/a_rt.exe"))
variants = "debug release link=static,shared"

View File

@@ -80,10 +80,11 @@ obj xxx : xxx.rc ;
t.write("xxx.bin", "foo")
def test1(n, expect, noexec=False):
params = "-sXXX=%d" % n
params = ["-sXXX=%d" % n]
if noexec:
params += " -n -sNOEXEC=NOEXEC"
t.run_build_system(params)
params.append("-n")
params.append("-sNOEXEC=NOEXEC")
t.run_build_system(" ".join(params))
t.expect_output_line("*NOEXEC*", noexec)
obj_file = "xxx_res.obj"
t.expect_output_line("compile.resource.dummy *%s" % obj_file, expect)

View File

@@ -9,25 +9,24 @@
import BoostBuild
################################################################################
###############################################################################
#
# Test that dumping Boost Build based testing results works in case test code
# is not located in a folder under the Jamroot folder.
#
################################################################################
###############################################################################
t = BoostBuild.Tester("--dump-tests")
t.write("TestBuild/jamroot.jam", """
t.write("TestBuild/jamroot.jam", """\
import testing ;
test-suite testit : [ run ../TestSource/test.cpp ] ;
""")
t.write("TestSource/test.cpp", """
int main() {}
""")
t.write("TestSource/test.cpp", "int main() {}\n")
t.run_build_system("", subdir="TestBuild")
t.expect_output_line('boost-test(RUN) "*/TestBuild/test" : "../TestSource/test.cpp"')
t.run_build_system(subdir="TestBuild")
t.expect_output_line('boost-test(RUN) "*/TestBuild/test" : '
'"../TestSource/test.cpp"')
t.cleanup()

View File

@@ -11,7 +11,7 @@
# 1. 'time' target with a source target representing more than one virtual
# target. This happens in practice, e.g. when using the time rule on a msvc
# exe target whose generator actually constructs an EXE and a PDB target.
# When this is done - only te main virtual target's constructing action
# When this is done - only the main virtual target's constructing action
# should be timed.
# 2. 'time' target with a source target representing a virtual target that
# actually gets built by multiple actions run in sequence. In that case a
@@ -26,19 +26,19 @@ import BoostBuild
import re
################################################################################
###############################################################################
#
# basic_jam_action_test()
# -----------------------
#
################################################################################
###############################################################################
def basic_jam_action_test():
"""Tests basic Jam action timing support."""
t = BoostBuild.Tester(pass_toolset=0)
t.write("file.jam", """
t.write("file.jam", """\
rule time
{
DEPENDS $(<) : $(>) ;
@@ -72,9 +72,10 @@ time foo : bar ;
make bar : baz ;
""")
t.write("baz", "nothing\n")
t.write("baz", "nothing")
expected_output = """\.\.\.found 4 targets\.\.\.
expected_output = """\
\.\.\.found 4 targets\.\.\.
\.\.\.updating 2 targets\.\.\.
make bar
time foo
@@ -91,23 +92,24 @@ bar +user: [0-9\.]+ +system: +[0-9\.]+ *
t.cleanup()
################################################################################
###############################################################################
#
# boost_build_testing_support_timing_rule():
# ------------------------------------------
#
################################################################################
###############################################################################
def boost_build_testing_support_timing_rule():
"""Tests the target build timing rule provided by the Boost Build testing
support system.
"""
Tests the target build timing rule provided by the Boost Build testing
support system.
"""
t = BoostBuild.Tester()
t.write("aaa.cpp", "int main() {}\n")
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import testing ;
exe my-exe : aaa.cpp ;
time my-time : my-exe ;
@@ -126,23 +128,24 @@ time my-time : my-exe ;
t.cleanup()
################################################################################
###############################################################################
#
# boost_build_testing_support_timing_rule_with_spaces_in_names()
# --------------------------------------------------------------
#
################################################################################
###############################################################################
def boost_build_testing_support_timing_rule_with_spaces_in_names():
"""Tests the target build timing rule provided by the Boost Build testing
support system when used with targets contining spaces in their names.
"""
Tests the target build timing rule provided by the Boost Build testing
support system when used with targets contining spaces in their names.
"""
t = BoostBuild.Tester()
t.write("aaa bbb.cpp", "int main() {}\n")
t.write("jamroot.jam", """
t.write("jamroot.jam", """\
import testing ;
exe "my exe" : "aaa bbb.cpp" ;
time "my time" : "my exe" ;
@@ -159,12 +162,12 @@ time "my time" : "my exe" ;
t.cleanup()
################################################################################
###############################################################################
#
# main()
# ------
#
################################################################################
###############################################################################
basic_jam_action_test()
boost_build_testing_support_timing_rule()

View File

@@ -1,13 +1,11 @@
#!/usr/bin/python
# Copyright 2002, 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2002, 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import BoostBuild
t = BoostBuild.Tester(pass_toolset=0)
t.run_build_system(extra_args="--debug --build-system=test/test")
t.run_build_system("--debug --build-system=test/test")
t.cleanup()

View File

@@ -1,8 +1,8 @@
#!/usr/bin/python
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Test that unused sources are at least reported.
@@ -16,18 +16,14 @@ t.set_tree("unused")
t.run_build_system()
# The second invocation should do nothing, and produce no warning. The previous
# invocation might have printed executed actions and other things, so it is not
# easy to check if warning was issued or not.
# easy to check if a warning was issued or not.
t.run_build_system(stdout="")
t.run_build_system("-sGENERATE_ONLY_UNUSABLE=1", stdout="")
# Now check that even if main target generates nothing, its usage requirements
# are still propagated to dependants.
t.write("a.cpp", """
#ifdef FOO
int main() {}
#endif
""")
t.write("a.cpp", "int main() {}\n")
t.run_build_system("-sGENERATE_NOTHING=1")
t.cleanup()

View File

@@ -1,16 +1,14 @@
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Copyright 2003 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
import type ;
import generators ;
import print ;
import virtual-target ;
import "class" : new ;
import modules ;
import targets ;
import project ;
import targets ;
import type ;
import virtual-target ;
type.register X : x ;
@@ -21,28 +19,22 @@ class test-target-class : basic-target
{
basic-target.__init__ $(name) : $(project) ;
}
rule construct ( name : source-targets * : property-set )
{
if [ modules.peek : GENERATE_NOTHING ]
local result = [ property-set.empty ] ;
if ! [ modules.peek : GENERATE_NOTHING ]
{
return [ property-set.empty ] ;
result += [ virtual-target.from-file b.x : . : $(self.project) ] ;
if ! [ modules.peek : GENERATE_ONLY_UNUSABLE ]
{
result += [ virtual-target.from-file b.cpp : . : $(self.project)
] ;
}
}
else if [ modules.peek : GENERATE_ONLY_UNUSABLE ]
{
return [ property-set.empty ]
[ virtual-target.from-file b.x : . : $(self.project) ]
;
}
else
{
return [ property-set.empty ]
[ virtual-target.from-file b.x : . : $(self.project) ]
[ virtual-target.from-file b.cpp : . : $(self.project) ]
;
}
return $(result) ;
}
rule compute-usage-requirements ( rproperties : targets * )
{
return [ property-set.create <define>FOO ] ;
@@ -51,10 +43,8 @@ class test-target-class : basic-target
rule make-b-main-target
{
local project = [ project.current ] ;
targets.main-target-alternative
[ new test-target-class b : $(project) ] ;
local project = [ project.current ] ;
targets.main-target-alternative [ new test-target-class b : $(project) ] ;
}
IMPORT $(__name__) : make-b-main-target : : make-b-main-target ;

View File

@@ -10,36 +10,36 @@ import BoostBuild
t = BoostBuild.Tester()
# Test that use requirements on main target work (and a propagated all the way
# up, not only to direct dependants).
t.write("jamroot.jam", "import gcc ;")
# Test that usage requirements on main targets work (and are propagated all the
# way up, and not only to direct dependants).
t.write("jamroot.jam", "")
# Note: 'lib cc ..', not 'lib c'. If using 'lib c: ...' the HP-CXX linker will
# confuse it with the system C runtime.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
lib b : b.cpp : <link>shared:<define>SHARED_B : :
<define>FOO <link>shared:<define>SHARED_B ;
lib cc : c.cpp b ;
exe a : a.cpp cc ;
""")
t.write("b.cpp", """
t.write("b.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_B)
__declspec(dllexport)
#endif
foo() {}\n
foo() {}
""")
t.write("c.cpp", """
t.write("c.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_B)
__declspec(dllexport)
#endif
create_lib_please() {}\n
create_lib_please() {}
""")
t.write("a.cpp", """
t.write("a.cpp", """\
#ifdef FOO
void
# if defined(_WIN32) && defined(SHARED_B)
@@ -56,15 +56,14 @@ t.run_build_system("--clean")
# Test that use requirements on main target work, when they are referred using
# 'dependency' features.
t.write("jamroot.jam", "import gcc ;")
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
lib b : b.cpp : <link>shared:<define>SHARED_B : : <define>FOO
<link>shared:<define>SHARED_B ;
exe a : a.cpp : <use>b ;
""")
t.write("b.cpp", """
t.write("b.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_B)
__declspec(dllexport)
@@ -72,33 +71,32 @@ __declspec(dllexport)
foo() {}
""")
t.write("a.cpp", """
t.write("a.cpp", """\
#ifdef FOO
int main() {}
#endif
""")
t.run_build_system()
t.run_build_system("--clean")
# Test that usage requirements on a project work.
t.write("jamfile.jam", "exe a : a.cpp lib//b ;")
t.write("lib/jamfile.jam", """
t.write("lib/jamfile.jam", """\
project
: requirements <link>shared:<define>SHARED_B
: usage-requirements <define>FOO <link>shared:<define>SHARED_B ;
lib b : b.cpp ;
""")
t.write("lib/b.cpp", """
t.write("lib/b.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_B)
__declspec(dllexport)
#endif
foo() {}\n
foo() {}
""")
t.run_build_system()
@@ -107,39 +105,39 @@ t.run_build_system()
# Test that use requirements are inherited correctly.
t.write("jamfile.jam", "exe a : a.cpp lib/1//b ;")
t.write("a.cpp", """
t.write("a.cpp", """\
#if defined(FOO) && defined(ZOO)
void foo() {}
#endif
int main() { foo(); }
""")
t.write("lib/jamfile.jam", """
t.write("lib/jamfile.jam", """\
project : requirements : usage-requirements <define>FOO ;
""")
t.write("lib/1/jamfile.jam", """
t.write("lib/1/jamfile.jam", """\
project
: requirements <link>shared:<define>SHARED_B
: usage-requirements <define>ZOO <link>shared:<define>SHARED_B ;
lib b : b.cpp ;
""")
t.write("lib/1/b.cpp", """
t.write("lib/1/b.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_B)
__declspec(dllexport)
#endif
foo() {}\n
foo() {}
""")
t.run_build_system()
t.run_build_system("--clean")
# Test that we correctly handle dependency features in use requirements on
# Test that we correctly handle dependency features in usage requirements on
# target.
t.write("jamfile.jam", """
t.write("jamfile.jam", """\
lib b : b.cpp : <link>shared:<define>SHARED_B : : <define>FOO
<link>shared:<define>SHARED_B ;
@@ -151,7 +149,7 @@ lib cc : c.cpp : <link>shared:<define>SHARED_C : : <library>b ;
exe a : a.cpp cc ;
""")
t.write("a.cpp", """
t.write("a.cpp", """\
#ifdef FOO
void
# if defined(_WIN32) && defined(SHARED_B)
@@ -163,7 +161,7 @@ foo();
int main() { foo(); }
""")
t.write("c.cpp", """
t.write("c.cpp", """\
int
#if defined(_WIN32) && defined(SHARED_C)
__declspec(dllexport)
@@ -176,18 +174,16 @@ t.run_build_system("--clean")
# Test correct handling of dependency features in project requirements.
t.write("jamfile.jam", """
exe a : a.cpp lib1//cc ;
""")
t.write("jamfile.jam", "exe a : a.cpp lib1//cc ;")
t.write("lib1/jamfile.jam", """
t.write("lib1/jamfile.jam", """\
project
: requirements <link>shared:<define>SHARED_C
: usage-requirements <library>../lib2//b <link>shared:<define>SHARED_C ;
lib cc : c.cpp ;
""")
t.write("lib1/c.cpp", """
t.write("lib1/c.cpp", """\
int
#if defined(_WIN32) && defined(SHARED_C)
__declspec(dllexport)
@@ -195,7 +191,7 @@ __declspec(dllexport)
must_export_something;
""")
t.write("lib2/jamfile.jam", """
t.write("lib2/jamfile.jam", """\
lib b : b.cpp : <link>shared:<define>SHARED_B : : <define>FOO
<link>shared:<define>SHARED_B ;
""")
@@ -205,16 +201,17 @@ t.copy("b.cpp", "lib2/b.cpp")
t.run_build_system()
# Test that dependency feature in use requirements are built with the correct
# properties.
# Test that targets listed in dependency features in usage requirements are
# built with the correct properties.
t.rm(".")
t.write("jamfile.jam", """
t.write("jamroot.jam", "")
t.write("jamfile.jam", """\
lib main : main.cpp : <use>libs//lib1 : : <library>libs//lib1 ;
exe hello : hello.cpp main : ;
""")
t.write("main.cpp", """
t.write("main.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_LIB1)
__declspec(dllimport)
@@ -225,12 +222,7 @@ int main() { foo(); }
""")
t.write("hello.cpp", "\n")
t.write("jamroot.jam", """
import gcc ;
""")
t.write("libs/a.cpp", """
t.write("libs/a.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_LIB1)
__declspec(dllexport)
@@ -239,17 +231,17 @@ foo() {}
""")
# This library should be build with the same properties as 'main'. This is a
# This library should be built with the same properties as 'main'. This is a
# regression test for a bug when they were generated with empty properties, and
# there were ambiguity between variants.
t.write("libs/jamfile.jam", """
# there were ambiguities between variants.
t.write("libs/jamfile.jam", """\
lib lib1 : a_d.cpp : <variant>debug <link>shared:<define>SHARED_LIB1 : :
<link>shared:<define>SHARED_LIB1 ;
lib lib1 : a.cpp : <variant>release <link>shared:<define>SHARED_LIB1 : :
<link>shared:<define>SHARED_LIB1 ;
""")
t.write("libs/a_d.cpp", """
t.write("libs/a_d.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_LIB1)
__declspec(dllexport)
@@ -264,29 +256,25 @@ t.expect_addition("libs/bin/$toolset/debug/link-static/a_d.obj")
# Test that indirect conditionals are respected in usage requirements.
t.rm(".")
t.write("jamroot.jam", """
rule has-foo ( properties * )
{
return <define>HAS_FOO ;
}
t.write("jamroot.jam", """\
rule has-foo ( properties * ) { return <define>HAS_FOO ; }
exe a : a.cpp b ;
lib b : b.cpp : <link>static : : <conditional>@has-foo ;
""")
t.write("a.cpp", """
t.write("a.cpp", """\
#ifdef HAS_FOO
void foo();
int main() { foo(); }
#endif
""")
t.write("b.cpp", """
t.write("b.cpp", """\
void
#if defined(_WIN32) && defined(SHARED_B)
__declspec(dllexport)
#endif
foo() {}\n
foo() {}
""")
t.run_build_system()