5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify that the Glob() function finds files in repositories.
33 test = TestSCons.TestSCons()
37 ['repository', 'src'],
38 ['repository', 'src', 'sub1'],
39 ['repository', 'src', 'sub2'])
41 work_aaa = test.workpath('work', 'aaa')
42 work_bbb = test.workpath('work', 'bbb')
43 work_ccc = test.workpath('work', 'ccc')
44 work_src_xxx = test.workpath('work', 'src', 'xxx')
45 work_src_yyy = test.workpath('work', 'src', 'yyy')
47 opts = "-Y " + test.workpath('repository')
49 test.write(['repository', 'SConstruct'], """\
50 def cat(env, source, target):
51 target = str(target[0])
52 f = open(target, "wb")
54 f.write(open(str(src), "rb").read())
57 # Verify that we can glob a repository-only Node that exists
58 # only in memory, not on disk.
59 File('../repository/mmm.in')
61 assert str(m[0]) == 'mmm.in'
63 env = Environment(BUILDERS={'Build':Builder(action=cat)})
64 env.Build('aaa.out', Glob('a*.in'))
65 env.Build('bbb.out', Glob('b*.in'))
66 env.Build('ccc.out', Glob('c*.in'))
67 SConscript('src/SConscript', "env")
70 test.write(['repository', 'aaa.in'], "repository/aaa.in\n")
71 test.write(['repository', 'bbb.in'], "repository/bbb.in\n")
72 test.write(['repository', 'ccc.in'], "repository/ccc.in\n")
74 test.write(['repository', 'src', 'SConscript'], """
76 env.Build('xxx.out', Glob('x*.in'))
77 env.Build('yyy.out', Glob('yy?.in'))
78 zzz_in = Glob('*/zzz.in')
79 zzz_in.sort(lambda a,b: cmp(a.abspath, b.abspath))
80 env.Build('zzz.out', zzz_in)
83 test.write(['repository', 'src', 'xxx.in'], "repository/src/xxx.in\n")
84 test.write(['repository', 'src', 'yyy.in'], "repository/src/yyy.in\n")
85 test.write(['repository', 'src', 'sub1', 'zzz.in'], "repository/src/sub1/zzz.in\n")
86 test.write(['repository', 'src', 'sub2', 'zzz.in'], "repository/src/sub2/zzz.in\n")
89 # Make the repository non-writable,
90 # so we'll detect if we try to write into it accidentally.
91 test.writable('repository', 0)
94 test.run(chdir = 'work', options = opts, arguments = 'aaa.out')
96 test.must_match(['work', 'aaa.out'], "repository/aaa.in\n")
97 test.must_not_exist(test.workpath('work', 'bbb.out'))
98 test.must_not_exist(test.workpath('work', 'ccc.out'))
99 test.must_not_exist(test.workpath('work', 'src', 'xxx.out'))
100 test.must_not_exist(test.workpath('work', 'src', 'yyy.out'))
102 test.run(chdir = 'work', options = opts, arguments = 'bbb.out src')
104 test.must_match(['work', 'bbb.out'], "repository/bbb.in\n")
105 test.must_not_exist(test.workpath('work', 'ccc.out'))
106 test.must_match(['work', 'src', 'xxx.out'], "repository/src/xxx.in\n")
107 test.must_match(['work', 'src', 'yyy.out'], "repository/src/yyy.in\n")
110 repository/src/sub1/zzz.in
111 repository/src/sub2/zzz.in
114 test.must_match(['work', 'src', 'zzz.out'], expect)
117 test.run(chdir = 'work', options = opts, arguments = '.')
119 test.must_match(['work', 'ccc.out'], "repository/ccc.in\n")
126 # indent-tabs-mode:nil
128 # vim: set expandtab tabstop=4 shiftwidth=4: