Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix bug in pathnt.c that caused the results of GLOB to be downcased u…
…nder some circumstances.
  • Loading branch information
swatanabe committed Mar 24, 2014
1 parent 1a1cb5a commit 9732c69
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/engine/pathnt.c
Expand Up @@ -175,6 +175,10 @@ static int canonicWindowsPath( char const * const path, int const path_length,
return 1;
}
}
else
{
return 1;
}
}
return 0;
}
Expand Down Expand Up @@ -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 ];
Expand Down
87 changes: 87 additions & 0 deletions 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 . : * ;")
1 change: 1 addition & 0 deletions test/test_all.py
Expand Up @@ -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",
Expand Down

0 comments on commit 9732c69

Please sign in to comment.