Skip to content

Commit b7e22f7

Browse files
committed
python_unittest.py: save raw txt output as well
1 parent bc10b90 commit b7e22f7

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

graalpython/com.oracle.graal.python.test/src/python_unittests.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@
5454
# constants
5555
PATH_UNITTESTS = "graalpython/lib-python/3/test/"
5656

57-
CSV_RESULTS_NAME = "unittests.csv"
58-
HTML_RESULTS_NAME = "unittests.html"
57+
_BASE_NAME = "unittests"
58+
TXT_RESULTS_NAME = "{}.txt".format(_BASE_NAME)
59+
CSV_RESULTS_NAME = "{}.csv".format(_BASE_NAME)
60+
HTML_RESULTS_NAME = "{}.html".format(_BASE_NAME)
61+
5962

6063
PTRN_ERROR = re.compile(r'^(?P<error>[A-Z][a-z][a-zA-Z]+):(?P<message>.*)$')
6164
PTRN_UNITTEST = re.compile(r'^#### running: graalpython/lib-python/3/test/(?P<unittest>.*)$')
@@ -117,7 +120,7 @@ def scp(results_file_path, destination_path, destination_name=None):
117120

118121

119122
def _run_unittest(test_path):
120-
cmd = ["mx", "python3", "--python.CatchAllExceptions=true", test_path]
123+
cmd = ["mx", "python3", "--python.CatchAllExceptions=true", test_path, "-v"]
121124
success, output = _run_cmd(cmd)
122125
output = '''
123126
##############################################################
@@ -278,6 +281,13 @@ class Stat(object):
278281
TEST_PERCENT_PASS = "test_percent_pass" # percentage of tests which pass from all running tests (all unittests)
279282

280283

284+
def save_as_txt(report_path, results):
285+
with open(report_path, 'w') as TXT:
286+
output = '\n'.join(results)
287+
TXT.write(output)
288+
return output
289+
290+
281291
def save_as_csv(report_path, unittests, error_messages, stats, current_date):
282292
rows = []
283293
with open(report_path, 'w') as CSV:
@@ -595,7 +605,10 @@ def _fmt(t):
595605
unittests = get_unittests(flags.tests_path, limit=flags.limit)
596606

597607
results = run_unittests(unittests)
598-
unittests, error_messages, stats = process_output('\n'.join(results))
608+
txt_report_path = file_name(TXT_RESULTS_NAME, current_date)
609+
output = save_as_txt(txt_report_path, results)
610+
611+
unittests, error_messages, stats = process_output(output)
599612

600613
csv_report_path = file_name(CSV_RESULTS_NAME, current_date)
601614
rows, totals = save_as_csv(csv_report_path, unittests, error_messages, stats, current_date)
@@ -608,6 +621,7 @@ def _fmt(t):
608621

609622
if flags.path:
610623
log("[SAVE] saving results to {} ... ", flags.path)
624+
scp(txt_report_path, flags.path)
611625
scp(csv_report_path, flags.path)
612626
scp(html_report_path, flags.path)
613627

graalpython/com.oracle.graal.python.test/src/tests/test_pyio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,7 @@ def test_builtin_open():
170170
except Exception as e:
171171
print(e)
172172
success = False
173+
finally:
174+
unlink(file_name)
173175

174176
assert success

0 commit comments

Comments
 (0)