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

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: Added tests 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
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
10
11 TEST_VARIABLES = {
12 'system': 'linux',
13 'mode': 'release',
14 }
15
16
17 TEST_STATUS_FILE = """
18 [
19 [ALWAYS, {
20 'foo/bar': [PASS, SKIP],
21 'baz/bar': [PASS, FAIL],
22 'foo/*': [PASS, SLOW],
23 }], # ALWAYS
24
25 ['%s', {
26 'baz/bar': [PASS, SLOW],
27 'foo/*': [FAIL],
28 }],
29 ]
30 """
31
32
33 def make_variables():
34 variables = {}
35 variables.update(TEST_VARIABLES)
36 return variables
37
38
39 class StatusFileTest(unittest.TestCase):
40 def test_eval_expression(self):
41 variables = make_variables()
42 variables.update(statusfile.VARIABLES)
43
44 self.assertTrue(
45 statusfile._EvalExpression(
46 'system==linux and mode==release', variables))
47 self.assertTrue(
48 statusfile._EvalExpression(
49 'system==linux or variant==default', variables))
50 self.assertFalse(
51 statusfile._EvalExpression(
52 'system==linux and mode==debug', variables))
53 self.assertRaises(
54 AssertionError,
55 lambda: statusfile._EvalExpression(
56 'system==linux and mode==foo', variables))
57 self.assertRaises(
58 SyntaxError,
59 lambda: statusfile._EvalExpression(
60 'system==linux and mode=release', variables))
61 self.assertEquals(
62 statusfile.VARIANT_EXPRESSION,
63 statusfile._EvalExpression(
64 'system==linux and variant==default', variables)
65 )
66
67 def test_read_statusfile_section_true(self):
68 rules, wildcards = statusfile.ReadStatusFile(
69 TEST_STATUS_FILE % 'system==linux', make_variables())
70
71 self.assertEquals(
72 {
73 'foo/bar': set(['PASS', 'SKIP']),
74 'baz/bar': set(['PASS', 'FAIL', 'SLOW']),
75 },
76 rules[''],
77 )
78 self.assertEquals(
79 {
80 'foo/*': set(['SLOW', 'FAIL']),
81 },
82 wildcards[''],
83 )
84 self.assertEquals({}, rules['default'])
85 self.assertEquals({}, wildcards['default'])
86
87 def test_read_statusfile_section_false(self):
88 rules, wildcards = statusfile.ReadStatusFile(
89 TEST_STATUS_FILE % 'system==windows', make_variables())
90
91 self.assertEquals(
92 {
93 'foo/bar': set(['PASS', 'SKIP']),
94 'baz/bar': set(['PASS', 'FAIL']),
95 },
96 rules[''],
97 )
98 self.assertEquals(
99 {
100 'foo/*': set(['PASS', 'SLOW']),
101 },
102 wildcards[''],
103 )
104 self.assertEquals({}, rules['default'])
105 self.assertEquals({}, wildcards['default'])
106
107 def test_read_statusfile_section_variant(self):
108 rules, wildcards = statusfile.ReadStatusFile(
109 TEST_STATUS_FILE % 'system==linux and variant==default',
110 make_variables(),
111 )
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(
127 {
128 'baz/bar': set(['PASS', 'SLOW']),
129 },
130 rules['default'],
131 )
132 self.assertEquals(
133 {
134 'foo/*': set(['FAIL']),
135 },
136 wildcards['default'],
137 )
138
139
140 if __name__ == '__main__':
141 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698