[testing] Collect test duration
We will be able to collect test duration and later upload them in BQ. Change-Id: Ie5610d4e872259857bf3f26ba698fa65d23058be Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2020952 Reviewed-by: Tamer Tas <tmrts@chromium.org> Commit-Queue: Liviu Rau <liviurau@chromium.org> Cr-Commit-Position: refs/heads/master@{#66040}
This commit is contained in:
parent
e920b2e351
commit
b9a690f38c
@ -345,6 +345,8 @@ class BaseTestRunner(object):
|
||||
"color, mono)")
|
||||
parser.add_option("--json-test-results",
|
||||
help="Path to a file for storing json results.")
|
||||
parser.add_option('--json-test-times',
|
||||
help='Path to a file for storing json test times.')
|
||||
parser.add_option("--exit-after-n-failures", type="int", default=100,
|
||||
help="Exit after the first N failures instead of "
|
||||
"running all tests. Pass 0 to disable this feature.")
|
||||
@ -792,7 +794,6 @@ class BaseTestRunner(object):
|
||||
if options.json_test_results:
|
||||
procs.append(progress.JsonTestProgressIndicator(
|
||||
self.framework_name,
|
||||
options.json_test_results,
|
||||
self.build_config.arch,
|
||||
self.mode_options.execution_mode))
|
||||
|
||||
|
@ -317,7 +317,7 @@ class MonochromeProgressIndicator(CompactProgressIndicator):
|
||||
|
||||
|
||||
class JsonTestProgressIndicator(ProgressIndicator):
|
||||
def __init__(self, framework_name, json_test_results, arch, mode):
|
||||
def __init__(self, framework_name, arch, mode):
|
||||
super(JsonTestProgressIndicator, self).__init__()
|
||||
# We want to drop stdout/err for all passed tests on the first try, but we
|
||||
# need to get outputs for all runs after the first one. To accommodate that,
|
||||
@ -326,7 +326,6 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
self._requirement = base.DROP_PASS_STDOUT
|
||||
|
||||
self.framework_name = framework_name
|
||||
self.json_test_results = json_test_results
|
||||
self.arch = arch
|
||||
self.mode = mode
|
||||
self.results = []
|
||||
@ -372,8 +371,8 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
|
||||
def finished(self):
|
||||
complete_results = []
|
||||
if os.path.exists(self.json_test_results):
|
||||
with open(self.json_test_results, "r") as f:
|
||||
if os.path.exists(self.options.json_test_results):
|
||||
with open(self.options.json_test_results, "r") as f:
|
||||
# On bots we might start out with an empty file.
|
||||
complete_results = json.loads(f.read() or "[]")
|
||||
|
||||
@ -386,15 +385,7 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
|
||||
# Sort tests by duration.
|
||||
self.tests.sort(key=lambda __duration_cmd: __duration_cmd[1], reverse=True)
|
||||
slowest_tests = [
|
||||
{
|
||||
"name": str(test),
|
||||
"flags": cmd.args,
|
||||
"command": cmd.to_string(relative=True),
|
||||
"duration": duration,
|
||||
"marked_slow": test.is_slow,
|
||||
} for (test, duration, cmd) in self.tests[:20]
|
||||
]
|
||||
slowest_tests = self._test_records(self.tests[:20])
|
||||
|
||||
complete_results.append({
|
||||
"arch": self.arch,
|
||||
@ -405,5 +396,24 @@ class JsonTestProgressIndicator(ProgressIndicator):
|
||||
"test_total": len(self.tests),
|
||||
})
|
||||
|
||||
with open(self.json_test_results, "w") as f:
|
||||
with open(self.options.json_test_results, "w") as f:
|
||||
f.write(json.dumps(complete_results))
|
||||
|
||||
self._save_test_times()
|
||||
|
||||
def _test_records(self, tests):
|
||||
return [
|
||||
{
|
||||
"name": str(test),
|
||||
"flags": cmd.args,
|
||||
"command": cmd.to_string(relative=True),
|
||||
"duration": duration,
|
||||
"marked_slow": test.is_slow,
|
||||
} for (test, duration, cmd) in tests
|
||||
]
|
||||
|
||||
def _save_test_times(self):
|
||||
if self.options.json_test_times:
|
||||
test_times = self._test_records(self.tests)
|
||||
with open(self.options.json_test_times, "w") as f:
|
||||
f.write(json.dumps(test_times))
|
||||
|
Loading…
Reference in New Issue
Block a user