Skip to content

Commit

Permalink
validate: launcher: Split test log file handling in Reporter
Browse files Browse the repository at this point in the history
Patch 3/5 to move logfile handling out of Reporter and into Test.
  • Loading branch information
Ramiro Polla authored and tsaunier committed Feb 5, 2015
1 parent b9357e3 commit 177eee7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion validate/launcher/baseclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,11 @@ def run_tests(self, cur_test_num, total_num_tests):
i = cur_test_num
for test in self.tests:
sys.stdout.write("[%d / %d] " % (i + 1, total_num_tests))
self.reporter.before_test(test)
self.reporter.open_logfile(test)
res = test.run()
i += 1
self.reporter.after_test(test)
self.reporter.close_logfile()
if res != Result.PASSED and (self.options.forever or
self.options.fatal_error):
return test.result
Expand Down
4 changes: 3 additions & 1 deletion validate/launcher/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def init_timer(self):
"""Initialize a timer before starting tests."""
self._start_time = time.time()

def before_test(self, test):
def open_logfile(self, test):
path = os.path.join(self.options.logsdir,
test.classname.replace(".", os.sep))
mkdir(os.path.dirname(path))
Expand Down Expand Up @@ -103,6 +103,8 @@ def after_test(self, test):
self.results.append(test)

self.add_results(test)

def close_logfile(self):
if not self.options.redirect_logs:
self.out.close()

Expand Down

2 comments on commit 177eee7

@thiblahute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@thiblahute
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Please sign in to comment.