Repository navigation
Do not reuse tempfiles - #3140
simontegelid wants to merge 0 commit into
Conversation
|
Did you mean ".. in either the target nor the source attributes since those are common for all actions." |
|
Can you provide an example SConstruct to demonstrate the problem? |
|
If the |
|
Bringing it to the users mailing list allows more eyes on the issue and potentially understanding why the code is as it is. Here's the email regarding the previous changes which you've altered. Are those issues re-broken by your changes? |
|
Yes, as I mentioned "not reusing tempfiles will create unneeded tempfiles on strfunction invocation" but the current solution is producing incorrect results. I will bring it to the users mailing list for discussion. |
|
The users mailing list didn't get much attention. The solution for the duplicate tempfiles are not correct imo, since it gives incorrect builds for the test case I added. Any ideas how we can solve that in another way? |
|
Would:
Be a better description than:
Also note as is the test fails against current master branch with missing xxx.py and yyy.py. Also. I don't think the test captures checking that the tempfile for each action has a different name? Seems like an optimal solution would have a single temp file for each item in an action list? |
|
Here's an updated test which is still not going to catch if the tempfiles are named, but seems to run.. #!/usr/bin/env python
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
Verify that using $TEMPFILE in multiple actions in a
list invokes each command in the list.
"""
import os
import stat
import TestSCons
test = TestSCons.TestSCons(match = TestSCons.match_re)
_python_ = TestSCons._python_
test.write('echo.py', """\
#!/usr/bin/env python
from __future__ import print_function
import sys
print(sys.argv)
""")
echo_py = test.workpath('echo.py')
st = os.stat(echo_py)
os.chmod(echo_py, st[stat.ST_MODE]|0o111)
test.write('SConstruct', """
env = Environment(BUILDCOM=['%(_python_)s echo.py ${TEMPFILE(" -otempfile $SOURCE")}',
'%(_python_)s echo.py second line ${TEMPFILE(" -o$TARGET tempfile")}'],
MAXLINELENGTH=1)
env.Command('file.output', 'file.input', '$BUILDCOM')
"""% locals())
test.write('file.input', "file.input\n")
test.run(arguments = '-n -Q .',
stdout = """\
Using tempfile \\S+ for command line:
-otempfile file.input
%(_python_)s echo.py @\\S+
['echo.py', '-otempfile', @\\S+']
Using tempfile \\S+ for command line:
-ofile.output tempfile
%(_python_)s echo.py second line @\\S+
['echo.py', 'second', 'line', '-otempfile', '@\\S+']
"""%locals())
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4: |
|
Oh, sorry for leaving this behind for a long time. I just rebased it and took a look at the added test. I don't really get the details of how the tests are being run, I just used Running What am I missing? Your proposed test seems more suitable, but I just fail to run it... |
|
The PR was apparently closed when I force-pushed my rebase..? That wasn't my intention. Edit: Pushed the wrong ref... Fixed now. |
Actions lists where each action use
TEMPFILEcannot use the same tempfiles. Therefore we cannot store thetempfile_cmdlistin neither the target nor the source attributes since those are common for all actions.Reusing the same tempfile causes the same command to be invoked for all actions in the list. However, not reusing tempfiles will create unneeded tempfiles on
strfunctioninvocation. This is better than producing incorrect results, but leaves the tempfile in a bad state.Contributor Checklist:
master/src/CHANGES.txtdirectory (and read theREADME.txtin that directory)