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

Side by Side Diff: tools/testrunner/local/statusfile_unittest.py

Issue 2203013002: [test] Enable test status filtering by variant (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nits Created 4 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 unified diff | Download patch
« no previous file with comments | « tools/testrunner/local/statusfile.py ('k') | tools/testrunner/local/testsuite.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 the V8 project 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 unittest
7
8 import statusfile
9 from utils import Freeze
10
11
12 TEST_VARIABLES = {
13 'system': 'linux',
14 'mode': 'release',
15 }
16
17
18 TEST_STATUS_FILE = """
19 [
20 [ALWAYS, {
21 'foo/bar': [PASS, SKIP],
22 'baz/bar': [PASS, FAIL],
23 'foo/*': [PASS, SLOW],
24 }], # ALWAYS
25
26 ['%s', {
27 'baz/bar': [PASS, SLOW],
28 'foo/*': [FAIL],
29 }],
30 ]
31 """
32
33
34 def make_variables():
35 variables = {}
36 variables.update(TEST_VARIABLES)
37 return variables
38
39
40 class UtilsTest(unittest.TestCase):
41 def test_freeze(self):
42 self.assertEqual(2, Freeze({1: [2]})[1][0])
43 self.assertEqual(set([3]), Freeze({1: [2], 2: set([3])})[2])
44
45 with self.assertRaises(Exception):
46 Freeze({1: [], 2: set([3])})[2] = 4
47 with self.assertRaises(Exception):
48 Freeze({1: [], 2: set([3])}).update({3: 4})
49 with self.assertRaises(Exception):
50 Freeze({1: [], 2: set([3])})[1].append(2)
51 with self.assertRaises(Exception):
52 Freeze({1: [], 2: set([3])})[2] |= set([3])
53
54 # Sanity check that we can do the same calls on a non-frozen object.
55 {1: [], 2: set([3])}[2] = 4
56 {1: [], 2: set([3])}.update({3: 4})
57 {1: [], 2: set([3])}[1].append(2)
58 {1: [], 2: set([3])}[2] |= set([3])
59
60
61 class StatusFileTest(unittest.TestCase):
62 def test_eval_expression(self):
63 variables = make_variables()
64 variables.update(statusfile.VARIABLES)
65
66 self.assertTrue(
67 statusfile._EvalExpression(
68 'system==linux and mode==release', variables))
69 self.assertTrue(
70 statusfile._EvalExpression(
71 'system==linux or variant==default', variables))
72 self.assertFalse(
73 statusfile._EvalExpression(
74 'system==linux and mode==debug', variables))
75 self.assertRaises(
76 AssertionError,
77 lambda: statusfile._EvalExpression(
78 'system==linux and mode==foo', variables))
79 self.assertRaises(
80 SyntaxError,
81 lambda: statusfile._EvalExpression(
82 'system==linux and mode=release', variables))
83 self.assertEquals(
84 statusfile.VARIANT_EXPRESSION,
85 statusfile._EvalExpression(
86 'system==linux and variant==default', variables)
87 )
88
89 def test_read_statusfile_section_true(self):
90 rules, wildcards = statusfile.ReadStatusFile(
91 TEST_STATUS_FILE % 'system==linux', make_variables())
92
93 self.assertEquals(
94 {
95 'foo/bar': set(['PASS', 'SKIP']),
96 'baz/bar': set(['PASS', 'FAIL', 'SLOW']),
97 },
98 rules[''],
99 )
100 self.assertEquals(
101 {
102 'foo/*': set(['SLOW', 'FAIL']),
103 },
104 wildcards[''],
105 )
106 self.assertEquals({}, rules['default'])
107 self.assertEquals({}, wildcards['default'])
108
109 def test_read_statusfile_section_false(self):
110 rules, wildcards = statusfile.ReadStatusFile(
111 TEST_STATUS_FILE % 'system==windows', make_variables())
112
113 self.assertEquals(
114 {
115 'foo/bar': set(['PASS', 'SKIP']),
116 'baz/bar': set(['PASS', 'FAIL']),
117 },
118 rules[''],
119 )
120 self.assertEquals(
121 {
122 'foo/*': set(['PASS', 'SLOW']),
123 },
124 wildcards[''],
125 )
126 self.assertEquals({}, rules['default'])
127 self.assertEquals({}, wildcards['default'])
128
129 def test_read_statusfile_section_variant(self):
130 rules, wildcards = statusfile.ReadStatusFile(
131 TEST_STATUS_FILE % 'system==linux and variant==default',
132 make_variables(),
133 )
134
135 self.assertEquals(
136 {
137 'foo/bar': set(['PASS', 'SKIP']),
138 'baz/bar': set(['PASS', 'FAIL']),
139 },
140 rules[''],
141 )
142 self.assertEquals(
143 {
144 'foo/*': set(['PASS', 'SLOW']),
145 },
146 wildcards[''],
147 )
148 self.assertEquals(
149 {
150 'baz/bar': set(['PASS', 'SLOW']),
151 },
152 rules['default'],
153 )
154 self.assertEquals(
155 {
156 'foo/*': set(['FAIL']),
157 },
158 wildcards['default'],
159 )
160
161
162 if __name__ == '__main__':
163 unittest.main()
OLDNEW
« no previous file with comments | « tools/testrunner/local/statusfile.py ('k') | tools/testrunner/local/testsuite.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698