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

Side by Side Diff: build/android/pylib/local/device/local_device_test_run_test.py

Issue 1971433002: ABANDONED [Android] Expose each try result in test results JSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 # pylint: disable=protected-access
7
8 import unittest
9
10 from pylib.base import base_test_result
11 from pylib.constants import host_paths
12 from pylib.local.device import local_device_test_run
13
14 with host_paths.SysPath(host_paths.PYMOCK_PATH):
15 import mock # pylint: disable=import-error
16
17
18 class TestLocalDeviceTestRun(local_device_test_run.LocalDeviceTestRun):
19
20 # pylint: disable=abstract-method
21
22 def __init__(self):
23 super(TestLocalDeviceTestRun, self).__init__(
24 mock.MagicMock(), mock.MagicMock())
25
26
27 class LocalDeviceTestRunTest(unittest.TestCase):
28
29 def testGetTestsToRetry_allTestsPassed(self):
30 results = [
31 base_test_result.BaseTestResult(
32 'Test1', base_test_result.ResultType.PASS),
33 base_test_result.BaseTestResult(
34 'Test2', base_test_result.ResultType.PASS),
35 ]
36
37 tests = [r.GetName() for r in results]
38 try_results = base_test_result.TestRunResults()
39 try_results.AddResults(results)
40
41 test_run = TestLocalDeviceTestRun()
42 tests_to_retry = test_run._GetTestsToRetry(tests, try_results)
43 self.assertEquals(0, len(tests_to_retry))
44
45 def testGetTestsToRetry_testFailed(self):
46 results = [
47 base_test_result.BaseTestResult(
48 'Test1', base_test_result.ResultType.FAIL),
49 base_test_result.BaseTestResult(
50 'Test2', base_test_result.ResultType.PASS),
51 ]
52
53 tests = [r.GetName() for r in results]
54 try_results = base_test_result.TestRunResults()
55 try_results.AddResults(results)
56
57 test_run = TestLocalDeviceTestRun()
58 tests_to_retry = test_run._GetTestsToRetry(tests, try_results)
59 self.assertEquals(1, len(tests_to_retry))
60 self.assertIn('Test1', tests_to_retry)
61
62 def testGetTestsToRetry_testUnknown(self):
63 results = [
64 base_test_result.BaseTestResult(
65 'Test2', base_test_result.ResultType.PASS),
66 ]
67
68 tests = ['Test1'] + [r.GetName() for r in results]
69 try_results = base_test_result.TestRunResults()
70 try_results.AddResults(results)
71
72 test_run = TestLocalDeviceTestRun()
73 tests_to_retry = test_run._GetTestsToRetry(tests, try_results)
74 self.assertEquals(1, len(tests_to_retry))
75 self.assertIn('Test1', tests_to_retry)
76
77 def testGetTestsToRetry_wildcardFilter_allPass(self):
78 results = [
79 base_test_result.BaseTestResult(
80 'TestCase.Test1', base_test_result.ResultType.PASS),
81 base_test_result.BaseTestResult(
82 'TestCase.Test2', base_test_result.ResultType.PASS),
83 ]
84
85 tests = ['TestCase.*']
86 try_results = base_test_result.TestRunResults()
87 try_results.AddResults(results)
88
89 test_run = TestLocalDeviceTestRun()
90 tests_to_retry = test_run._GetTestsToRetry(tests, try_results)
91 self.assertEquals(0, len(tests_to_retry))
92
93 def testGetTestsToRetry_wildcardFilter_oneFails(self):
94 results = [
95 base_test_result.BaseTestResult(
96 'TestCase.Test1', base_test_result.ResultType.PASS),
97 base_test_result.BaseTestResult(
98 'TestCase.Test2', base_test_result.ResultType.FAIL),
99 ]
100
101 tests = ['TestCase.*']
102 try_results = base_test_result.TestRunResults()
103 try_results.AddResults(results)
104
105 test_run = TestLocalDeviceTestRun()
106 tests_to_retry = test_run._GetTestsToRetry(tests, try_results)
107 self.assertEquals(1, len(tests_to_retry))
108 self.assertIn('TestCase.Test2', tests_to_retry)
109
110
111 if __name__ == '__main__':
112 unittest.main(verbosity=2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698