diff options
author | Mats Wichmann <mats@linux.com> | 2021-04-02 13:43:49 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2021-04-14 21:32:13 (GMT) |
commit | b6e861cc465680f4c1ae5ec3327504da9afd5730 (patch) | |
tree | 48ff81509abb6be7270e6c45cf2286338043ace8 /test/long-lines | |
parent | a20701025fa9f7901396b7d148c5069e86e16944 (diff) | |
download | SCons-b6e861cc465680f4c1ae5ec3327504da9afd5730.zip SCons-b6e861cc465680f4c1ae5ec3327504da9afd5730.tar.gz SCons-b6e861cc465680f4c1ae5ec3327504da9afd5730.tar.bz2 |
Test tweaks to help testing on mingw-only win32 systems
On a system where SCons is started from the mingw bash shell, and
mingw Python is the interpreter, the secondary self-identification differs.
Use that in a few tests which otherwise make the wrong decision.
EnvironmentTests used an invalid value for CCFLAGS, and empty
string is a better choice.
Change a couple of cases where Python code was run directly so
it's prefixed by the-Python-in-use, which fails if there is not
a Windows-registered program for .py files - we didn't really want
to use the Windows-native Python anyway.
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/long-lines')
-rw-r--r-- | test/long-lines/signature.py | 55 |
1 files changed, 34 insertions, 21 deletions
diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index 7f9ba43..68076d4 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # +# MIT License +# # Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining @@ -20,7 +22,6 @@ # 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. -# """ Verify that use of long command lines correctly excludes arguments @@ -36,18 +37,22 @@ test = TestSCons.TestSCons() build_py = test.workpath('build.py') +# create a dummy command which understands a tempfile syntax +# so it doesn't have to be that platform/compiler's specific syntax. test.write(build_py, """\ #!%(_python_)s import sys -if sys.argv[1][0] == '@': - with open(sys.argv[1][1:], 'r') as f: - args = f.read().split() +if sys.argv[1].startswith('@'): + tempfile = sys.argv[1][1:] + with open(tempfile, 'r') as tmp: + args = tmp.read().split() else: args = sys.argv[1:] -with open(args[0], 'w') as fp, open(args[1], 'r') as ifp: - fp.write(ifp.read()) - fp.write('FILEFLAG=%%s\\n' %% args[2]) - fp.write('TIMESTAMP=%%s\\n' %% args[3]) + +with open(args[0], 'w') as ofp, open(args[1], 'r') as ifp: + ofp.write(ifp.read()) + ofp.write('FILEFLAG=%%s\\n' %% args[2]) + ofp.write('TIMESTAMP=%%s\\n' %% args[3]) """ % locals()) os.chmod(build_py, 0o755) @@ -56,21 +61,29 @@ test.write('SConstruct', """\ DefaultEnvironment(tools=[]) arg = 'a_long_ignored_argument' extra_arguments = arg -while len(extra_arguments) <= 1024: +MAXLINE=1024 +while len(extra_arguments) <= MAXLINE: extra_arguments = extra_arguments + ' ' + arg -env = Environment(tools=[], - FILECOM=[r'%(build_py)s', - '$TARGET', '$SOURCE', - '$FILEFLAG', - '$(', '$TIMESTAMP', '$)', - '$EXTRA_ARGUMENTS'], - FILEFLAG=ARGUMENTS.get('FILEFLAG'), - TIMESTAMP=ARGUMENTS.get('TIMESTAMP'), - EXTRA_ARGUMENTS=extra_arguments, - MAXLINELENGTH=1024) +env = Environment( + tools=[], + FILECOM=[ + '%(build_py)s', + '$TARGET', + '$SOURCE', + '$FILEFLAG', + '$(', + '$TIMESTAMP', + '$)', + '$EXTRA_ARGUMENTS', + ], + FILEFLAG=ARGUMENTS.get('FILEFLAG'), + TIMESTAMP=ARGUMENTS.get('TIMESTAMP'), + EXTRA_ARGUMENTS=extra_arguments, + MAXLINELENGTH=MAXLINE, + TEMPFILEPREFIX='@', +) env.PrependENVPath('PATHEXT', '.PY') -env.Command('file.out', 'file.in', - '${TEMPFILE(FILECOM)}') +env.Command('file.out', 'file.in', '%(_python_)s ${TEMPFILE(FILECOM)}') """ % locals()) test.write('file.in', "file.in\n", mode='w') |