Boost logo

Boost-Build :

From: Jurko Gospodnetiæ (jurko.gospodnetic_at_[hidden])
Date: 2008-01-04 14:20:43


   Hi.

   I'm attaching a patch for the alias test. See the comment embedded
inside the patch file.

   Best regards,
     Jurko Gospodnetiæ

Corrected a bug with Jamroot.jam being used in one part of the test and
project-root.jam in another. Refactored the test into two separate test
functions.

Left base folder: X:\Boost_Build\20071228_nightly_build\Original
Right base folder: X:\Boost_Build\20071228_nightly_build\Modified
--- boost-build\test\alias.py 2008-01-04 19:36:23.000000000 +-0100
+++ boost-build\test\alias.py 2008-01-04 20:07:29.000000000 +-0100
@@ -3,73 +3,104 @@
 # Copyright 2003 Dave Abrahams
 # 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)
 
 from BoostBuild import Tester, List
-t = Tester()
+
 
-t.write("Jamroot.jam", """
+################################################################################
+#
+# test_alias_rule()
+# -----------------
+#
+################################################################################
+
+def test_alias_rule(t):
+ """Basic alias rule test.
+ """
+
+ t.write("Jamroot.jam", """
 exe a : a.cpp ;
 exe b : b.cpp ;
 exe c : c.cpp ;
 
 alias bin1 : a ;
 alias bin2 : a b ;
 
 alias src : s.cpp ;
 exe hello : hello.cpp src ;
 """)
 
-t.write("a.cpp", "int main() { return 0; }\n")
-t.copy("a.cpp", "b.cpp")
-t.copy("a.cpp", "c.cpp")
-t.copy("a.cpp", "hello.cpp")
-t.write("s.cpp", "")
+ t.write("a.cpp", "int main() { return 0; }\n")
+ t.copy("a.cpp", "b.cpp")
+ t.copy("a.cpp", "c.cpp")
+ t.copy("a.cpp", "hello.cpp")
+ t.write("s.cpp", "")
 
-# Check that targets to which "bin1" refers are updated, and only those.
-t.run_build_system("bin1")
-t.expect_addition(List("bin/$toolset/debug/") * "a.exe a.obj")
-t.expect_nothing_more()
+ # Check that targets to which "bin1" refers are updated, and only those.
+ t.run_build_system("bin1")
+ t.expect_addition(List("bin/$toolset/debug/") * "a.exe a.obj")
+ t.expect_nothing_more()
 
-# Try again with "bin2"
-t.run_build_system("bin2")
-t.expect_addition(List("bin/$toolset/debug/") * "b.exe b.obj")
-t.expect_nothing_more()
+ # Try again with "bin2"
+ t.run_build_system("bin2")
+ t.expect_addition(List("bin/$toolset/debug/") * "b.exe b.obj")
+ t.expect_nothing_more()
 
-# Try building everything, making sure 'hello' target is created.
-t.run_build_system()
-t.expect_addition(List("bin/$toolset/debug/") * "hello.exe hello.obj")
-t.expect_addition("bin/$toolset/debug/s.obj")
-t.expect_addition(List("bin/$toolset/debug/") * "c.exe c.obj")
-t.expect_nothing_more()
+ # Try building everything, making sure 'hello' target is created.
+ t.run_build_system()
+ t.expect_addition(List("bin/$toolset/debug/") * "hello.exe hello.obj")
+ t.expect_addition("bin/$toolset/debug/s.obj")
+ t.expect_addition(List("bin/$toolset/debug/") * "c.exe c.obj")
+ t.expect_nothing_more()
 
-# Regression test.
-# Check if usage requirements are propagated via "alias"
-
-t.write("l.cpp", """
+
+################################################################################
+#
+# test_alias_source_usage_requirements()
+# --------------------------------------
+#
+################################################################################
+
+def test_alias_source_usage_requirements(t):
+ """Check whether usage requirements are propagated via "alias". In case they
+ are not, linking will fail as there will be no main() function defined
+ anywhere in the source.
+ """
+
+ t.write("Jamroot.jam", """
+lib l : l.cpp : : : <define>WANT_MAIN ;
+alias la : l ;
+exe main : main.cpp la ;
+""")
+
+ t.write("l.cpp", """
 void
 #if defined(_WIN32)
 __declspec(dllexport)
 #endif
 foo() {}
-
 """)
 
-t.write("Jamfile", """
-lib l : l.cpp : : : <define>WANT_MAIN ;
-alias la : l ;
-exe main : main.cpp la ;
-""")
-
-t.write("main.cpp", """
+ t.write("main.cpp", """
 #ifdef WANT_MAIN
 int main() { return 0; }
 #endif
-
 """)
 
-t.write("project-root.jam", "")
+ t.run_build_system()
+
+
+################################################################################
+#
+# main()
+# ------
+#
+################################################################################
+
+t = Tester()
 
-t.run_build_system()
+test_alias_rule(t)
+test_alias_source_usage_requirements(t)
 
 t.cleanup()


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk