summaryrefslogtreecommitdiffstats
path: root/test/sconsign/script/SConsignFile.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/sconsign/script/SConsignFile.py')
-rw-r--r--test/sconsign/script/SConsignFile.py44
1 files changed, 27 insertions, 17 deletions
diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py
index 4e29ef0..569e5e6 100644
--- a/test/sconsign/script/SConsignFile.py
+++ b/test/sconsign/script/SConsignFile.py
@@ -31,15 +31,20 @@ using the signatures in an SConsignFile().
import TestSCons
import TestSConsign
-_python_ = TestSCons._python_
+from TestSCons import _python_
+from TestCmd import NEED_HELPER
test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+if NEED_HELPER:
+ test.skip_test("Test host cannot directly execute scripts, skipping test\n")
+
test.subdir('sub1', 'sub2')
fake_cc_py = test.workpath('fake_cc.py')
fake_link_py = test.workpath('fake_link.py')
-test.write(fake_cc_py, r"""#!%(_python_)s
+test.write(fake_cc_py, fr"""#!{_python_}
import os
import re
import sys
@@ -66,21 +71,23 @@ def process(infp, outfp):
outfp.write(line)
with open(sys.argv[2], 'w') as outf, open(sys.argv[3], 'r') as ifp:
- outf.write('fake_cc.py: %%s\n' %% sys.argv)
+ outf.write('fake_cc.py: %s\n' % sys.argv)
process(ifp, outf)
sys.exit(0)
-""" % locals())
+"""
+)
-test.write(fake_link_py, r"""#!%(_python_)s
+test.write(fake_link_py, fr"""#!{_python_}
import sys
with open(sys.argv[1], 'w') as outf, open(sys.argv[2], 'r') as ifp:
- outf.write('fake_link.py: %%s\n' %% sys.argv)
+ outf.write('fake_link.py: %s\n' % sys.argv)
outf.write(ifp.read())
sys.exit(0)
-""" % locals())
+"""
+)
test.chmod(fake_cc_py, 0o755)
test.chmod(fake_link_py, 0o755)
@@ -96,24 +103,27 @@ sub2_hello_obj = 'sub2/hello.obj'
sub2_inc1_h = 'sub2/inc1.h'
sub2_inc2_h = 'sub2/inc2.h'
-test.write(['SConstruct'], """\
+test.write(['SConstruct'], f"""\
SConsignFile()
env1 = Environment(
PROGSUFFIX='.exe',
OBJSUFFIX='.obj',
- CCCOM=[[r'%(fake_cc_py)s', 'sub2', '$TARGET', '$SOURCE']],
- LINKCOM=[[r'%(fake_link_py)s', '$TARGET', '$SOURCE']],
+ CCCOM=[[r'{fake_cc_py}', 'sub2', '$TARGET', '$SOURCE']],
+ LINKCOM=[[r'{fake_link_py}', '$TARGET', '$SOURCE']],
)
env1.PrependENVPath('PATHEXT', '.PY')
env1.Program('sub1/hello.c')
env2 = env1.Clone(CPPPATH=['sub2'])
env2.Program('sub2/hello.c')
-""" % locals())
+"""
+)
# TODO in the above, we would normally want to run a python program
-# using "our python" as in:
-# CCCOM=[[r'%(_python_)s', r'%(fake_cc_py)s', 'sub2', '$TARGET', '$SOURCE']],
-# LINKCOM=[[r'%(_python_)s', r'%(fake_link_py)s', '$TARGET', '$SOURCE']],
-# however we're looking at dependencies with sconsign, so that breaks things
+# using "our python" like this:
+# CCCOM=[[r'{_python_}', r'{fake_cc_py}', 'sub2', '$TARGET', '$SOURCE']],
+# LINKCOM=[[r'{_python_}', r'{fake_link_py}', '$TARGET', '$SOURCE']],
+# however we're looking at dependencies with sconsign, so that breaks things.
+# It still breaks things on Windows if something else is registered as the
+# handler for .py files, as Visual Studio Code installs itself.
test.write(['sub1', 'hello.c'], r"""
sub1/hello.c
@@ -131,11 +141,11 @@ main(int argc, char *argv[])
}
""")
-test.write(['sub2', 'inc1.h'], r"""\
+test.write(['sub2', 'inc1.h'], r"""
#define STRING1 "inc1.h"
""")
-test.write(['sub2', 'inc2.h'], r"""\
+test.write(['sub2', 'inc2.h'], r"""
#define STRING2 "inc2.h"
""")