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

Unified Diff: tools/isolate/run_test_cases_smoke_test.py

Issue 10825010: Run_test_case.py now returns 1 when at least 1 test fails. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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') | tools/isolate/trace_test_cases_smoke_test.py » ('j') | 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 6cc413a42ab49c03d259725184e50c2eacccc02a..00b552c0daf5ef06fa81aa964c5650a352f79e71 100755
--- a/tools/isolate/run_test_cases_smoke_test.py
+++ b/tools/isolate/run_test_cases_smoke_test.py
@@ -13,7 +13,24 @@ import unittest
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(ROOT_DIR, 'data', 'gtest_fake'))
-import gtest_fake
+import gtest_fake_base
+
+
+def RunTest(test_file):
+ 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,
+ ]
+ logging.debug(' '.join(cmd))
+ proc = subprocess.Popen(
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ # pylint is confused.
+ out, err = proc.communicate() or ('', '')
+
+ return (out, err, proc.returncode)
class TraceTestCases(unittest.TestCase):
@@ -22,23 +39,41 @@ class TraceTestCases(unittest.TestCase):
os.environ.pop('GTEST_SHARD_INDEX', '')
os.environ.pop('GTEST_TOTAL_SHARDS', '')
- def test_simple(self):
- target = os.path.join(ROOT_DIR, 'data', 'gtest_fake', 'gtest_fake.py')
- cmd = [
- sys.executable,
- os.path.join(ROOT_DIR, 'run_test_cases.py'),
- '--no-dump',
- target,
- ]
- logging.debug(' '.join(cmd))
- proc = subprocess.Popen(
- cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- # pylint is confused.
- out, err = proc.communicate() or ('', '')
- self.assertEquals(0, proc.returncode)
+ def _check_results(self, expected_out_re, out, err):
if sys.platform == 'win32':
out = out.replace('\r\n', '\n')
lines = out.splitlines()
+
+ for index in range(len(expected_out_re)):
+ line = lines.pop(0)
+ self.assertTrue(
+ re.match('^%s$' % expected_out_re[index], line),
+ (index, expected_out_re[index], repr(line)))
+ self.assertEquals([], lines)
+ self.assertEquals('', err)
+
+ def test_simple_pass(self):
+ out, err, return_code = RunTest('gtest_fake_pass.py')
+
+ self.assertEquals(0, return_code)
+
+ expected_out_re = [
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ r'\[\d/\d\] \d\.\d\ds .+',
+ 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)
+
+ def test_simple_fail(self):
+ out, err, return_code = RunTest('gtest_fake_fail.py')
+
+ self.assertEquals(1, return_code)
+
expected_out_re = [
r'\[\d/\d\] \d\.\d\ds .+',
r'\[\d/\d\] \d\.\d\ds .+',
@@ -49,11 +84,12 @@ class TraceTestCases(unittest.TestCase):
re.escape('Note: Google Test filter = Baz.Fail'),
r'',
] + [
- re.escape(l) for l in gtest_fake.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.get_footer(1).splitlines()
+ re.escape(l) for l in gtest_fake_base.get_footer(1, 1).splitlines()
] + [
'',
re.escape('Success: 3 75.00%'),
@@ -61,13 +97,7 @@ class TraceTestCases(unittest.TestCase):
re.escape('Fail: 1 25.00%'),
r'\d+\.\ds Done running 4 tests with 6 executions. \d+\.\d test/s',
]
- for index in range(len(expected_out_re)):
- line = lines.pop(0)
- self.assertTrue(
- re.match('^%s$' % expected_out_re[index], line),
- (index, expected_out_re[index], repr(line)))
- self.assertEquals([], lines)
- self.assertEquals('', err)
+ self._check_results(expected_out_re, out, err)
if __name__ == '__main__':
« no previous file with comments | « tools/isolate/run_test_cases.py ('k') | tools/isolate/trace_test_cases_smoke_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698