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

Side by Side Diff: scripts/slave/recipe_modules/swarming/results_merger_unittest.py

Issue 2375663003: Add json test results format support for SwarmingIsolatedScriptTest (Closed)
Patch Set: Fix typos Created 4 years, 2 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 import os
7 import sys
8 import unittest
9
10 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
11
12 # For 'test_env'.
13 sys.path.insert(
14 0, os.path.abspath(os.path.join(THIS_DIR, '..', '..', 'unittests')))
15
16 sys.path.insert(0, os.path.join(THIS_DIR, '..'))
17
18 # Imported for side effects on sys.path.
19 import test_env
20
21 from swarming import results_merger
22
23
24 GOOD_JSON_TEST_RESULT_0 = {
25 'tests': {
26 'car': {
27 'honda': {
28 'expected': 'PASS',
29 'actual': 'PASS'
30 },
31 'toyota': {
32 'expected': 'FAIL',
33 'actual': 'FAIL'
34 }
35 },
36 'computer': {
37 'dell': {
38 'expected': 'PASS',
39 'actual': 'PASS'
40 }
41 },
42 },
43 'interrupted': False,
44 'path_delimiter': '.',
45 'version': 3,
46 'seconds_since_epoch': 1406662289.76,
47 'num_failures_by_type': {
48 'FAIL': 0,
49 'PASS': 2
50 }
51 }
52
53 GOOD_JSON_TEST_RESULT_1 = {
54 'tests': {
55 'car': {
56 'tesla': {
57 'expected': 'PASS',
58 'actual': 'PASS'
59 },
60 },
61 'burger': {
62 'mcdonald': {
63 'expected': 'PASS',
64 'actual': 'PASS'
65 }
66 },
67 },
68 'interrupted': False,
69 'path_delimiter': '.',
70 'version': 3,
71 'seconds_since_epoch': 1406662283.11,
72 'num_failures_by_type': {
73 'FAIL': 0,
74 'PASS': 2
75 }
76 }
77
78 GOOD_JSON_TEST_RESULT_2 = {
79 'tests': {
80 'car': {
81 'mercedes': {
82 'expected': 'PASS',
83 'actual': 'FAIL'
84 },
85 },
86 'burger': {
87 'in n out': {
88 'expected': 'PASS',
89 'actual': 'PASS'
90 }
91 },
92 },
93 'interrupted': True,
94 'path_delimiter': '.',
95 'version': 3,
96 'seconds_since_epoch': 1406662200.01,
97 'num_failures_by_type': {
98 'FAIL': 1,
99 'PASS': 1
100 }
101 }
102
103 GOOD_JSON_TEST_RESULT_MERGED = {
104 'tests': {
105 'car': {
106 'tesla': {
107 'expected': 'PASS',
108 'actual': 'PASS'
109 },
110 'mercedes': {
111 'expected': 'PASS',
112 'actual': 'FAIL'
113 },
114 'honda': {
115 'expected': 'PASS',
116 'actual': 'PASS'
117 },
118 'toyota': {
119 'expected': 'FAIL',
120 'actual': 'FAIL'
121 }
122 },
123 'computer': {
124 'dell': {
125 'expected': 'PASS',
126 'actual': 'PASS'
127 }
128 },
129 'burger': {
130 'mcdonald': {
131 'expected': 'PASS',
132 'actual': 'PASS'
133 },
134 'in n out': {
135 'expected': 'PASS',
136 'actual': 'PASS'
137 }
138 }
139 },
140 'interrupted': True,
141 'path_delimiter': '.',
142 'version': 3,
143 'seconds_since_epoch': 1406662200.01,
144 'num_failures_by_type': {
145 'FAIL': 1,
146 'PASS': 5
147 }
148 }
149
150
151 class MergingTest(unittest.TestCase): # pragma: no cover
152 def test_merge_json_test_results_format_ok(self):
153 self.maxDiff = None # Show full diff if assertion fail
154 self.assertEquals(results_merger.merge_test_results(
155 [GOOD_JSON_TEST_RESULT_0,
156 GOOD_JSON_TEST_RESULT_1,
157 GOOD_JSON_TEST_RESULT_2]),
158 GOOD_JSON_TEST_RESULT_MERGED)
159
160 if __name__ == '__main__':
161 unittest.main() # pragma: no cover
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698