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

Side by Side Diff: scripts/slave/get_swarm_results_unittest.py

Issue 10035003: Split up Each Swarm Test into Two Steps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import os 6 import os
7 import sys 7 import sys
8 import unittest 8 import unittest
9 9
10 HERE = os.path.dirname(os.path.abspath(__file__)) 10 HERE = os.path.dirname(os.path.abspath(__file__))
11 sys.path.insert(0, os.path.join(HERE, '..', '..', 'site_config')) 11 sys.path.insert(0, os.path.join(HERE, '..', '..', 'site_config'))
12 sys.path.insert(0, os.path.join(HERE, '..')) 12 sys.path.insert(0, os.path.join(HERE, '..'))
13 sys.path.insert(0, HERE) 13 sys.path.insert(0, HERE)
14 14
15 import slave.run_slavelastic as slavelastic 15 import slave.get_swarm_results as swarm_results
16 16
17 17
18 class TestSummaryTest(unittest.TestCase): 18 class TestSummaryTest(unittest.TestCase):
19 def test_correct_output(self): 19 def test_correct_output(self):
20 summary_output = [ 20 summary_output = [
21 ('[ PASSED ] 10 tests.\n' 21 ('[ PASSED ] 10 tests.\n'
22 'YOU HAVE 1 DISABLED TESTS\n' 22 'YOU HAVE 1 DISABLED TESTS\n'
23 'YOU HAVE 1 test with ignored failures (FAILS prefix)'), 23 'YOU HAVE 1 test with ignored failures (FAILS prefix)'),
24 ('[ PASSED ] 10 tests\n' 24 ('[ PASSED ] 10 tests\n'
25 '[ FAILED ] 1 test, listed below:\n' 25 '[ FAILED ] 1 test, listed below:\n'
26 '[ FAILED ] ObserverListThreadSafeTest.RemoveObserver\n' 26 '[ FAILED ] ObserverListThreadSafeTest.RemoveObserver\n'
27 '1 FAILED TEST\n' 27 '1 FAILED TEST\n'
28 'YOU HAVE 2 DISABLED TESTS\n' 28 'YOU HAVE 2 DISABLED TESTS\n'
29 'YOU HAVE 2 test with ignored failures (FAILS prefix)\n')] 29 'YOU HAVE 2 test with ignored failures (FAILS prefix)\n')]
30 30
31 expected_output = ['[ PASSED ] 20 tests.', 31 expected_output = ['[ PASSED ] 20 tests.',
32 '[ FAILED ] failed tests listed below:', 32 '[ FAILED ] failed tests listed below:',
33 '[ FAILED ] ObserverListThreadSafeTest.RemoveObserver', 33 '[ FAILED ] ObserverListThreadSafeTest.RemoveObserver',
34 '1 FAILED TESTS', 34 '1 FAILED TESTS',
35 '3 DISABLED TESTS', 35 '3 DISABLED TESTS',
36 '3 tests with ignored failures (FAILS prefix)'] 36 '3 tests with ignored failures (FAILS prefix)']
37 37
38 summary = slavelastic.TestSummary() 38 summary = swarm_results.TestSummary()
39 39
40 for data in summary_output: 40 for data in summary_output:
41 summary.AddSummaryData(data) 41 summary.AddSummaryData(data)
42 42
43 self.assertEquals(expected_output, summary.Output()) 43 self.assertEquals(expected_output, summary.Output())
44 self.assertEquals(1, summary.exit_code())
45 44
46 def test_correct_all_pass(self): 45 def test_correct_all_pass(self):
47 summary_output = [ 46 summary_output = [
48 ('[ PASSED ] 10 tests.'), 47 ('[ PASSED ] 10 tests.'),
49 ('[ PASSED ] 10 tests')] 48 ('[ PASSED ] 10 tests')]
50 49
51 expected_output = ['[ PASSED ] 20 tests.'] 50 expected_output = ['[ PASSED ] 20 tests.']
52 51
53 summary = slavelastic.TestSummary() 52 summary = swarm_results.TestSummary()
54 53
55 for data in summary_output: 54 for data in summary_output:
56 summary.AddSummaryData(data) 55 summary.AddSummaryData(data)
57 56
58 self.assertEquals(expected_output, summary.Output()) 57 self.assertEquals(expected_output, summary.Output())
59 58
60 def test_test_run_output(self): 59 def test_test_run_output(self):
61 full_output = ('[==========] Running 1 tests from results test run.\n' 60 full_output = ('[==========] Running 1 tests from results test run.\n'
62 '[ RUN ] results.Run Test\n' 61 '[ RUN ] results.Run Test\n'
63 'DONE\n' 62 'DONE\n'
64 '[ OK ] results.Run Test (10 ms)\n\n' 63 '[ OK ] results.Run Test (10 ms)\n\n'
65 '[----------] results summary\n' 64 '[----------] results summary\n'
66 '[==========] 1 tests ran. (10 ms total)\n' 65 '[==========] 1 tests ran. (10 ms total)\n'
67 '[ PASSED ] 1 tests.\n' 66 '[ PASSED ] 1 tests.\n'
68 '[ FAILED ] 0 tests\n\n' 67 '[ FAILED ] 0 tests\n\n'
69 ' 0 FAILED TESTS') 68 ' 0 FAILED TESTS')
70 69
71 cleaned_output = slavelastic.TestRunOutput(full_output) 70 cleaned_output = swarm_results.TestRunOutput(full_output)
72 71
73 self.assertEquals('DONE', cleaned_output) 72 self.assertEquals('DONE', cleaned_output)
74 73
75 if __name__ == '__main__': 74 if __name__ == '__main__':
76 unittest.main() 75 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698