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.
27 Verify that setting the $TEMPFILEPREFIX variable will cause
28 it to appear at the front of name of the generated tempfile
29 used for long command lines.
34 test
= TestSCons
.TestSCons(match
=TestSCons
.match_re
)
36 test
.write('SConstruct', """
40 BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}',
42 TEMPFILEPREFIX='-via',
44 env.AppendENVPath('PATH', os.curdir)
45 env.Command('foo.out', 'foo.in', '$BUILDCOM')
48 test
.write('foo.in', "foo.in\n")
53 Using tempfile \\S+ for command line:
58 test
.write('SConstruct', """
61 def print_cmd_line(s, targets, sources, env):
65 BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}',
67 TEMPFILEPREFIX = '-via',
68 PRINT_CMD_LINE_FUNC=print_cmd_line
70 env.AppendENVPath('PATH', os.curdir)
71 env.Command('foo.out', 'foo.in', '$BUILDCOM')
74 test
.run(arguments
='-n -Q .', stdout
="")
76 test
.write('SConstruct', """
78 from SCons.Platform import TempFileMunge
80 class TestTempFileMunge(TempFileMunge):
81 def __init__(self, cmd, cmdstr=None):
82 super().__init__(cmd, cmdstr)
84 def _print_cmd_str(self, target, source, env, cmdstr):
85 super()._print_cmd_str(target, source, None, cmdstr)
88 TEMPFILE=TestTempFileMunge,
89 BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}',
91 TEMPFILEPREFIX='-via',
93 env.AppendENVPath('PATH', os.curdir)
94 env.Command('foo.out', 'foo.in', '$BUILDCOM')
100 Using tempfile \\S+ for command line:
101 xxx.py foo.out foo.in
105 # make sure an empty prefix works too
106 test
.write('SConstruct', """
108 from SCons.Platform import TempFileMunge
110 class TestTempFileMunge(TempFileMunge):
111 def __init__(self, cmd, cmdstr=None):
112 super().__init__(cmd, cmdstr)
114 def _print_cmd_str(self, target, source, env, cmdstr):
115 super()._print_cmd_str(target, source, None, cmdstr)
118 TEMPFILE=TestTempFileMunge,
119 BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}',
123 env.AppendENVPath('PATH', os.curdir)
124 env.Command('foo.out', 'foo.in', '$BUILDCOM')
130 Using tempfile \\S+ for command line:
131 xxx.py foo.out foo.in
139 # indent-tabs-mode:nil
141 # vim: set expandtab tabstop=4 shiftwidth=4: