added release.txt blurb. Fixed spelling typo in Defaults.xml
[scons.git] / test / option / option-f.py
bloba2c8561adfc0f2738b464667550eec1a249a3116
1 #!/usr/bin/env python
3 # MIT License
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 import os
28 import TestSCons
30 test = TestSCons.TestSCons()
32 test.subdir('subdir')
34 subdir_BuildThis = os.path.join('subdir', 'Buildthis')
36 test.write('SConscript', """
37 import os
39 DefaultEnvironment(tools=[])
40 print("SConscript " + os.getcwd())
41 """)
43 test.write(subdir_BuildThis, """
44 import os
46 DefaultEnvironment(tools=[])
47 print("subdir/BuildThis " + os.getcwd())
48 """)
50 test.write('Build2', """
51 import os
53 DefaultEnvironment(tools=[])
54 print("Build2 " + os.getcwd())
55 """)
57 wpath = test.workpath()
59 test.run(
60 arguments='-f SConscript .',
61 stdout=test.wrap_stdout(
62 read_str=f'SConscript {wpath}\n',
63 build_str="scons: `.' is up to date.\n"
67 test.run(
68 arguments=f'-f {subdir_BuildThis} .',
69 stdout=test.wrap_stdout(
70 read_str=f'subdir/BuildThis {wpath}\n',
71 build_str="scons: `.' is up to date.\n",
75 test.run(
76 arguments='--file=SConscript .',
77 stdout=test.wrap_stdout(
78 read_str=f'SConscript {wpath}\n',
79 build_str="scons: `.' is up to date.\n"
83 test.run(
84 arguments=f'--file={subdir_BuildThis} .',
85 stdout=test.wrap_stdout(
86 read_str=f'subdir/BuildThis {wpath}\n',
87 build_str="scons: `.' is up to date.\n",
91 test.run(
92 arguments='--makefile=SConscript .',
93 stdout=test.wrap_stdout(
94 read_str=f'SConscript {wpath}\n',
95 build_str="scons: `.' is up to date.\n"
99 test.run(
100 arguments=f'--makefile={subdir_BuildThis} .',
101 stdout=test.wrap_stdout(
102 read_str=f'subdir/BuildThis {wpath}\n',
103 build_str="scons: `.' is up to date.\n",
107 test.run(
108 arguments='--sconstruct=SConscript .',
109 stdout=test.wrap_stdout(
110 read_str=f'SConscript {wpath}\n',
111 build_str="scons: `.' is up to date.\n"
115 test.run(
116 arguments=f'--sconstruct={subdir_BuildThis} .',
117 stdout=test.wrap_stdout(
118 read_str=f'subdir/BuildThis {wpath}\n',
119 build_str="scons: `.' is up to date.\n",
123 test.run(
124 arguments='-f - .',
125 stdin="""
126 DefaultEnvironment(tools=[])
127 import os
128 print("STDIN " + os.getcwd())
129 """,
130 stdout=test.wrap_stdout(
131 read_str=f'STDIN {wpath}\n',
132 build_str="scons: `.' is up to date.\n"
136 expect = test.wrap_stdout(
137 read_str=f'Build2 {wpath}\nSConscript {wpath}\n',
138 build_str="scons: `.' is up to date.\n",
140 test.run(arguments='-f Build2 -f SConscript .', stdout=expect)
142 missing = "no_such_file"
143 test.run(arguments=f"-f {missing} .", status=2, stderr=None)
144 expect = [f"scons: *** missing SConscript file {missing!r}"]
145 test.must_contain_all_lines(test.stderr(), expect)
147 test.pass_test()
149 # Local Variables:
150 # tab-width:4
151 # indent-tabs-mode:nil
152 # End:
153 # vim: set expandtab tabstop=4 shiftwidth=4: