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

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

Issue 10919265: First commit of new tools/run-tests.py (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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
(Empty)
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided
11 # with the distribution.
12 # * Neither the name of Google Inc. nor the names of its
13 # contributors may be used to endorse or promote products derived
14 # from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29 # These imports are required for the on-demand conversion from
30 # old to new status file format.
31 from os.path import exists
32 from os.path import getmtime
33
34 from . import old_statusfile
35
36
37 # These outcomes can occur in a TestCase's outcomes list:
38 SKIP = 'SKIP'
39 FAIL = 'FAIL'
40 PASS = 'PASS'
41 OKAY = 'OKAY'
42 TIMEOUT = 'TIMEOUT'
43 CRASH = 'CRASH'
44 SLOW = 'SLOW'
45 # These are just for the status files and are mapped below in DEFS:
46 FAIL_OK = 'FAIL_OK'
47 PASS_OR_FAIL = 'PASS_OR_FAIL'
48
49 KEYWORDS = {SKIP: SKIP,
50 FAIL: FAIL,
51 PASS: PASS,
52 OKAY: OKAY,
53 TIMEOUT: TIMEOUT,
54 CRASH: CRASH,
55 SLOW: SLOW,
56 FAIL_OK: FAIL_OK,
57 PASS_OR_FAIL: PASS_OR_FAIL}
58
59 DEFS = {FAIL_OK: [FAIL, OKAY],
60 PASS_OR_FAIL: [PASS, FAIL]}
61
62
63 def DoSkip(outcomes):
64 return SKIP in outcomes or SLOW in outcomes
65
66
67 def IsFlaky(outcomes):
68 return ((PASS in outcomes) and (FAIL in outcomes) and
69 (not CRASH in outcomes) and (not OKAY in outcomes))
70
71
72 def IsFailOk(outcomes):
73 return (FAIL in outcomes) and (OKAY in outcomes)
74
75
76 def _AddOutcome(result, new):
77 global DEFS
78 if new in DEFS:
79 mapped = DEFS[new]
80 if type(mapped) == list:
81 for m in mapped:
82 _AddOutcome(result, m)
83 elif type(mapped) == str:
84 _AddOutcome(result, mapped)
85 else:
86 result.add(new)
87
88
89 def _ParseOutcomeList(rule, outcomes, target_dict, variables):
90 result = set([])
91 if type(outcomes) == str:
92 outcomes = [outcomes]
93 for item in outcomes:
94 if type(item) == str:
95 _AddOutcome(result, item)
96 elif type(item) == list:
97 if not eval(item[0], variables): continue
98 for outcome in item[1:]:
99 assert type(outcome) == str
100 _AddOutcome(result, outcome)
101 else:
102 assert False
103 if len(result) == 0: return
104 if rule in target_dict:
105 target_dict[rule] |= result
106 else:
107 target_dict[rule] = result
108
109
110 def ReadStatusFile(path, variables):
111 # As long as the old-format .status files are authoritative, just
112 # create the converted version on demand and cache it to speed up
113 # subsequent runs.
114 if path.endswith(".status"):
115 newpath = path + "2"
116 if not exists(newpath) or getmtime(newpath) < getmtime(path):
117 print "Converting status file."
118 converted = old_statusfile.ConvertNotation(path).GetOutput()
119 with open(newpath, 'w') as f:
120 f.write(converted)
121 path = newpath
122
123 with open(path) as f:
124 global KEYWORDS
125 contents = eval(f.read(), KEYWORDS)
126
127 rules = {}
128 wildcards = {}
129 for section in contents:
130 assert type(section) == list
131 assert len(section) == 2
132 if not eval(section[0], variables): continue
133 section = section[1]
134 assert type(section) == dict
135 for rule in section:
136 assert type(rule) == str
137 if rule[-1] == '*':
138 _ParseOutcomeList(rule, section[rule], wildcards, variables)
139 else:
140 _ParseOutcomeList(rule, section[rule], rules, variables)
141 return rules, wildcards
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698