Skip to content

Commit 3ac65bd

Browse files
authored
Merge pull request swiftlang#93 from graydon/cperf-initial-error
[run_cperf] Write a comment file with error before running.
2 parents 7da9a18 + 52f2f23 commit 3ac65bd

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

run_cperf

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ def validate_workspace(instance, workspace, args):
6262
% workspace)
6363

6464

65+
def workspace_comment():
66+
if 'WORKSPACE' in os.environ:
67+
workspace = os.environ['WORKSPACE']
68+
print("WORKSPACE: %s" % workspace)
69+
return os.path.join(workspace, 'comment.md')
70+
else:
71+
return None
72+
73+
6574
def main():
6675
common.debug_print('** RUN PULL-REQUEST CPERF **')
6776
os.chdir(os.path.dirname(__file__))
@@ -70,6 +79,11 @@ def main():
7079
instances = [NEW_INSTANCE, OLD_INSTANCE]
7180
configs = get_configs(args.suite)
7281

82+
ws_comment = workspace_comment()
83+
if ws_comment is not None:
84+
with open(ws_comment, 'w') as f:
85+
f.write("Compilation-performance test failed")
86+
7387
for instance in instances:
7488
workspace = get_workspace_for_instance(instance, args)
7589

@@ -85,19 +99,16 @@ def main():
8599

86100
regressions = analyze_results(configs, args)
87101

88-
# Temporary hack to write output to workspace when in CI,
102+
# Crude hack to write output to workspace when in CI,
89103
# regardless of --output passed.
90-
if 'WORKSPACE' in os.environ:
91-
workspace = os.environ['WORKSPACE']
92-
print("WORKSPACE: %s" % workspace)
93-
p = os.path.join(workspace, 'comment.md')
94-
o = os.path.abspath(os.path.join(os.getcwd(),
95-
args.output.name))
96-
print("Output written to: %s" % o)
97-
if o != p:
98-
print("Copying %s to %s" % (o, p))
104+
if ws_comment is not None:
105+
out = os.path.abspath(os.path.join(os.getcwd(),
106+
args.output.name))
107+
print("Output written to: %s" % out)
108+
if out != ws_comment:
109+
print("Copying %s to %s" % (out, ws_comment))
99110
args.output.close()
100-
shutil.copyfile(o, p)
111+
shutil.copyfile(out, ws_comment)
101112

102113
return regressions
103114

0 commit comments

Comments
 (0)