summaryrefslogtreecommitdiff
path: root/bin/SConsExamples.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-24 09:57:09 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-24 09:57:09 +0200
commitc7665433b2004d2b404d6fb9d6fd064998486f63 (patch)
tree8525ef6d24f7c6ceb238945ebb2cc997c7afc905 /bin/SConsExamples.py
parente48d2727885efda8369c7edbc2e3929a59532adc (diff)
parent6e228c305122f0564eda1e67d56651f8386d24d7 (diff)
Merge branch 'release/debian/3.1.0+repack-1'debian/3.1.0+repack-1
Diffstat (limited to 'bin/SConsExamples.py')
-rw-r--r--bin/SConsExamples.py65
1 files changed, 39 insertions, 26 deletions
diff --git a/bin/SConsExamples.py b/bin/SConsExamples.py
index 50c4c1a..7491c58 100644
--- a/bin/SConsExamples.py
+++ b/bin/SConsExamples.py
@@ -39,7 +39,7 @@
# env.Program('foo')
# </file>
# <file name="foo.c">
-# int main() { printf("foo.c\n"); }
+# int main(void) { printf("foo.c\n"); }
# </file>
# </scons_example>
#
@@ -305,6 +305,11 @@ def createAllExampleOutputs(dpath):
examples = readAllExampleInfos(dpath)
total = len(examples)
idx = 0
+
+ if len(sys.argv) > 1:
+ examples_to_run = sys.argv[1:]
+ examples = { k:v for k,v in examples.items() if k in examples_to_run }
+
for key, value in examples.items():
# Process all scons_output tags
print("%.2f%s (%d/%d) %s" % (float(idx + 1) * 100.0 / float(total),
@@ -411,8 +416,8 @@ def exampleNamesAreUnique(dpath):
#
# ###############################################################
-sys.path.append(os.path.join(os.getcwd(), 'QMTest'))
-sys.path.append(os.path.join(os.getcwd(), 'build', 'QMTest'))
+sys.path.append(os.path.join(os.getcwd(), 'testing/framework'))
+sys.path.append(os.path.join(os.getcwd(), 'build', 'testing/framework'))
scons_py = os.path.join('bootstrap', 'src', 'script', 'scons.py')
if not os.path.exists(scons_py):
@@ -657,21 +662,27 @@ SConscript('SConstruct')
"""
# "Commands" that we will execute in our examples.
-def command_scons(args, c, test, dict):
+def command_scons(args, command, test, values):
+ """
+ Fake scons command
+ """
save_vals = {}
delete_keys = []
try:
- ce = c.environment
+ ce = command.environment
except AttributeError:
pass
else:
- for arg in c.environment.split():
+ for arg in command.environment.split():
key, val = arg.split('=')
try:
save_vals[key] = os.environ[key]
except KeyError:
delete_keys.append(key)
os.environ[key] = val
+
+ test.write(test.workpath('WORK/SConstruct_created'), Stdin % values)
+
test.run(interpreter=sys.executable,
program=scons_py,
# We use ToolSurrogates to capture win32 output by "building"
@@ -681,7 +692,7 @@ def command_scons(args, c, test, dict):
# Visual C installed.
arguments='--warn=no-visual-c-missing -f - ' + ' '.join(args),
chdir=test.workpath('WORK'),
- stdin=Stdin % dict)
+ stdin=Stdin % values)
os.environ.update(save_vals)
for key in delete_keys:
del(os.environ[key])
@@ -698,7 +709,7 @@ def command_scons(args, c, test, dict):
# sys.stderr.write(err)
return lines
-def command_touch(args, c, test, dict):
+def command_touch(args, command, test, values):
if args[0] == '-t':
t = int(time.mktime(time.strptime(args[1], '%Y%m%d%H%M')))
times = (t, t)
@@ -714,7 +725,7 @@ def command_touch(args, c, test, dict):
os.utime(file, times)
return []
-def command_edit(args, c, test, dict):
+def command_edit(args, c, test, values):
if c.edit is None:
add_string = 'void edit(void) { ; }\n'
else:
@@ -728,7 +739,7 @@ def command_edit(args, c, test, dict):
open(file, 'wb').write(contents + add_string)
return []
-def command_ls(args, c, test, dict):
+def command_ls(args, c, test, values):
def ls(a):
try:
return [' '.join(sorted([x for x in os.listdir(a) if x[0] != '.']))]
@@ -743,7 +754,7 @@ def command_ls(args, c, test, dict):
else:
return ls(test.workpath('WORK'))
-def command_sleep(args, c, test, dict):
+def command_sleep(args, c, test, values):
time.sleep(int(args[0]))
CommandDict = {
@@ -754,17 +765,19 @@ CommandDict = {
'sleep' : command_sleep,
}
-def ExecuteCommand(args, c, t, dict):
+def ExecuteCommand(args, c, t, values):
try:
func = CommandDict[args[0]]
except KeyError:
- func = lambda args, c, t, dict: []
- return func(args[1:], c, t, dict)
+ func = lambda args, c, t, values: []
+ return func(args[1:], c, t, values)
def create_scons_output(e):
- # The real raison d'etre for this script, this is where we
- # actually execute SCons to fetch the output.
+ """
+ The real raison d'etre for this script, this is where we
+ actually execute SCons to fetch the output.
+ """
# Loop over all outputs for the example
for o in e.outputs:
@@ -837,37 +850,37 @@ def create_scons_output(e):
sroot = stf.newEtreeNode("screen", True)
curchild = None
content = ""
- for c in o.commands:
+ for command in o.commands:
content += Prompt[o.os]
if curchild is not None:
- if not c.output:
+ if not command.output:
# Append content as tail
curchild.tail = content
content = "\n"
# Add new child for userinput tag
curchild = stf.newEtreeNode("userinput")
- d = c.cmd.replace('__ROOT__', '')
+ d = command.cmd.replace('__ROOT__', '')
curchild.text = d
sroot.append(curchild)
else:
- content += c.output + '\n'
+ content += command.output + '\n'
else:
- if not c.output:
+ if not command.output:
# Add first text to root
sroot.text = content
content = "\n"
# Add new child for userinput tag
curchild = stf.newEtreeNode("userinput")
- d = c.cmd.replace('__ROOT__', '')
+ d = command.cmd.replace('__ROOT__', '')
curchild.text = d
sroot.append(curchild)
else:
- content += c.output + '\n'
+ content += command.output + '\n'
# Execute command and capture its output
- cmd_work = c.cmd.replace('__ROOT__', t.workpath('ROOT'))
+ cmd_work = command.cmd.replace('__ROOT__', t.workpath('ROOT'))
args = cmd_work.split()
- lines = ExecuteCommand(args, c, t, {'osname':o.os, 'tools':o.tools})
- if not c.output and lines:
+ lines = ExecuteCommand(args, command, t, {'osname':o.os, 'tools':o.tools})
+ if not command.output and lines:
ncontent = '\n'.join(lines)
ncontent = address_re.sub(r' at 0x700000&gt;', ncontent)
ncontent = engine_re.sub(r' File "bootstrap/src/engine/SCons/', ncontent)