Add emacs and vim editing settings to the bottom of *.py files.
[scons.git] / test / Repository / Default.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 import os.path
28
29 import TestSCons
30
31 test = TestSCons.TestSCons()
32
33 test.subdir('repository', ['repository', 'subdir'], 'work')
34
35 work_aaa_out = test.workpath('work', 'aaa.out')
36 work_bbb_out = test.workpath('work', 'bbb.out')
37 work_ccc_out = test.workpath('work', 'ccc.out')
38 work_subdir_ddd_out = test.workpath('work', 'subdir', 'ddd.out')
39 work_subdir_eee_out = test.workpath('work', 'subdir', 'eee.out')
40 work_subdir_fff_out = test.workpath('work', 'subdir', 'fff.out')
41
42 opts = "-Y " + test.workpath('repository')
43
44 #
45 test.write(['repository', 'SConstruct'], r"""
46 def copy(env, source, target):
47     source = str(source[0])
48     target = str(target[0])
49     print 'copy() < %s > %s' % (source, target)
50     open(target, "wb").write(open(source, "rb").read())
51
52 Build = Builder(action=copy)
53 env = Environment(BUILDERS={'Build':Build})
54 env.Build('aaa.out', 'aaa.in')
55 env.Build('bbb.out', 'bbb.in')
56 env.Build('ccc.out', 'ccc.in')
57 Default('bbb.out')
58 SConscript('subdir/SConscript', "env")
59 """)
60
61 test.write(['repository', 'subdir', 'SConscript'], r"""
62 Import("env")
63 Default('eee.out')
64 env.Build('ddd.out', 'ddd.in')
65 env.Build('eee.out', 'eee.in')
66 env.Build('fff.out', 'fff.in')
67 """)
68
69 test.write(['repository', 'aaa.in'], "repository/aaa.in\n")
70 test.write(['repository', 'bbb.in'], "repository/bbb.in\n")
71 test.write(['repository', 'ccc.in'], "repository/ccc.in\n")
72 test.write(['repository', 'subdir', 'ddd.in'], "repository/subdir/ddd.in\n")
73 test.write(['repository', 'subdir', 'eee.in'], "repository/subdir/eee.in\n")
74 test.write(['repository', 'subdir', 'fff.in'], "repository/subdir/fff.in\n")
75
76 # Make the entire repository non-writable, so we'll detect
77 # if we try to write into it accidentally.
78 test.writable('repository', 0)
79
80 test.run(chdir = 'work', options = opts, arguments = '')
81
82 test.fail_test(os.path.exists(work_aaa_out))
83 test.fail_test(test.read(work_bbb_out) != "repository/bbb.in\n")
84 test.fail_test(os.path.exists(work_ccc_out))
85 test.fail_test(os.path.exists(work_subdir_ddd_out))
86 test.fail_test(test.read(work_subdir_eee_out) != "repository/subdir/eee.in\n")
87 test.fail_test(os.path.exists(work_subdir_fff_out))
88
89 #
90 test.run(chdir = 'work', options = opts, arguments = '.')
91
92 test.fail_test(test.read(work_aaa_out) != "repository/aaa.in\n")
93 test.fail_test(test.read(work_ccc_out) != "repository/ccc.in\n")
94 test.fail_test(test.read(work_subdir_ddd_out) != "repository/subdir/ddd.in\n")
95 test.fail_test(test.read(work_subdir_fff_out) != "repository/subdir/fff.in\n")
96
97 test.up_to_date(chdir = 'work', options = opts, arguments = '.')
98
99 #
100 test.pass_test()
101
102 # Local Variables:
103 # tab-width:4
104 # indent-tabs-mode:nil
105 # End:
106 # vim: set expandtab tabstop=4 shiftwidth=4: