2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-15 00:52:16 +00:00

(merge from head) A variety of changes to make most tests pass on Windows (with mingw):

* BoostBuild.py; Make the matching of content and files be more loose and use pattern globbing of toolset names.
* glob.py/project_glob.py; Rename to avoid collision with builtin Python module.
* all; Update copyrights and license info.


[SVN r35731]
This commit is contained in:
Rene Rivera
2006-10-24 23:26:32 +00:00
parent a516eb2c94
commit 6d13f1ea85
5 changed files with 69 additions and 142 deletions

View File

@@ -1,16 +1,23 @@
# Copyright 2002-2005 Vladimir Prus.
# Copyright 2002-2003 Dave Abrahams.
# Copyright 2006 Rene Rivera.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import TestCmd
from tree import build_tree, trees_difference
import copy
import fnmatch
import glob
import os
import re
import shutil
import string
import types
import time
import tempfile
import sys
import re
def get_toolset():
toolset = None;
@@ -39,6 +46,17 @@ def prepare_suffix_map(toolset):
if os.__dict__.has_key('uname') and os.uname()[0] == 'Darwin':
suffixes['.dll'] = '.dylib'
def re_remove(sequence,regex):
me = re.compile(regex)
result = filter( lambda x: me.match(x), sequence )
for r in result:
sequence.remove(r)
def glob_remove(sequence,pattern):
result = fnmatch.filter(sequence,pattern)
for r in result:
sequence.remove(r)
lib_prefix = 1
if windows:
lib_prefix = 0
@@ -255,10 +273,13 @@ class Tester(TestCmd.TestCmd):
os.chdir(self.original_workdir)
for name in names:
n = self.native_file_name(name)
if os.path.isdir(n):
shutil.rmtree(n, ignore_errors=0)
else:
os.unlink(n)
n = glob.glob(n)
if n:
n = n[0]
if os.path.isdir(n):
shutil.rmtree(n, ignore_errors=0)
else:
os.unlink(n)
# Create working dir root again, in case
# we've removed it
@@ -358,10 +379,10 @@ class Tester(TestCmd.TestCmd):
self.last_build_time = time.time()
def read(self, name):
return open(self.native_file_name(name), "rb").read()
return open(glob.glob(self.native_file_name(name))[0], "rb").read()
def read_and_strip(self, name):
lines = open(self.native_file_name(name), "rb").readlines()
lines = open(glob.glob(self.native_file_name(name))[0], "rb").readlines()
result = string.join(map(string.rstrip, lines), "\n")
if lines and lines[-1][-1] == '\n':
return result + '\n'
@@ -399,7 +420,7 @@ class Tester(TestCmd.TestCmd):
def expect_addition(self, names):
for name in self.adjust_names(names):
try:
self.unexpected_difference.added_files.remove(name)
glob_remove(self.unexpected_difference.added_files,name)
except:
print "File %s not added as expected" % (name,)
self.fail_test(1)
@@ -410,7 +431,7 @@ class Tester(TestCmd.TestCmd):
def expect_removal(self, names):
for name in self.adjust_names(names):
try:
self.unexpected_difference.removed_files.remove(name)
glob_remove(self.unexpected_difference.removed_files,name)
except:
print "File %s not removed as expected" % (name,)
self.fail_test(1)
@@ -443,7 +464,7 @@ class Tester(TestCmd.TestCmd):
while filesets:
try:
filesets[-1].remove(name)
glob_remove(filesets[-1],name)
break
except ValueError:
filesets.pop()
@@ -509,9 +530,23 @@ class Tester(TestCmd.TestCmd):
print "Note: could not open file", name
self.fail_test(1)
content = string.replace(content, "$toolset", self.toolset)
content = string.replace(content, "$toolset", self.toolset+"*")
if exact:
matched = fnmatch.fnmatch(actual,content)
else:
actual_ = map(lambda x: sorted(x.split()),actual.splitlines())
content_ = map(lambda x: sorted(x.split()),content.splitlines())
matched = map(
lambda x,y: map(lambda n,p: fnmatch.fnmatch(n,p),x,y),
actual_, content_ )
matched = reduce(
lambda x,y: x and reduce(
lambda a,b: a and b,
y ),
matched )
if actual != content:
if not matched:
print "Expected:\n"
print content
print "Got:\n"
@@ -596,7 +631,7 @@ class Tester(TestCmd.TestCmd):
names = [names]
r = map(self.adjust_lib_name, names)
r = map(self.adjust_suffix, r)
r = map(lambda x, t=self.toolset: string.replace(x, "$toolset", t), r)
r = map(lambda x, t=self.toolset: string.replace(x, "$toolset", t+"*"), r)
return r
def native_file_name(self, name):

View File

@@ -1,119 +0,0 @@
#!/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 the 'glob' rule in Jamfile context.
from BoostBuild import Tester, List
import os
import string
# Create a temporary working directory
t = Tester()
t.write("project-root.jam", """
""")
t.write("Jamfile", """
""")
t.write("d1/a.cpp", """
int main() { return 0; }
""")
t.write("d1/Jamfile", """
exe a : [ glob *.cpp ] ../d2/d//l ;
""")
t.write("d2/d/l.cpp", """
#if defined(_WIN32)
__declspec(dllexport)
void force_import_lib_creation() {}
#endif
""")
t.write("d2/d/Jamfile", """
lib l : [ glob *.cpp ] ;
""")
t.write("d3/d/Jamfile", """
exe a : [ glob ../*.cpp ] ;
""")
t.write("d3/a.cpp", """
int main()
{
return 0;
}
""")
t.run_build_system(subdir="d1")
t.expect_addition("d1/bin/$toolset/debug/a.exe")
t.run_build_system(subdir="d3/d")
t.expect_addition("d3/d/bin/$toolset/debug/a.exe")
t.rm("d2/d/bin")
t.run_build_system(subdir="d2/d")
t.expect_addition("d2/d/bin/$toolset/debug/l.dll")
# Test that when 'source-location' is explicitly-specified
# glob works relatively to source location
t.rm("d1")
t.write("d1/src/a.cpp", """
int main() { return 0; }
""")
t.write("d1/Jamfile", """
project : source-location src ;
exe a : [ glob *.cpp ] ../d2/d//l ;
""")
t.run_build_system(subdir="d1")
t.expect_addition("d1/bin/$toolset/debug/a.exe")
# Test that wildcards can include directories
t.rm("d1")
t.write("d1/src/foo/a.cpp", """
void bar();
int main() { bar(); return 0; }
""")
t.write("d1/src/bar/b.cpp", """
void bar() {}
""")
t.write("d1/Jamfile", """
project : source-location src ;
exe a : [ glob foo/*.cpp bar/*.cpp ] ../d2/d//l ;
""")
t.run_build_system(subdir="d1")
t.expect_addition("d1/bin/$toolset/debug/a.exe")
# Test that 'glob' works with absolute names
t.rm("d1/bin")
# Note that to get current dir, we use bjam's PWD,
# not Python's os.getcwd, because the former will
# always return long path. The latter might return
# short path, and that will confuse path.glob.
t.write("d1/Jamfile", """
project : source-location src ;
local pwd = [ PWD ] ; # Always absolute
exe a : [ glob $(pwd)/src/foo/*.cpp $(pwd)/src/bar/*.cpp ] ../d2/d//l ;
""")
t.run_build_system(subdir="d1")
t.expect_addition("d1/bin/$toolset/debug/a.exe")
t.cleanup()

View File

@@ -1,3 +1,7 @@
# Copyright 2002-2005 Vladimir Prus.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import gcc ;
import property ;
@@ -7,10 +11,10 @@ rule properties-as-path ( properties * )
local r ;
for local p in $(properties)
{
if $(p:G) != <action>
{
r += $(p) ;
}
if $(p:G) != <action>
{
r += $(p) ;
}
}
return [ property.as-path
[ property.remove incidental : $(r) ] ] ;

View File

@@ -1,9 +1,9 @@
#!/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.
# Copyright (C) Vladimir Prus 2003.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Test for the regression testing framework.
from BoostBuild import Tester, List
@@ -74,7 +74,7 @@ t.expect_addition("bin/r-f.test/$toolset/debug/r-f.test")
# Make sure args are handled.
t.expect_content("bin/r.test/$toolset/debug/r.output",
"foo\nbar\n\nEXIT STATUS: 0\n")
"foo\nbar\n\nEXIT STATUS: 0\n",True)
# Test that input file is handled as well.
t.write("r.cpp", """

View File

@@ -1,4 +1,11 @@
#!/usr/bin/python
# Copyright 2002-2005 Dave Abrahams.
# Copyright 2002-2006 Vladimir Prus.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
import os, sys, string
from BoostBuild import get_toolset
@@ -112,7 +119,7 @@ tests = [ "rebuilds",
"suffix",
"inherit_toolset",
"skipping",
"glob",
"project_glob",
"project_root_constants",
"double_loading",
"dll_path",