From 034e54f68d6d358413bf26ca6328e97ee8052244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Sat, 5 Jan 2008 23:18:17 +0000 Subject: [PATCH] Refactored the test into two separate test functions. Made the 'directory names with dots' test use the expect_output_line() tool instead of a manual find, causing a better diagnostic to be displayed in case of a failure. Made one of the test Jam scripts more compact. Made the test use the Jamroot.jam file instead of project-root.jam. [SVN r42504] --- v2/test/tag.py | 184 +++++++++++++++++++++++++++---------------------- 1 file changed, 102 insertions(+), 82 deletions(-) diff --git a/v2/test/tag.py b/v2/test/tag.py index 5c72fdeb5..d65bed340 100644 --- a/v2/test/tag.py +++ b/v2/test/tag.py @@ -5,87 +5,22 @@ # all copies. This software is provided "as is" without express or implied # warranty, and with no claim as to its suitability for any purpose. -from BoostBuild import Tester, List -import string +import BoostBuild -t = Tester() -t.write("project-root.jam", "") -t.write("Jamfile", """ -import virtual-target ; -rule tag ( name : type ? : property-set ) -{ - local tags ; - local v = [ $(property-set).get ] ; - if $(v) = debug - { - tags += d ; - } - else if $(v) = release - { - tags += r ; - } - - local l = [ $(property-set).get ] ; - if $(l) = shared - { - tags += s ; - } - else if $(l) = static - { - tags += t ; - } - - if $(tags) - { - return [ virtual-target.add-prefix-and-suffix $(name)_$(tags:J="") - : $(type) : $(property-set) ] ; - } - -} +################################################################################ +# +# test_folder_with_dot_in_name() +# ------------------------------ +# +################################################################################ -# Test both fully-qualified and local name of the rule -exe a : a.cpp : @$(__name__).tag ; -lib b : a.cpp : @tag ; -stage c : a ; -""") +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. + """ -t.write("a.cpp", """ -int main() -{ - return 0; -} - -#ifdef _MSC_VER -__declspec (dllexport) void x () {} -#endif -""") - -file_list = \ -List("bin/$toolset/debug/a_ds.exe") + \ -List("bin/$toolset/debug/b_ds.dll") + \ -List("c/a_ds.exe") + \ -List("bin/$toolset/release/a_rs.exe") + \ -List("bin/$toolset/release/b_rs.dll") + \ -List("c/a_rs.exe") + \ -List("bin/$toolset/debug/link-static/a_dt.exe") + \ -List("bin/$toolset/debug/link-static/b_dt.lib") + \ -List("c/a_dt.exe") + \ -List("bin/$toolset/release/link-static/a_rt.exe") + \ -List("bin/$toolset/release/link-static/b_rt.lib") + \ -List("c/a_rt.exe") - -variants = "debug release link=static,shared" - -t.run_build_system(variants) -t.expect_addition(file_list) - -t.run_build_system(variants + " clean") -t.expect_removal(file_list) - -# Regression test: the 'tag' feature did not work in directories that -# had dot in names. -t.write("version-1.32.0/Jamroot", """ + t.write("version-1.32.0/Jamroot.jam", """ project test : requirements @$(__name__).tag ; rule tag ( name : type ? : property-set ) @@ -95,12 +30,97 @@ rule tag ( name : type ? : property-set ) } exe a : a.cpp ; """) + t.write("version-1.32.0/a.cpp", "int main() { return 0; }\n") -t.write("version-1.32.0/a.cpp", "int main() { return 0; }\n") + t.run_build_system(subdir="version-1.32.0") + t.expect_addition("version-1.32.0/bin/$toolset/debug/a.exe") + t.expect_output_line("The tag rule was invoked") -t.run_build_system(subdir="version-1.32.0") -t.expect_addition("version-1.32.0/bin/$toolset/debug/a.exe") -t.fail_test(string.find(t.stdout(), "The tag rule was invoked") == -1) + +################################################################################ +# +# test_tag_property() +# ------------------- +# +################################################################################ + +def test_tag_property(t): + """Basic tag property test. + """ + + t.write("Jamroot.jam", """ +import virtual-target ; + +rule tag ( name : type ? : property-set ) +{ + local tags ; + switch [ $(property-set).get ] + { + case debug : tags += d ; + case release : tags += r ; + } + switch [ $(property-set).get ] + { + case shared : tags += s ; + case static : tags += t ; + } + if $(tags) + { + return [ virtual-target.add-prefix-and-suffix $(name)_$(tags:J="") + : $(type) : $(property-set) ] ; + } +} + +# Test both fully-qualified and local name of the rule +exe a : a.cpp : @$(__name__).tag ; +lib b : a.cpp : @tag ; +stage c : a ; +""") + + t.write("a.cpp", """ +int main() +{ + return 0; +} + +#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") + + variants = "debug release link=static,shared" + + t.run_build_system(variants) + t.expect_addition(file_list) + + t.run_build_system(variants + " clean") + t.expect_removal(file_list) + + +################################################################################ +# +# main() +# ------ +# +################################################################################ + +t = BoostBuild.Tester() + +test_tag_property(t) +test_folder_with_dot_in_name(t) t.cleanup() -