From e7885b762b1d4022f0a7e78ea0a8fc6f36fcab80 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 21 Jul 2003 07:17:19 +0000 Subject: [PATCH] Bugfix: conditionals properties was misbehaving when there were ":" in property value. * new/property.jam (evaluate-conditionals-in-context): Don't be greedy in regex. * test/conditionals3.py: New test. [SVN r19243] --- new/property.jam | 2 +- test/conditionals3.py | 34 ++++++++++++++++++++++++++++++++++ test/test_all.py | 1 + v2/build/property.jam | 2 +- v2/test/conditionals3.py | 34 ++++++++++++++++++++++++++++++++++ v2/test/test_all.py | 1 + 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 test/conditionals3.py create mode 100644 v2/test/conditionals3.py diff --git a/new/property.jam b/new/property.jam index 05897b440..602218888 100644 --- a/new/property.jam +++ b/new/property.jam @@ -114,7 +114,7 @@ rule evaluate-conditionals-in-context ( properties * : context * ) for local p in $(conditionals) { # Separate condition and property - local s = [ MATCH (.*):(.*) : $(p) ] ; + local s = [ MATCH ([^:]*):(.*) : $(p) ] ; # Split condition into individual properties local c = [ regex.split $(s[1]) "," ] ; # Evaluate condition diff --git a/test/conditionals3.py b/test/conditionals3.py new file mode 100644 index 000000000..c4b067dd0 --- /dev/null +++ b/test/conditionals3.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and +# distribute this software is granted provided this copyright notice appears in +# all copies. This software is provided "as is" without express or implied +# warranty, and with no claim as to its suitability for any purpose. + +# Test that conditional properties work, even if property is free, and +# value includes colon. +from BoostBuild import Tester, List + + +t = Tester() + +# Create the needed files +t.write("project-root.jam", "") +t.write("Jamfile", """ +exe hello : hello.cpp : debug:CLASS=Foo::Bar ; +""") +t.write("hello.cpp", """ +namespace Foo { class Bar { } ; } +int main() +{ + CLASS c; + return 0; +} + +""") + +# Don't check stderr, which can include warning about unused 'c'. +t.run_build_system(stderr=None) +t.expect_addition("bin/$toolset/debug/main-target-hello/hello") + +t.cleanup() diff --git a/test/test_all.py b/test/test_all.py index 71aab124b..c30dfc97b 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -101,6 +101,7 @@ tests = [ "project_test1", "conditionals2", "property_expansion", "loop", + "conditionals3", ] if os.name == 'posix': diff --git a/v2/build/property.jam b/v2/build/property.jam index 05897b440..602218888 100644 --- a/v2/build/property.jam +++ b/v2/build/property.jam @@ -114,7 +114,7 @@ rule evaluate-conditionals-in-context ( properties * : context * ) for local p in $(conditionals) { # Separate condition and property - local s = [ MATCH (.*):(.*) : $(p) ] ; + local s = [ MATCH ([^:]*):(.*) : $(p) ] ; # Split condition into individual properties local c = [ regex.split $(s[1]) "," ] ; # Evaluate condition diff --git a/v2/test/conditionals3.py b/v2/test/conditionals3.py new file mode 100644 index 000000000..c4b067dd0 --- /dev/null +++ b/v2/test/conditionals3.py @@ -0,0 +1,34 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and +# distribute this software is granted provided this copyright notice appears in +# all copies. This software is provided "as is" without express or implied +# warranty, and with no claim as to its suitability for any purpose. + +# Test that conditional properties work, even if property is free, and +# value includes colon. +from BoostBuild import Tester, List + + +t = Tester() + +# Create the needed files +t.write("project-root.jam", "") +t.write("Jamfile", """ +exe hello : hello.cpp : debug:CLASS=Foo::Bar ; +""") +t.write("hello.cpp", """ +namespace Foo { class Bar { } ; } +int main() +{ + CLASS c; + return 0; +} + +""") + +# Don't check stderr, which can include warning about unused 'c'. +t.run_build_system(stderr=None) +t.expect_addition("bin/$toolset/debug/main-target-hello/hello") + +t.cleanup() diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 71aab124b..c30dfc97b 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -101,6 +101,7 @@ tests = [ "project_test1", "conditionals2", "property_expansion", "loop", + "conditionals3", ] if os.name == 'posix':