]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/builtin_glob.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / tools / build / test / builtin_glob.py
1 #!/usr/bin/python
2
3 # Copyright 2014 Steven Watanabe
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
6
7 # This tests the GLOB rule.
8
9 import os
10 import BoostBuild
11
12 def test_glob(files, glob, expected, setup=""):
13 t = BoostBuild.Tester(["-ffile.jam"], pass_toolset=0)
14 t.write("file.jam", setup + """
15 for local p in [ SORT %s ]
16 {
17 ECHO $(p) ;
18 }
19 UPDATE ;
20 """ % glob)
21 for f in files:
22 t.write(f, "")
23 # convert / into \ on windows
24 expected = [os.path.join(*p.split("/")) for p in expected]
25 expected.sort()
26 t.run_build_system(stdout="\n".join(expected + [""]))
27 t.cleanup()
28
29 # one or both arguments empty
30 test_glob([], "[ GLOB : ]", [])
31 test_glob([], "[ GLOB . : ]", [])
32 test_glob([], "[ GLOB : * ]", [])
33
34 # a single result
35 test_glob([], "[ GLOB . : * ]", ["./file.jam"])
36
37 # * can match any number of characters
38 test_glob([], "[ GLOB . : file*.jam ]", ["./file.jam"])
39 test_glob([], "[ GLOB . : f*am ]", ["./file.jam"])
40 # ? should match a single character, but not more than one
41 test_glob([], "[ GLOB . : fi?e.?am ]", ["./file.jam"])
42 test_glob([], "[ GLOB . : fi?.jam ]", [])
43 # [abc-fh-j] matches a set of characters
44 test_glob([], '[ GLOB . : "[f][i][l][e].jam" ]', ["./file.jam"])
45 test_glob([], '[ GLOB . : "[fghau][^usdrwe][k-o][^f-s].jam" ]', ["./file.jam"])
46 # \x matches x
47 test_glob([], "[ GLOB . : \\f\\i\\l\\e.jam ]", ["./file.jam"])
48
49 # multiple results
50 test_glob(["test.txt"], "[ GLOB . : * ]", ["./file.jam", "./test.txt"])
51
52 # directories
53 test_glob(["dir1/dir2/test.txt"], "[ GLOB dir1 : * ]", ["dir1/dir2"]);
54
55 # non-existent directory
56 test_glob([], "[ GLOB dir1 : * ] ", [])
57
58 # multiple directories and patterns
59 test_glob(["dir1/file1.txt", "dir2/file1.txt",
60 "dir2/file2.txt"],
61 "[ GLOB dir1 dir2 : file1* file2* ]",
62 ["dir1/file1.txt", "dir2/file1.txt",
63 "dir2/file2.txt"])
64
65 # The directory can contain . and ..
66 test_glob(["dir/test.txt"], "[ GLOB dir/. : test.txt ]", ["dir/./test.txt"])
67 test_glob(["dir/test.txt"], "[ GLOB dir/.. : file.jam ]", ["dir/../file.jam"])
68
69 # On case insensitive filesystems, the result should
70 # be normalized. It should NOT be downcased.
71 test_glob(["TEST.TXT"], "[ GLOB . : TEST.TXT ]", ["./TEST.TXT"])
72
73 case_insensitive = (os.path.normcase("FILE") == "file")
74
75 if case_insensitive:
76 test_glob(["TEST.TXT"], "[ GLOB . : test.txt ]", ["./TEST.TXT"])
77 # This used to fail because the caching routines incorrectly
78 # reported that . and .. do not exist.
79 test_glob(["D1/D2/TEST.TXT"], "[ GLOB D1/./D2 : test.txt ]",
80 ["D1/./D2/TEST.TXT"])
81 test_glob(["D1/TEST.TXT", "TEST.TXT"], "[ GLOB D1/../D1 : test.txt ]",
82 ["D1/../D1/TEST.TXT"])
83 # This also failed because directories that were first found
84 # by GLOB were recorded as non-existent.
85 test_glob(["D1/D2/TEST.TXT"], "[ GLOB d1/d2 : test.txt ]",
86 ["D1/D2/TEST.TXT"],
87 "GLOB . : * ;")