From 4b0384ff0378e442535a5d3f7a2f3be181908e02 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 9 Jan 2003 01:29:30 +0000 Subject: [PATCH] Fixes for Windows/GCC-3.2 [SVN r16815] --- test/BoostBuild.py | 27 ++++++++++++++++++++++----- test/chain.py | 31 ++++++++++++++++++++++++------- test/default_build.py | 8 ++++---- test/dependency_test.py | 2 +- test/direct-request-test/a.cpp | 2 +- test/direct-request-test/b.cpp | 2 +- test/direct_request_test.py | 7 +++++-- test/main_properties.py | 2 +- test/relative_sources.py | 2 +- test/use_requirements.py | 10 +++++----- v2/test/BoostBuild.py | 27 ++++++++++++++++++++++----- v2/test/chain.py | 31 ++++++++++++++++++++++++------- v2/test/default_build.py | 8 ++++---- v2/test/dependency_test.py | 2 +- v2/test/direct-request-test/a.cpp | 2 +- v2/test/direct-request-test/b.cpp | 2 +- v2/test/direct_request_test.py | 7 +++++-- v2/test/main_properties.py | 2 +- v2/test/relative_sources.py | 2 +- v2/test/use_requirements.py | 10 +++++----- 20 files changed, 130 insertions(+), 56 deletions(-) diff --git a/test/BoostBuild.py b/test/BoostBuild.py index 6491f5f30..7412810d9 100644 --- a/test/BoostBuild.py +++ b/test/BoostBuild.py @@ -297,14 +297,31 @@ class Tester(TestCmd.TestCmd): ignore_elements(self.unexpected_difference.modified_files, wildcard) def expect_touch(self, names): + if type(names) == types.StringType: - names = [names] + names = [names] + + d = self.unexpected_difference for name in names: + + # We need to check in both touched and modified files if + # it's a Windows exe because they sometimes have slight + # differences even with identical inputs + if name.endswith('.exe'): + filesets = [d.modified_files, d.touched_files] + else: + filesets = [d.touched_files] + + while filesets: try: - self.unexpected_difference.touched_files.remove(name) - except: - print "File %s not touched as expected" % (name,) - self.fail_test(1) + filesets[-1].remove(name) + break + except ValueError: + filesets.pop() + + if not filesets: + print "File %s not touched as expected" % (name,) + self.fail_test(1) def ignore_touch(self, wildcard): diff --git a/test/chain.py b/test/chain.py index b69ea091b..4f016304e 100644 --- a/test/chain.py +++ b/test/chain.py @@ -5,32 +5,49 @@ # 2) than if 'make' create targets of type CPP, they are # correctly used (there was a bug with it). -from BoostBuild import Tester +from BoostBuild import Tester, exe_suffix t = Tester() # In order to correctly link this app, 'b.cpp', created by 'make' # rule, should be compiled. t.write("project-root.jam", "import gcc ;") -t.write("Jamfile", """ +t.write("Jamfile", r''' rule create ( dst : src * : properties * ) { + # hack to echo a space under NT + setup on $(dst) = "set x=int main(){}" ; } -actions create +import modules ; +if [ modules.peek : NT ] { - echo "int main(){}" > $(<) + actions create + { + $(setup) + echo %x% > $(<) + } } +else +{ + actions create + { + echo "int main(){}" > $(<) + } +} + IMPORT $(__name__) : create : : create ; exe a : l ; -lib l : a.cpp b.cpp ; + +# needs to be static lib for Windows - main can't appear in DLL +static-lib l : a.cpp b.cpp ; make b.cpp : : create ; -""") +''') t.write("a.cpp", "") t.run_build_system() -t.expect_addition("bin/gcc/debug/a") +t.expect_addition("bin/gcc/debug/a" + exe_suffix) t.cleanup() diff --git a/test/default_build.py b/test/default_build.py index f68c169ce..408b04bac 100644 --- a/test/default_build.py +++ b/test/default_build.py @@ -2,15 +2,15 @@ # Test that default build clause actually has any effect. -from BoostBuild import Tester +from BoostBuild import Tester, exe_suffix t = Tester() t.write("project-root.jam", "import gcc ;") t.write("Jamfile", "exe a : a.cpp : : debug release ;") -t.write("a.cpp", "int main() {}") +t.write("a.cpp", "int main() {}\n") t.run_build_system() -t.expect_addition("bin/gcc/debug/a") -t.expect_addition("bin/gcc/release/a") +t.expect_addition("bin/gcc/debug/a"+exe_suffix) +t.expect_addition("bin/gcc/release/a"+exe_suffix) t.cleanup() diff --git a/test/dependency_test.py b/test/dependency_test.py index 1f1b1b6ff..25004c09a 100644 --- a/test/dependency_test.py +++ b/test/dependency_test.py @@ -29,7 +29,7 @@ t.expect_nothing_more() t.touch("src1/a.h") t.run_build_system() -t.expect_touch("bin/gcc/debug/a") +t.expect_touch("bin/gcc/debug/a" + exe_suffix) t.expect_touch("bin/gcc/debug/a.o") t.expect_touch("bin/gcc/debug/main-target-c/c" + exe_suffix) t.expect_nothing_more() diff --git a/test/direct-request-test/a.cpp b/test/direct-request-test/a.cpp index aa4c32f18..5d2d2ae8c 100644 --- a/test/direct-request-test/a.cpp +++ b/test/direct-request-test/a.cpp @@ -4,4 +4,4 @@ void foo(); int main() { foo(); -} \ No newline at end of file +} diff --git a/test/direct-request-test/b.cpp b/test/direct-request-test/b.cpp index 93137a0c9..56b40d01b 100644 --- a/test/direct-request-test/b.cpp +++ b/test/direct-request-test/b.cpp @@ -1,4 +1,4 @@ #ifdef MACROS void foo() {} -#endif \ No newline at end of file +#endif diff --git a/test/direct_request_test.py b/test/direct_request_test.py index be061f632..948eb5d70 100644 --- a/test/direct_request_test.py +++ b/test/direct_request_test.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from BoostBuild import Tester, List +from BoostBuild import Tester, List, dll_suffix, exe_suffix import os from string import strip @@ -10,6 +10,9 @@ t = Tester() t.set_tree("direct-request-test") t.run_build_system(extra_args="define=MACROS") -t.expect_addition("bin/gcc/debug/" * List("a.o b.o b.so a")) +t.expect_addition("bin/gcc/debug/" + * (List("a.o b.o") + + ('b'+dll_suffix) + + ('a'+exe_suffix))) t.cleanup() diff --git a/test/main_properties.py b/test/main_properties.py index 92e18aceb..deae70fbb 100644 --- a/test/main_properties.py +++ b/test/main_properties.py @@ -17,7 +17,7 @@ t.write("a.cpp", """ void foo(); int main() { foo(); } """) -t.write("b.cpp", "void foo() {}") +t.write("b.cpp", "void foo() {}\n") t.run_build_system() t.expect_addition("bin/gcc/debug/main-target-b/b.o") diff --git a/test/relative_sources.py b/test/relative_sources.py index 834a3cbd1..11217556f 100644 --- a/test/relative_sources.py +++ b/test/relative_sources.py @@ -7,7 +7,7 @@ t = Tester() t.write("project-root.jam", "import gcc ;") t.write("Jamfile", "exe a : src/a.cpp ;") -t.write("src/a.cpp", "int main() {}") +t.write("src/a.cpp", "int main() {}\n") t.run_build_system() diff --git a/test/use_requirements.py b/test/use_requirements.py index a3c1f3460..ba66b426d 100644 --- a/test/use_requirements.py +++ b/test/use_requirements.py @@ -9,7 +9,7 @@ t.write("Jamfile", """ lib b : b.cpp : : : FOO ; exe a : a.cpp b ; """) -t.write("b.cpp", "void foo() {}") +t.write("b.cpp", "void foo() {}\n") t.write("a.cpp", """ #ifdef FOO void foo() {} @@ -28,7 +28,7 @@ t.write("Jamfile", """ lib b : b.cpp : : : FOO ; exe a : a.cpp : b ; """) -t.write("b.cpp", "void foo() {}") +t.write("b.cpp", "void foo() {}\n") t.write("a.cpp", """ #ifdef FOO int main() {} @@ -48,7 +48,7 @@ project : ; lib b : b.cpp ; """) -t.write("lib/b.cpp", "void foo() {}") +t.write("lib/b.cpp", "void foo() {}\n") t.run_build_system() # Test that use requirements are inherited correctly @@ -74,7 +74,7 @@ project : ; lib b : b.cpp ; """) -t.write("lib/1/b.cpp", "void foo() {}") +t.write("lib/1/b.cpp", "void foo() {}\n") t.run_build_system() t.run_build_system("--clean") @@ -164,4 +164,4 @@ void foo() {} t.run_build_system() t.expect_addition("libs/bin/gcc/debug/a_d.o") -t.cleanup() \ No newline at end of file +t.cleanup() diff --git a/v2/test/BoostBuild.py b/v2/test/BoostBuild.py index 6491f5f30..7412810d9 100644 --- a/v2/test/BoostBuild.py +++ b/v2/test/BoostBuild.py @@ -297,14 +297,31 @@ class Tester(TestCmd.TestCmd): ignore_elements(self.unexpected_difference.modified_files, wildcard) def expect_touch(self, names): + if type(names) == types.StringType: - names = [names] + names = [names] + + d = self.unexpected_difference for name in names: + + # We need to check in both touched and modified files if + # it's a Windows exe because they sometimes have slight + # differences even with identical inputs + if name.endswith('.exe'): + filesets = [d.modified_files, d.touched_files] + else: + filesets = [d.touched_files] + + while filesets: try: - self.unexpected_difference.touched_files.remove(name) - except: - print "File %s not touched as expected" % (name,) - self.fail_test(1) + filesets[-1].remove(name) + break + except ValueError: + filesets.pop() + + if not filesets: + print "File %s not touched as expected" % (name,) + self.fail_test(1) def ignore_touch(self, wildcard): diff --git a/v2/test/chain.py b/v2/test/chain.py index b69ea091b..4f016304e 100644 --- a/v2/test/chain.py +++ b/v2/test/chain.py @@ -5,32 +5,49 @@ # 2) than if 'make' create targets of type CPP, they are # correctly used (there was a bug with it). -from BoostBuild import Tester +from BoostBuild import Tester, exe_suffix t = Tester() # In order to correctly link this app, 'b.cpp', created by 'make' # rule, should be compiled. t.write("project-root.jam", "import gcc ;") -t.write("Jamfile", """ +t.write("Jamfile", r''' rule create ( dst : src * : properties * ) { + # hack to echo a space under NT + setup on $(dst) = "set x=int main(){}" ; } -actions create +import modules ; +if [ modules.peek : NT ] { - echo "int main(){}" > $(<) + actions create + { + $(setup) + echo %x% > $(<) + } } +else +{ + actions create + { + echo "int main(){}" > $(<) + } +} + IMPORT $(__name__) : create : : create ; exe a : l ; -lib l : a.cpp b.cpp ; + +# needs to be static lib for Windows - main can't appear in DLL +static-lib l : a.cpp b.cpp ; make b.cpp : : create ; -""") +''') t.write("a.cpp", "") t.run_build_system() -t.expect_addition("bin/gcc/debug/a") +t.expect_addition("bin/gcc/debug/a" + exe_suffix) t.cleanup() diff --git a/v2/test/default_build.py b/v2/test/default_build.py index f68c169ce..408b04bac 100644 --- a/v2/test/default_build.py +++ b/v2/test/default_build.py @@ -2,15 +2,15 @@ # Test that default build clause actually has any effect. -from BoostBuild import Tester +from BoostBuild import Tester, exe_suffix t = Tester() t.write("project-root.jam", "import gcc ;") t.write("Jamfile", "exe a : a.cpp : : debug release ;") -t.write("a.cpp", "int main() {}") +t.write("a.cpp", "int main() {}\n") t.run_build_system() -t.expect_addition("bin/gcc/debug/a") -t.expect_addition("bin/gcc/release/a") +t.expect_addition("bin/gcc/debug/a"+exe_suffix) +t.expect_addition("bin/gcc/release/a"+exe_suffix) t.cleanup() diff --git a/v2/test/dependency_test.py b/v2/test/dependency_test.py index 1f1b1b6ff..25004c09a 100644 --- a/v2/test/dependency_test.py +++ b/v2/test/dependency_test.py @@ -29,7 +29,7 @@ t.expect_nothing_more() t.touch("src1/a.h") t.run_build_system() -t.expect_touch("bin/gcc/debug/a") +t.expect_touch("bin/gcc/debug/a" + exe_suffix) t.expect_touch("bin/gcc/debug/a.o") t.expect_touch("bin/gcc/debug/main-target-c/c" + exe_suffix) t.expect_nothing_more() diff --git a/v2/test/direct-request-test/a.cpp b/v2/test/direct-request-test/a.cpp index aa4c32f18..5d2d2ae8c 100644 --- a/v2/test/direct-request-test/a.cpp +++ b/v2/test/direct-request-test/a.cpp @@ -4,4 +4,4 @@ void foo(); int main() { foo(); -} \ No newline at end of file +} diff --git a/v2/test/direct-request-test/b.cpp b/v2/test/direct-request-test/b.cpp index 93137a0c9..56b40d01b 100644 --- a/v2/test/direct-request-test/b.cpp +++ b/v2/test/direct-request-test/b.cpp @@ -1,4 +1,4 @@ #ifdef MACROS void foo() {} -#endif \ No newline at end of file +#endif diff --git a/v2/test/direct_request_test.py b/v2/test/direct_request_test.py index be061f632..948eb5d70 100644 --- a/v2/test/direct_request_test.py +++ b/v2/test/direct_request_test.py @@ -1,6 +1,6 @@ #!/usr/bin/python -from BoostBuild import Tester, List +from BoostBuild import Tester, List, dll_suffix, exe_suffix import os from string import strip @@ -10,6 +10,9 @@ t = Tester() t.set_tree("direct-request-test") t.run_build_system(extra_args="define=MACROS") -t.expect_addition("bin/gcc/debug/" * List("a.o b.o b.so a")) +t.expect_addition("bin/gcc/debug/" + * (List("a.o b.o") + + ('b'+dll_suffix) + + ('a'+exe_suffix))) t.cleanup() diff --git a/v2/test/main_properties.py b/v2/test/main_properties.py index 92e18aceb..deae70fbb 100644 --- a/v2/test/main_properties.py +++ b/v2/test/main_properties.py @@ -17,7 +17,7 @@ t.write("a.cpp", """ void foo(); int main() { foo(); } """) -t.write("b.cpp", "void foo() {}") +t.write("b.cpp", "void foo() {}\n") t.run_build_system() t.expect_addition("bin/gcc/debug/main-target-b/b.o") diff --git a/v2/test/relative_sources.py b/v2/test/relative_sources.py index 834a3cbd1..11217556f 100644 --- a/v2/test/relative_sources.py +++ b/v2/test/relative_sources.py @@ -7,7 +7,7 @@ t = Tester() t.write("project-root.jam", "import gcc ;") t.write("Jamfile", "exe a : src/a.cpp ;") -t.write("src/a.cpp", "int main() {}") +t.write("src/a.cpp", "int main() {}\n") t.run_build_system() diff --git a/v2/test/use_requirements.py b/v2/test/use_requirements.py index a3c1f3460..ba66b426d 100644 --- a/v2/test/use_requirements.py +++ b/v2/test/use_requirements.py @@ -9,7 +9,7 @@ t.write("Jamfile", """ lib b : b.cpp : : : FOO ; exe a : a.cpp b ; """) -t.write("b.cpp", "void foo() {}") +t.write("b.cpp", "void foo() {}\n") t.write("a.cpp", """ #ifdef FOO void foo() {} @@ -28,7 +28,7 @@ t.write("Jamfile", """ lib b : b.cpp : : : FOO ; exe a : a.cpp : b ; """) -t.write("b.cpp", "void foo() {}") +t.write("b.cpp", "void foo() {}\n") t.write("a.cpp", """ #ifdef FOO int main() {} @@ -48,7 +48,7 @@ project : ; lib b : b.cpp ; """) -t.write("lib/b.cpp", "void foo() {}") +t.write("lib/b.cpp", "void foo() {}\n") t.run_build_system() # Test that use requirements are inherited correctly @@ -74,7 +74,7 @@ project : ; lib b : b.cpp ; """) -t.write("lib/1/b.cpp", "void foo() {}") +t.write("lib/1/b.cpp", "void foo() {}\n") t.run_build_system() t.run_build_system("--clean") @@ -164,4 +164,4 @@ void foo() {} t.run_build_system() t.expect_addition("libs/bin/gcc/debug/a_d.o") -t.cleanup() \ No newline at end of file +t.cleanup()