Merge pull request #4650 from Repiteo/node-explicit-types
[scons.git] / test / Install / option--install-sandbox.py
blobbb64c3464e3563e3dd950dd44984737b8f9bbf95
1 #!/usr/bin/env python
3 # MIT Licenxe
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Test the --install-sandbox commandline option for Install() and InstallAs().
28 """
30 import os.path
32 import TestSCons
34 test = TestSCons.TestSCons()
36 test.subdir('install', 'subdir')
37 target = 'destination'
38 destdir = test.workpath( target )
39 _SUBDIR_file3_out = os.path.join('$SUBDIR', 'file3.out')
40 _SUBDIR_file3_in = os.path.join('$SUBDIR', 'file3.in')
42 target_file2_out = os.path.join(target, 'file2.out')
43 subdir_file3_in = os.path.join('subdir', 'file3.in')
44 target_subdir_file3_out = os.path.join(target, 'subdir', 'file3.out')
45 file1_out = target + os.path.join(target, os.path.splitdrive(destdir)[1], 'file1.out')
47 test.write('SConstruct', r"""
48 DefaultEnvironment(tools=[])
49 env = Environment(tools=[], SUBDIR='subdir')
50 f1 = env.Install(r'%(destdir)s', 'file1.out')
51 f2 = env.InstallAs(['file2.out', r'%(_SUBDIR_file3_out)s'],
52 ['file2.in', r'%(_SUBDIR_file3_in)s'])
53 env.Depends(f2, f1)
54 """ % locals())
56 test.write('file1.out', "file1.out\n")
57 test.write('file2.in', "file2.in\n")
58 test.write(['subdir', 'file3.in'], "subdir/file3.in\n")
60 expect = test.wrap_stdout("""\
61 Install file: "file1.out" as "%(file1_out)s"
62 Install file: "file2.in" as "%(target_file2_out)s"
63 Install file: "%(subdir_file3_in)s" as "%(target_subdir_file3_out)s"
64 """ % locals())
66 test.run(arguments = '--install-sandbox=%s' % destdir, stdout=expect)
68 test.must_match(file1_out, "file1.out\n")
69 test.must_match('destination/file2.out', "file2.in\n")
70 test.must_match('destination/subdir/file3.out', "subdir/file3.in\n")
73 test.pass_test()
75 # Local Variables:
76 # tab-width:4
77 # indent-tabs-mode:nil
78 # End:
79 # vim: set expandtab tabstop=4 shiftwidth=4: