Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: tools/isolate/run_test_cases_smoke_test.py

Issue 10831330: Repeat Failed Tests in Serial (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/isolate/run_test_cases.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/isolate/run_test_cases_smoke_test.py
diff --git a/tools/isolate/run_test_cases_smoke_test.py b/tools/isolate/run_test_cases_smoke_test.py
index 62ba92efaa6902213d6ae896d81ee7e88e41814e..21744686cc87406a787edaf26d5025f3594f402e 100755
--- a/tools/isolate/run_test_cases_smoke_test.py
+++ b/tools/isolate/run_test_cases_smoke_test.py
@@ -3,6 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import json
import logging
import os
import re
@@ -16,14 +17,19 @@ sys.path.append(os.path.join(ROOT_DIR, 'data', 'gtest_fake'))
import gtest_fake_base
-def RunTest(test_file):
+def RunTest(test_file, dump_file=None):
target = os.path.join(ROOT_DIR, 'data', 'gtest_fake', test_file)
cmd = [
sys.executable,
os.path.join(ROOT_DIR, 'run_test_cases.py'),
- '--no-dump',
- target,
]
+
+ if dump_file:
+ cmd.extend(['--result', dump_file])
+ else:
+ cmd.append('--no-dump')
+
+ cmd.append(target)
logging.debug(' '.join(cmd))
proc = subprocess.Popen(
cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -39,6 +45,12 @@ class TraceTestCases(unittest.TestCase):
os.environ.pop('GTEST_SHARD_INDEX', '')
os.environ.pop('GTEST_TOTAL_SHARDS', '')
+ self.filename = 'test.results'
+
+ def tearDown(self):
+ if os.path.exists(self.filename):
+ os.remove(self.filename)
+
def _check_results(self, expected_out_re, out, err):
if sys.platform == 'win32':
out = out.replace('\r\n', '\n')
@@ -52,8 +64,20 @@ class TraceTestCases(unittest.TestCase):
self.assertEquals([], lines)
self.assertEquals('', err)
+ def _check_results_file(self, expected_file_contents_entries):
+ self.assertTrue(os.path.exists(self.filename))
+
+ with open(self.filename) as f:
+ file_contents = json.load(f)
+
+ self.assertEqual(len(expected_file_contents_entries), len(file_contents))
+ for (entry_name, entry_count) in expected_file_contents_entries:
+ self.assertTrue(entry_name in file_contents)
+ self.assertEqual(entry_count, len(file_contents[entry_name]))
+
def test_simple_pass(self):
- out, err, return_code = RunTest('gtest_fake_pass.py')
+ out, err, return_code = RunTest('gtest_fake_pass.py',
+ dump_file=self.filename)
self.assertEquals(0, return_code)
@@ -61,37 +85,53 @@ class TraceTestCases(unittest.TestCase):
r'\[\d/\d\] \d\.\d\ds .+',
r'\[\d/\d\] \d\.\d\ds .+',
r'\[\d/\d\] \d\.\d\ds .+',
+ re.escape('Summary:'),
re.escape('Success: 3 100.00%'),
re.escape('Flaky: 0 0.00%'),
re.escape('Fail: 0 0.00%'),
r'\d+\.\ds Done running 3 tests with 3 executions. \d+\.\d test/s',
]
-
self._check_results(expected_out_re, out, err)
+ expected_result_file_entries = [
+ ('Foo.Bar1', 1),
+ ('Foo.Bar2', 1),
+ ('Foo.Bar3', 1)
+ ]
+ self._check_results_file(expected_result_file_entries)
+
def test_simple_fail(self):
- out, err, return_code = RunTest('gtest_fake_fail.py')
+ out, err, return_code = RunTest('gtest_fake_fail.py', self.filename)
self.assertEquals(1, return_code)
- expected_out_re = [
- r'\[\d/\d\] \d\.\d\ds .+',
- r'\[\d/\d\] \d\.\d\ds .+',
- r'\[\d/\d\] \d\.\d\ds .+',
- r'\[\d/\d\] \d\.\d\ds .+',
- r'\[\d/\d\] \d\.\d\ds .+',
- r'\[\d/\d\] \d\.\d\ds .+',
+ test_fail_output = [
re.escape('Note: Google Test filter = Baz.Fail'),
r'',
] + [
- re.escape(l) for l in
- gtest_fake_base.get_test_output('Baz.Fail').splitlines()
+ re.escape(l) for l in
+ gtest_fake_base.get_test_output('Baz.Fail').splitlines()
] + [
'',
] + [
re.escape(l) for l in gtest_fake_base.get_footer(1, 1).splitlines()
] + [
- '',
+ ''
+ ]
+
+ expected_out_re = [
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ ] + test_fail_output + [
+ re.escape('Retrying failed tests serially.'),
+ r'\[\d/\d\] \d\.\d\ds .+',
+ ] + test_fail_output + [
+ re.escape('Summary:'),
+ re.escape('Baz.Fail failed'),
re.escape('Success: 3 75.00%'),
re.escape('Flaky: 0 0.00%'),
re.escape('Fail: 1 25.00%'),
@@ -99,6 +139,14 @@ class TraceTestCases(unittest.TestCase):
]
self._check_results(expected_out_re, out, err)
+ expected_result_file_entries = [
+ ('Foo.Bar1', 1),
+ ('Foo.Bar2', 1),
+ ('Foo.Bar3', 1),
+ ('Baz.Fail', 4)
+ ]
+ self._check_results_file(expected_result_file_entries)
+
def test_simple_gtest_list_error(self):
out, err, return_code = RunTest('gtest_fake_error.py')
« no previous file with comments | « tools/isolate/run_test_cases.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698