diff --git a/src/engine/pathnt.c b/src/engine/pathnt.c index 8abf8fe7bd..412f5f4b50 100644 --- a/src/engine/pathnt.c +++ b/src/engine/pathnt.c @@ -175,6 +175,10 @@ static int canonicWindowsPath( char const * const path, int const path_length, return 1; } } + else + { + return 1; + } } return 0; } @@ -243,7 +247,10 @@ static path_key_entry * path_key( OBJECT * const path, { nresult->path = normalized; if ( known_to_be_canonic ) + { nresult->key = object_copy( path ); + nresult->exists = 1; + } else { string canonic_path[ 1 ]; diff --git a/test/builtin_glob.py b/test/builtin_glob.py new file mode 100755 index 0000000000..6f55a4d9c1 --- /dev/null +++ b/test/builtin_glob.py @@ -0,0 +1,87 @@ +#!/usr/bin/python + +# Copyright 2014 Steven Watanabe +# 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) + +# This tests the GLOB rule. + +import os +import BoostBuild + +def test_glob(files, glob, expected, setup=""): + t = BoostBuild.Tester(["-ffile.jam"], pass_toolset=0) + t.write("file.jam", setup + """ + for local p in [ SORT %s ] + { + ECHO $(p) ; + } + UPDATE ; + """ % glob) + for f in files: + t.write(f, "") + # convert / into \ on windows + expected = [os.path.join(*p.split("/")) for p in expected] + expected.sort() + t.run_build_system(stdout="\n".join(expected + [""])) + t.cleanup() + +# one or both arguments empty +test_glob([], "[ GLOB : ]", []) +test_glob([], "[ GLOB . : ]", []) +test_glob([], "[ GLOB : * ]", []) + +# a single result +test_glob([], "[ GLOB . : * ]", ["./file.jam"]) + +# * can match any number of characters +test_glob([], "[ GLOB . : file*.jam ]", ["./file.jam"]) +test_glob([], "[ GLOB . : f*am ]", ["./file.jam"]) +# ? should match a single character, but not more than one +test_glob([], "[ GLOB . : fi?e.?am ]", ["./file.jam"]) +test_glob([], "[ GLOB . : fi?.jam ]", []) +# [abc-fh-j] matches a set of characters +test_glob([], "[ GLOB . : [f][i][l][e].jam ]", ["./file.jam"]) +test_glob([], "[ GLOB . : [fghau][^usdrwe][k-o][^f-s].jam ]", ["./file.jam"]) +# \x matches x +test_glob([], "[ GLOB . : \\f\\i\\l\\e.jam ]", ["./file.jam"]) + +# multiple results +test_glob(["test.txt"], "[ GLOB . : * ]", ["./file.jam", "./test.txt"]) + +# directories +test_glob(["dir1/dir2/test.txt"], "[ GLOB dir1 : * ]", ["dir1/dir2"]); + +# non-existent directory +test_glob([], "[ GLOB dir1 : * ] ", []) + +# multiple directories and patterns +test_glob(["dir1/file1.txt", "dir2/file1.txt", + "dir2/file2.txt"], + "[ GLOB dir1 dir2 : file1* file2* ]", + ["dir1/file1.txt", "dir2/file1.txt", + "dir2/file2.txt"]) + +# The directory can contain . and .. +test_glob(["dir/test.txt"], "[ GLOB dir/. : test.txt ]", ["dir/./test.txt"]) +test_glob(["dir/test.txt"], "[ GLOB dir/.. : file.jam ]", ["dir/../file.jam"]) + +# On case insensitive filesystems, the result should +# be normalized. It should NOT be downcased. +test_glob(["TEST.TXT"], "[ GLOB . : TEST.TXT ]", ["./TEST.TXT"]) + +case_insensitive = (os.path.normcase("FILE") == "file") + +if case_insensitive: + test_glob(["TEST.TXT"], "[ GLOB . : test.txt ]", ["./TEST.TXT"]) + # This used to fail because the caching routines incorrectly + # reported that . and .. do not exist. + test_glob(["D1/D2/TEST.TXT"], "[ GLOB D1/./D2 : test.txt ]", + ["D1/./D2/TEST.TXT"]) + test_glob(["D1/TEST.TXT", "TEST.TXT"], "[ GLOB D1/../D1 : test.txt ]", + ["D1/../D1/TEST.TXT"]) + # This also failed because directories that were first found + # by GLOB were recorded as non-existent. + test_glob(["D1/D2/TEST.TXT"], "[ GLOB d1/d2 : test.txt ]", + ["D1/D2/TEST.TXT"], + "GLOB . : * ;") diff --git a/test/test_all.py b/test/test_all.py index 02b7bd83ba..8fa522d1ea 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -166,6 +166,7 @@ def reorder_tests(tests, first_test): "build_no", "builtin_echo", "builtin_exit", + "builtin_glob", "builtin_split_by_characters", "c_file", "chain",