from BoostBuild import Tester, List # Create a temporary working directory t = Tester() # Create the needed files t.write("Jamroot", """ exe hello : hello.cpp ; # This should use the 'hello' target, even if there's # 'hello' file in current dir. install s : hello : <location>. ; """) t.write("hello.cpp", """ int main() { return 0; } """) t.run_build_system() 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 # current dir, nothing will be rebuilt. t.expect_touch("bin/$toolset/debug/hello.obj") t.cleanup()
"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 lib2/helper/e.cpp """) t.expect_addition("lib3/bin/$toolset/debug/f.obj") t.expect_content( "lib3/bin/$toolset/debug/f.obj", """$toolset/debug lib3/f.cpp lib2/helper/bin/$toolset/debug/e.obj """) t.touch("a.cpp") t.run_build_system() 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.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') t.expect_removal([
"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 lib3/f.cpp lib2/helper/bin/$toolset/debug/e.obj """, ) t.touch("a.cpp") t.run_build_system() 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.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")
t.expect_addition("dist2/b/c.h") # Test that when installing .cpp files, we don't scan # include dependencies. t.rm(".") t.write("Jamroot", """ install dist : a.cpp ; """) t.write("a.cpp", """ #include "a.h" """) t.write("a.h", "") t.run_build_system() t.expect_addition("dist/a.cpp") t.touch("a.h") t.run_build_system() t.expect_nothing("dist/a.cpp") # Test that <name> property works, when there's just # one file in sources. t.rm(".") t.write("Jamroot", """ install dist : a.cpp : <name>b.cpp ; """) t.write("a.cpp", "test file") t.run_build_system() t.expect_addition("dist/b.cpp") t.cleanup()
b.cpp """) t.fail(t.read("bin/a/yfc/debug/runtime-link-dynamic/a") !=\ """ <optimization>off <rtti>on <runtime-link>dynamic <toolset>yfc <variant>debug <optimization>off <rtti>on <runtime-link>dynamic <toolset>yfc <variant>debug a.cpp <optimization>space <rtti>on <runtime-link>dynamic <toolset>yfc <variant>debug b.cpp """) # Check that we have vanilla target names available in subdirs t.touch("auxillary/b.cpp") t.run_build_system("-sTOOLSET b.obj", subdir="auxillary") t.expect_touch("auxillary/bin/b.obj/yfc/debug/runtime-link-dynamic/optimization-space/b.obj") t.expect_no_modification("bin/a.obj/yfc/debug/runtime-link-dynamic/a.obj") t.expect_no_modification("bin/a/yfc/debug/runtime-link-dynamic/a") # Check that we cannot request link-incompatible property for source target t.write('Jamfile', t.read('Jamfile2')) stdout="""Error: subvariant of target ./a with properties <optimization>off <rtti>on <runtime-link>dynamic <toolset>yfc <variant>debug requests link-incompatible property <rtti>off for source @auxillary/b.obj """
, 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test' , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test']) # I didn't add a test for 'no other files were touched', because # it's a little complicated. There is an expect_nothing_more() # function, but we actually need to spell out a lot more than # what we currently have to do that. # 4) Introduced error into one of the library files, causing a library build # compile to fail. path_test.test was deleted, so the reporting programs # would know that failure occurred. Excellent! This is the case that has # caused regression testing to report the wrong results in the past, so it # was good news to see it working correctly now. We probably should figure # out some other test cases just to be sure it is working for full coverage. t.rename('lib.cpp', 'lib.cpp.bak') t.rename('lib-err.cpp', 'lib.cpp') t.touch('lib.cpp') t.run_build_system(arguments = 'test', status=1) t.expect_removal( ['bin/link.test/gcc/debug/runtime-link-dynamic/link.test' , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test' , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test']) # 5) Fixed the error in the library file. The library build then worked, and # path_test.exe was relinked, without first recompiling path_test.obj. Test # was rerun. Exactly right behavior! t.rename('lib.cpp.bak', 'lib.cpp') t.run_build_system(arguments = 'test', status = 0) t.expect_addition( [ 'bin/link.test/gcc/debug/runtime-link-dynamic/link.test' , 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test' , 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test'])
#!/usr/bin/python from BoostBuild import Tester, List t = Tester() t.set_tree("dependency-test") t.run_build_system() # Check that main target 'c' was able to find 'x.h' from # 'a's dependency graph t.expect_addition("bin/$toolset/debug/c.exe") # Check handling of first level includes. # Both 'a' and 'b' include "a.h" and should be updated t.touch("a.h") t.run_build_system() t.expect_touch("bin/$toolset/debug/a.exe") t.expect_touch("bin/$toolset/debug/a.obj") t.expect_touch("bin/$toolset/debug/a_c.obj") t.expect_touch("bin/$toolset/debug/b.exe") t.expect_touch("bin/$toolset/debug/b.obj") # Now, <dependency> does not add dependency. # It sound weird, but is intentional. Need # to rename <dependency> eventually. #t.expect_touch("bin/$toolset/debug/main-target-c/c.exe") t.ignore("*.tds") t.expect_nothing_more() # Only 'a' include <a.h> and should be updated
'bin/run.test/gcc/debug/runtime-link-dynamic/run.test' ]) # I didn't add a test for 'no other files were touched', because # it's a little complicated. There is an expect_nothing_more() # function, but we actually need to spell out a lot more than # what we currently have to do that. # 4) Introduced error into one of the library files, causing a library build # compile to fail. path_test.test was deleted, so the reporting programs # would know that failure occurred. Excellent! This is the case that has # caused regression testing to report the wrong results in the past, so it # was good news to see it working correctly now. We probably should figure # out some other test cases just to be sure it is working for full coverage. t.rename('lib.cpp', 'lib.cpp.bak') t.rename('lib-err.cpp', 'lib.cpp') t.touch('lib.cpp') t.run_build_system(arguments='test', status=1) t.expect_removal([ 'bin/link.test/gcc/debug/runtime-link-dynamic/link.test', 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test', 'bin/run.test/gcc/debug/runtime-link-dynamic/run.test' ]) # 5) Fixed the error in the library file. The library build then worked, and # path_test.exe was relinked, without first recompiling path_test.obj. Test # was rerun. Exactly right behavior! t.rename('lib.cpp.bak', 'lib.cpp') t.run_build_system(arguments='test', status=0) t.expect_addition([ 'bin/link.test/gcc/debug/runtime-link-dynamic/link.test', 'bin/nolink.test/gcc/debug/runtime-link-dynamic/nolink.test',
""") 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.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", """ import testing ; compile-fail c.cpp ; compile c-f.cpp ; run-fail r.cpp : : dir/input.txt ; run r-f.cpp ; """) t.touch(List("c.cpp c-f.cpp r.cpp r-f.cpp")) t.run_build_system("hardcode-dll-paths=false", stderr=None, status=1) t.expect_removal("bin/c.test/$toolset/debug/c.test") t.expect_removal("bin/c-f.test/$toolset/debug/c-f.test") t.expect_removal("bin/r.test/$toolset/debug/r.test") t.expect_removal("bin/r-f.test/$toolset/debug/r-f.test") t.cleanup()
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.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", """ import testing ; compile-fail c.cpp ; compile c-f.cpp ; run-fail r.cpp : : dir/input.txt ; run r-f.cpp ; """) t.touch(List("c.cpp c-f.cpp r.cpp r-f.cpp")) t.run_build_system("hardcode-dll-paths=false", stderr=None, status=1) t.expect_removal("bin/c.test/$toolset/debug/c.test") t.expect_removal("bin/c-f.test/$toolset/debug/c-f.test") t.expect_removal("bin/r.test/$toolset/debug/r.test") t.expect_removal("bin/r-f.test/$toolset/debug/r-f.test") t.cleanup()