diff options
author | Chad Versace <chad@chad-versace.us> | 2011-07-18 19:10:36 -0700 |
---|---|---|
committer | Chad Versace <chad@chad-versace.us> | 2011-07-29 17:23:03 -0700 |
commit | 84544ba918cbd0c20bf84cc9e228ad7f844ad4d5 (patch) | |
tree | 42042f4672e36380e1bfcc11a34c570e3cb53f08 /piglit-run.py | |
parent | 9f54e57ba100542fec6f326c4003e69cc6d88dc9 (diff) |
framework: Write each test result to the result file as the test completes
When a test run is interrupted, perhaps by a system crash, we often want
the test results. To accomplish this, Piglit must write each test result
to the result file as the test completes.
If the test run is interrupted, the result file will be corrupt. This is
corrected in a subsequent commit.
CC: Ian Romanick <ian.d.romanick@intel.com>
Signed-off-by: Chad Versace <chad@chad-versace.us>
Diffstat (limited to 'piglit-run.py')
-rwxr-xr-x | piglit-run.py | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/piglit-run.py b/piglit-run.py index d5e85f893..0771ede85 100755 --- a/piglit-run.py +++ b/piglit-run.py @@ -23,7 +23,6 @@ from getopt import getopt, GetoptError -import json import os.path as path import re import sys, os @@ -132,31 +131,27 @@ def main(): else: results.name = OptionName - results.__dict__.update(env.collectData()) + # Begin json. + result_filepath = os.path.join(resultsDir, 'main') + json_writer = core.JSONWriter(SyncFileWriter(result_filepath)) + json_writer.open_dict() + + json_writer.write_dict_item('name', results.name) + for (key, value) in env.collectData().items(): + json_writer.write_dict_item(key, value) profile = core.loadTestProfile(profileFilename) time_start = time.time() - try: - profile.run(env, results) - except Exception as e: - if isinstance(e, KeyboardInterrupt): - # When the user interrupts the test run, he may still - # want the partial test results. So ignore - # KeyboardInterruption and proceed to writing the - # result files. - pass - else: - traceback.print_exc() - sys.exit(1) + profile.run(env, json_writer) time_end = time.time() results.time_elapsed = time_end - time_start + json_writer.write_dict_item('time_elapsed', results.time_elapsed) - result_filepath = os.path.join(resultsDir, 'main') - print("Writing results file...") - with open(result_filepath, 'w') as f: - results.write(f) + # End json. + json_writer.close_dict() + json_writer.file.close() print print 'Thank you for running Piglit!' |