Skip to content

Commit 45eb277

Browse files
committed
Merge pull request #1290 from practicalswift/fix-indentation-not-multiple-of-four
[Python] Fix "indentation is not a multiple of four"
2 parents 9c37cb6 + e528954 commit 45eb277

File tree

3 files changed

+140
-134
lines changed

3 files changed

+140
-134
lines changed

test/Driver/Dependencies/Inputs/modify-non-primary-files.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
2424
assert sys.argv[1] == '-frontend'
2525

2626
if '-primary-file' in sys.argv:
27-
primaryFileIndex = sys.argv.index('-primary-file') + 1
28-
primaryFile = sys.argv[primaryFileIndex]
27+
primaryFileIndex = sys.argv.index('-primary-file') + 1
28+
primaryFile = sys.argv[primaryFileIndex]
2929

30-
# Modify all files after the primary file.
31-
# Ideally this would modify every non-primary file, but that's harder to
32-
# infer without actually parsing the arguments.
33-
for file in sys.argv[primaryFileIndex + 1:]:
34-
if file.startswith('-'):
35-
break
36-
os.utime(file, None)
30+
# Modify all files after the primary file.
31+
# Ideally this would modify every non-primary file, but that's harder to
32+
# infer without actually parsing the arguments.
33+
for file in sys.argv[primaryFileIndex + 1:]:
34+
if file.startswith('-'):
35+
break
36+
os.utime(file, None)
3737

3838
else:
39-
primaryFile = None
39+
primaryFile = None
4040

4141
outputFile = sys.argv[sys.argv.index('-o') + 1]
4242

@@ -46,6 +46,6 @@
4646
os.utime(outputFile, None)
4747

4848
if primaryFile:
49-
print("Handled", os.path.basename(primaryFile))
49+
print("Handled", os.path.basename(primaryFile))
5050
else:
51-
print("Produced", os.path.basename(outputFile))
51+
print("Produced", os.path.basename(outputFile))

test/Driver/Dependencies/Inputs/update-dependencies.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@
3636
assert sys.argv[1] == '-frontend'
3737

3838
if '-primary-file' in sys.argv:
39-
primaryFile = sys.argv[sys.argv.index('-primary-file') + 1]
40-
depsFile = sys.argv[sys.argv.index('-emit-reference-dependencies-path') + 1]
39+
primaryFile = sys.argv[sys.argv.index('-primary-file') + 1]
40+
depsFile = sys.argv[sys.argv.index(
41+
'-emit-reference-dependencies-path') + 1]
4142

42-
# Replace the dependencies file with the input file.
43-
shutil.copyfile(primaryFile, depsFile)
43+
# Replace the dependencies file with the input file.
44+
shutil.copyfile(primaryFile, depsFile)
4445
else:
45-
primaryFile = None
46+
primaryFile = None
4647

4748
outputFile = sys.argv[sys.argv.index('-o') + 1]
4849

@@ -52,6 +53,6 @@
5253
os.utime(outputFile, None)
5354

5455
if primaryFile:
55-
print("Handled", os.path.basename(primaryFile))
56+
print("Handled", os.path.basename(primaryFile))
5657
else:
57-
print("Produced", os.path.basename(outputFile))
58+
print("Produced", os.path.basename(outputFile))

utils/submit-benchmark-results

100755100644
Lines changed: 120 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ XFAIL = 2
2222

2323
###
2424

25+
2526
def capture_with_result(args, include_stderr=False):
2627
"""capture_with_result(command) -> (output, exit code)
2728
@@ -40,16 +41,19 @@ def capture_with_result(args, include_stderr=False):
4041
out, _ = p.communicate()
4142
return out, p.wait()
4243

44+
4345
def capture(args, include_stderr=False):
4446
"""capture(command) - Run the given command (or argv list) in a shell and
4547
return the standard output."""
4648
return capture_with_result(args, include_stderr)[0]
4749

50+
4851
def timestamp():
4952
return datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
5053

5154
###
5255

56+
5357
def submit_results_to_server(results_data, submit_url):
5458
# Submit the URL encoded data.
5559
data = urllib.urlencode({'input_data': results_data,
@@ -73,121 +77,122 @@ def submit_results_to_server(results_data, submit_url):
7377

7478
###
7579

80+
7681
def main():
77-
parser = optparse.OptionParser("""%prog [options] <results>""")
78-
parser.add_option("", "--submit", dest="submit_url", metavar="URL",
79-
help="Submit results to the given URL",
80-
action="store", type=str, default=None)
81-
parser.add_option("", "--output", dest="output", metavar="PATH",
82-
help="Write raw report data to PATH",
83-
action="store", type=str, default=None)
84-
parser.add_option("", "--machine-name", dest="machine_name", metavar="NAME",
85-
help="Set the machine name to embed in the report",
86-
action="store", type=str, default=None)
87-
parser.add_option("", "--run-order", dest="run_order", metavar="REVISION",
88-
help="Set the run order to embed in the report",
89-
action="store", type=int, default=None)
90-
opts, args = parser.parse_args()
91-
92-
# At least one of --submit or --output is required.
93-
if len(args) != 1:
94-
parser.error("incorrect number of arguments")
95-
if opts.submit_url is None and opts.output is None:
96-
parser.error("no action given (provide --submit or --output)")
97-
if opts.machine_name is None:
98-
parser.error("--machine-name is required")
99-
if opts.run_order is None:
100-
parser.error("--run-order is required")
101-
102-
# Load the results data.
103-
results_path, = args
104-
with open(results_path) as f:
105-
data = json.load(f)
106-
107-
# Compute some data not present in the 'lit' report.
108-
machine_name = opts.machine_name
109-
run_order = str(opts.run_order)
110-
111-
# Estimate the end time as being now, and the start time as being that minus
112-
# the elapsed testing time.
113-
utcnow = datetime.datetime.utcnow()
114-
start_time = utcnow - datetime.timedelta(seconds=data['elapsed'])
115-
end_time = utcnow
116-
117-
# Create the LNT report format.
118-
lnt_results = {}
119-
lnt_results['Machine'] = {
120-
'Name': machine_name,
121-
'Info': {
122-
'hardware': capture(["uname", "-m"], include_stderr=True).strip(),
123-
'name': capture(["uname", "-n"], include_stderr=True).strip(),
124-
'os': capture(["uname", "-sr"], include_stderr=True).strip(),
125-
'uname': capture(["uname", "-a"], include_stderr=True).strip(),
126-
}
127-
}
128-
129-
# FIXME: Record source versions for LLVM, Swift, etc.?
130-
lnt_results['Run'] = {
131-
'Start Time': start_time.strftime('%Y-%m-%d %H:%M:%S'),
132-
'End Time': end_time.strftime('%Y-%m-%d %H:%M:%S'),
133-
'Info': {
134-
'__report_version__': '1',
135-
'tag': 'nts',
136-
'inferred_run_order': run_order,
137-
'run_order': run_order,
138-
'sw_vers': capture(['sw_vers'], include_stderr=True).strip(),
139-
}
140-
}
141-
142-
lnt_results['Tests'] = lnt_tests = []
143-
for test in data['tests']:
144-
# Ignore tests which have unexpected status.
145-
code = test['code']
146-
if code not in ('PASS', 'XPASS', 'FAIL', 'XFAIL'):
147-
sys.stderr.write("ignoring test %r with result code %r" % (
148-
test['name'], code))
149-
continue
150-
151-
# Extract the test name, which is encoded as 'suite :: name'.
152-
test_name = 'nts.%s' % (test['name'].split('::', 1)[1][1:],)
153-
154-
# Convert this test to the 'nts' schema.
155-
compile_success = test['metrics'].get('compile_success', 1)
156-
compile_time = test['metrics']['compile_time']
157-
exec_success = test['metrics'].get('exec_success', 1)
158-
exec_time = test['metrics']['exec_time']
159-
160-
# FIXME: Ensure the test success flags matches the result code.
161-
# FIXME: The XFAIL handling here isn't going to be right.
162-
163-
if not compile_success:
164-
lnt_tests.append({'Name': '%s.compile.status' % (test_name,),
165-
'Info': {},
166-
'Data': [FAIL]})
167-
if not exec_success:
168-
lnt_tests.append({'Name': '%s.exec.status' % (test_name,),
169-
'Info': {},
170-
'Data': [FAIL]})
171-
lnt_tests.append({'Name': '%s.compile' % (test_name,),
172-
'Info': {},
173-
'Data': [compile_time]})
174-
lnt_tests.append({'Name': '%s.exec' % (test_name,),
175-
'Info': {},
176-
'Data': [exec_time]})
177-
178-
# Create the report data.
179-
lnt_result_data = json.dumps(lnt_results, indent=2) + '\n'
180-
181-
# Write the results, if requested.
182-
if opts.output:
183-
sys.stderr.write('%s: generating report: %r\n' % (
184-
timestamp(), opts.output))
185-
with open(opts.output, 'w') as f:
186-
f.write(lnt_result_data)
187-
188-
# Submit the results to an LNT server, if requested.
189-
if opts.submit_url:
190-
submit_results_to_server(lnt_result_data, opts.submit_url)
82+
parser = optparse.OptionParser("""%prog [options] <results>""")
83+
parser.add_option("", "--submit", dest="submit_url", metavar="URL",
84+
help="Submit results to the given URL",
85+
action="store", type=str, default=None)
86+
parser.add_option("", "--output", dest="output", metavar="PATH",
87+
help="Write raw report data to PATH",
88+
action="store", type=str, default=None)
89+
parser.add_option("", "--machine-name", dest="machine_name", metavar="NAME",
90+
help="Set the machine name to embed in the report",
91+
action="store", type=str, default=None)
92+
parser.add_option("", "--run-order", dest="run_order", metavar="REVISION",
93+
help="Set the run order to embed in the report",
94+
action="store", type=int, default=None)
95+
opts, args = parser.parse_args()
96+
97+
# At least one of --submit or --output is required.
98+
if len(args) != 1:
99+
parser.error("incorrect number of arguments")
100+
if opts.submit_url is None and opts.output is None:
101+
parser.error("no action given (provide --submit or --output)")
102+
if opts.machine_name is None:
103+
parser.error("--machine-name is required")
104+
if opts.run_order is None:
105+
parser.error("--run-order is required")
106+
107+
# Load the results data.
108+
results_path, = args
109+
with open(results_path) as f:
110+
data = json.load(f)
111+
112+
# Compute some data not present in the 'lit' report.
113+
machine_name = opts.machine_name
114+
run_order = str(opts.run_order)
115+
116+
# Estimate the end time as being now, and the start time as being that minus
117+
# the elapsed testing time.
118+
utcnow = datetime.datetime.utcnow()
119+
start_time = utcnow - datetime.timedelta(seconds=data['elapsed'])
120+
end_time = utcnow
121+
122+
# Create the LNT report format.
123+
lnt_results = {}
124+
lnt_results['Machine'] = {
125+
'Name': machine_name,
126+
'Info': {
127+
'hardware': capture(["uname", "-m"], include_stderr=True).strip(),
128+
'name': capture(["uname", "-n"], include_stderr=True).strip(),
129+
'os': capture(["uname", "-sr"], include_stderr=True).strip(),
130+
'uname': capture(["uname", "-a"], include_stderr=True).strip(),
131+
}
132+
}
133+
134+
# FIXME: Record source versions for LLVM, Swift, etc.?
135+
lnt_results['Run'] = {
136+
'Start Time': start_time.strftime('%Y-%m-%d %H:%M:%S'),
137+
'End Time': end_time.strftime('%Y-%m-%d %H:%M:%S'),
138+
'Info': {
139+
'__report_version__': '1',
140+
'tag': 'nts',
141+
'inferred_run_order': run_order,
142+
'run_order': run_order,
143+
'sw_vers': capture(['sw_vers'], include_stderr=True).strip(),
144+
}
145+
}
146+
147+
lnt_results['Tests'] = lnt_tests = []
148+
for test in data['tests']:
149+
# Ignore tests which have unexpected status.
150+
code = test['code']
151+
if code not in ('PASS', 'XPASS', 'FAIL', 'XFAIL'):
152+
sys.stderr.write("ignoring test %r with result code %r" % (
153+
test['name'], code))
154+
continue
155+
156+
# Extract the test name, which is encoded as 'suite :: name'.
157+
test_name = 'nts.%s' % (test['name'].split('::', 1)[1][1:],)
158+
159+
# Convert this test to the 'nts' schema.
160+
compile_success = test['metrics'].get('compile_success', 1)
161+
compile_time = test['metrics']['compile_time']
162+
exec_success = test['metrics'].get('exec_success', 1)
163+
exec_time = test['metrics']['exec_time']
164+
165+
# FIXME: Ensure the test success flags matches the result code.
166+
# FIXME: The XFAIL handling here isn't going to be right.
167+
168+
if not compile_success:
169+
lnt_tests.append({'Name': '%s.compile.status' % (test_name,),
170+
'Info': {},
171+
'Data': [FAIL]})
172+
if not exec_success:
173+
lnt_tests.append({'Name': '%s.exec.status' % (test_name,),
174+
'Info': {},
175+
'Data': [FAIL]})
176+
lnt_tests.append({'Name': '%s.compile' % (test_name,),
177+
'Info': {},
178+
'Data': [compile_time]})
179+
lnt_tests.append({'Name': '%s.exec' % (test_name,),
180+
'Info': {},
181+
'Data': [exec_time]})
182+
183+
# Create the report data.
184+
lnt_result_data = json.dumps(lnt_results, indent=2) + '\n'
185+
186+
# Write the results, if requested.
187+
if opts.output:
188+
sys.stderr.write('%s: generating report: %r\n' % (
189+
timestamp(), opts.output))
190+
with open(opts.output, 'w') as f:
191+
f.write(lnt_result_data)
192+
193+
# Submit the results to an LNT server, if requested.
194+
if opts.submit_url:
195+
submit_results_to_server(lnt_result_data, opts.submit_url)
191196

192197
if __name__ == '__main__':
193-
main()
198+
main()

0 commit comments

Comments
 (0)