Skip to content

Commit 6d57cd4

Browse files
committed
adjusting output methodology
1 parent b1d3135 commit 6d57cd4

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

scripts/devops_tasks/tox_harness.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ def collect_tox_coverage_files(targeted_packages):
106106
shutil.move(source, dest)
107107

108108

109-
def individual_workload(tox_command_tuple, failed_workload_results):
109+
def individual_workload(tox_command_tuple, workload_results):
110+
pkg = os.path.basename(tox_command_tuple[1])
110111
stdout = os.path.join(tox_command_tuple[1], "stdout.txt")
111112
stderr = os.path.join(tox_command_tuple[1], "stderr.txt")
112-
pkg = os.path.basename(tox_command_tuple[1])
113113
tox_dir = os.path.join(tox_command_tuple[1], './.tox/')
114114

115115
with open(stdout, "w") as f_stdout, open(stderr, "w") as f_stderr:
@@ -124,16 +124,18 @@ def individual_workload(tox_command_tuple, failed_workload_results):
124124
logging.info("POpened task for for {}".format(pkg))
125125
proc.wait()
126126

127-
log_file(stdout)
128-
127+
return_code = proc.returncode
128+
129129
if proc.returncode != 0:
130130
logging.error("{} returned with code {}".format(pkg, proc.returncode))
131-
failed_workload_results[pkg] = proc.returncode
131+
else:
132+
logging.info("{} returned with code 0, output will be printed after the test run completes.".format(pkg))
132133

133134
if read_file(stderr):
134135
logging.error("Package {} had stderror output. Logging.".format(pkg))
135-
failed_workload_results[pkg] = "StdErr output detected"
136-
log_file(stderr)
136+
return_code = "StdErr output detected"
137+
138+
workload_results[tox_command_tuple[1]] = (return_code, stdout, stderr)
137139

138140
if in_ci():
139141
shutil.rmtree(tox_dir)
@@ -143,22 +145,27 @@ def individual_workload(tox_command_tuple, failed_workload_results):
143145

144146
def execute_tox_parallel(tox_command_tuples):
145147
pool = ThreadPool(pool_size)
146-
failed_workload_results = {}
148+
workload_results = {}
147149

148150
for index, cmd_tuple in enumerate(tox_command_tuples):
149-
pool.add_task(individual_workload, cmd_tuple, failed_workload_results)
151+
pool.add_task(individual_workload, cmd_tuple, workload_results)
150152

151153
pool.wait_completion()
152154

153-
if len(failed_workload_results.keys()):
154-
for key in failed_workload_results.keys():
155+
failed_run = False
156+
157+
for key in workload_results.keys():
158+
log_file(workload_results[key][1])
159+
160+
if workload_results[key][0] != 0:
155161
logging.error(
156162
"{} tox invocation exited with returncode {}".format(
157-
key, failed_workload_results[key]
163+
os.path.basename(key), workload_results[key]
158164
)
159165
)
160-
exit(1)
161166

167+
if failed_run:
168+
exit(1)
162169

163170
def execute_tox_serial(tox_command_tuples):
164171
for index, cmd_tuple in enumerate(tox_command_tuples):
@@ -218,7 +225,6 @@ def prep_and_run_tox(targeted_packages, parsed_args, options_array=[]):
218225
if local_options_array:
219226
tox_execution_array.extend(["--"] + local_options_array)
220227

221-
# 0 = command array
222228
tox_command_tuples.append((tox_execution_array, package_dir))
223229

224230
if parsed_args.tparallel:

0 commit comments

Comments
 (0)