|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86709 - in trunk/tools/build/v2: test tools
From: steven_at_[hidden]
Date: 2013-11-14 18:24:50
Author: steven_watanabe
Date: 2013-11-14 18:24:50 EST (Thu, 14 Nov 2013)
New Revision: 86709
URL: http://svn.boost.org/trac/boost/changeset/86709
Log:
Add tests for link.jam. Fix timestamp/dependency problem that made symlinks cause unnecessary rebuilds on Windows.
Added:
trunk/tools/build/v2/test/link.py (contents, props changed)
Text files modified:
trunk/tools/build/v2/test/link.py | 154 +++++++++++++++++++++++++++++++++++++++
trunk/tools/build/v2/test/test_all.py | 1
trunk/tools/build/v2/tools/link.jam | 10 +-
3 files changed, 161 insertions(+), 4 deletions(-)
Added: trunk/tools/build/v2/test/link.py
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/build/v2/test/link.py 2013-11-14 18:24:50 EST (Thu, 14 Nov 2013) (r86709)
@@ -0,0 +1,154 @@
+#!/usr/bin/python
+
+# Copyright 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)
+
+# Tests the link-directory rule used to create the
+# common boost/ directory in the new git layout.
+
+import BoostBuild
+
+def ignore_config(t):
+ """These files are created by the configuration logic in link.jam
+ They may or may not exist, depending on the system."""
+ t.ignore("bin/test-hardlink")
+ t.ignore("bin/test-hardlink-source")
+ t.ignore("bin/test-symlink")
+ t.ignore("bin/test-symlink-source")
+
+def test_basic():
+ """Test creation of a single link"""
+ t = BoostBuild.Tester()
+ t.write("jamroot.jam", """\
+ import link ;
+ link-directory dir1-link : src/dir1/include : <location>. ;
+ """)
+
+ t.write("src/dir1/include/file1.h", "file1")
+
+ t.run_build_system()
+
+ t.expect_addition("include/file1.h")
+ t.expect_content("include/file1.h", "file1")
+ ignore_config(t)
+ t.expect_nothing_more()
+ t.cleanup()
+
+def test_merge_two():
+ """Test merging two directories"""
+ t = BoostBuild.Tester()
+ t.write("jamroot.jam", """\
+ import link ;
+ link-directory dir1-link : src/dir1/include : <location>. ;
+ link-directory dir2-link : src/dir2/include : <location>. ;
+ """)
+
+ t.write("src/dir1/include/file1.h", "file1")
+ t.write("src/dir2/include/file2.h", "file2")
+
+ t.run_build_system()
+
+ t.expect_addition("include/file1.h")
+ t.expect_content("include/file1.h", "file1")
+ t.expect_addition("include/file2.h")
+ t.expect_content("include/file2.h", "file2")
+ ignore_config(t)
+ t.expect_nothing_more()
+ t.cleanup()
+
+def test_merge_existing():
+ """Test adding a link when a different symlink already exists"""
+ t = BoostBuild.Tester()
+ t.write("jamroot.jam", """\
+ import link ;
+ link-directory dir1-link : src/dir1/include : <location>. ;
+ link-directory dir2-link : src/dir2/include : <location>. ;
+ """)
+
+ t.write("src/dir1/include/file1.h", "file1")
+ t.write("src/dir2/include/file2.h", "file2")
+
+ t.run_build_system(["dir1-link"])
+
+ t.expect_addition("include/file1.h")
+ t.expect_content("include/file1.h", "file1")
+ ignore_config(t)
+ t.expect_nothing_more()
+
+ t.run_build_system(["dir2-link"])
+
+ t.expect_addition("include/file2.h")
+ t.expect_content("include/file2.h", "file2")
+ # If include is a symlink to src/dir1/include, then
+ # we have to delete it and add a directory.
+ t.ignore_removal("include/file1.h")
+ ignore_config(t)
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+def test_merge_recursive():
+ "Test merging several directories including common prefixes"
+ t = BoostBuild.Tester()
+ t.write("jamroot.jam", """\
+ import link ;
+ link-directory dir1-link : src/dir1/include : <location>. ;
+ link-directory dir2-link : src/dir2/include : <location>. ;
+ link-directory dir3-link : src/dir3/include : <location>. ;
+ """)
+
+ t.write("src/dir1/include/file1.h", "file1")
+ t.write("src/dir2/include/file2.h", "file2")
+ t.write("src/dir2/include/nested/file3.h", "file3")
+ t.write("src/dir3/include/nested/file4.h", "file4")
+
+ t.run_build_system()
+
+ t.expect_addition("include/file1.h")
+ t.expect_content("include/file1.h", "file1")
+ t.expect_addition("include/file2.h")
+ t.expect_content("include/file2.h", "file2")
+ t.expect_addition("include/nested/file3.h")
+ t.expect_content("include/nested/file3.h", "file3")
+ t.expect_addition("include/nested/file4.h")
+ t.expect_content("include/nested/file4.h", "file4")
+ ignore_config(t)
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+def test_include_scan():
+ """Make sure that the #include scanner finds the headers"""
+ t = BoostBuild.Tester()
+ t.write("jamroot.jam", """\
+ import link ;
+ link-directory dir1-link : src/dir1/include : <location>. ;
+ link-directory dir2-link : src/dir2/include : <location>. ;
+ obj test : test.cpp :
+ <include>include
+ <implicit-dependency>dir1-link
+ <implicit-dependency>dir2-link ;
+ """)
+
+ t.write("src/dir1/include/file1.h", "#include <file2.h>\n")
+ t.write("src/dir2/include/file2.h", "int f();\n")
+ t.write("test.cpp", """\
+ #include <file1.h>
+ int main() { f(); }
+ """);
+
+ t.run_build_system(["test"])
+
+ t.expect_addition("bin/$toolset/debug/test.obj")
+
+ t.run_build_system()
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+test_basic()
+test_merge_two()
+test_merge_existing()
+test_merge_recursive()
+test_include_scan()
Modified: trunk/tools/build/v2/test/test_all.py
==============================================================================
--- trunk/tools/build/v2/test/test_all.py Thu Nov 14 15:00:24 2013 (r86708)
+++ trunk/tools/build/v2/test/test_all.py 2013-11-14 18:24:50 EST (Thu, 14 Nov 2013) (r86709)
@@ -221,6 +221,7 @@
"lib_source_property",
"library_chain",
"library_property",
+ "link",
"load_order",
"loop",
"make_rule",
Modified: trunk/tools/build/v2/tools/link.jam
==============================================================================
--- trunk/tools/build/v2/tools/link.jam Thu Nov 14 15:00:24 2013 (r86708)
+++ trunk/tools/build/v2/tools/link.jam 2013-11-14 18:24:50 EST (Thu, 14 Nov 2013) (r86709)
@@ -227,10 +227,6 @@
DEPENDS $(.current-target) : $(target) ;
common.mkdir $(target) ;
}
- if ! [ on $(target) return $(RM) ]
- {
- NOUPDATE $(target) ;
- }
MKLINK_OR_DIR on $(target) = mkdir \"$(target)\" ;
}
@@ -242,6 +238,11 @@
link.rm $(target) ;
}
+rule mklink-or-dir
+{
+ NOUPDATE $(<) ;
+}
+
actions mklink-or-dir
{
$(MKLINK_OR_DIR)
@@ -258,6 +259,7 @@
local s = [ path.native [ path.relative-to [ path.pwd ] $(target) ] ] ;
LOCATE on $(t) = . ;
DEPENDS $(t) : $(s) ;
+ NOUPDATE $(s) ;
}
if $(split)
{
Boost-Commit 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