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

Side by Side Diff: test/message/testcfg.py

Issue 4299: Added message tests. (Closed)
Patch Set: Created 12 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
« no previous file with comments | « test/message/simple-throw.out ('k') | test/mozilla/mozilla.status » ('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 # Copyright 2008 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 import test
29 import os
30 from os.path import join, dirname, exists, basename
31 import re
32
33 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
34
35 class MessageTestCase(test.TestCase):
36
37 def __init__(self, path, file, expected, mode, context, config):
38 super(MessageTestCase, self).__init__(context, path)
39 self.file = file
40 self.expected = expected
41 self.config = config
42 self.mode = mode
43
44 def IsFailureOutput(self, output):
45 f = file(self.expected)
46 # Skip initial '#' comment and spaces
47 for line in f:
48 if (not line.startswith('#')) and (not line.strip()):
49 break
50 # Convert output lines to regexps that we can match
51 env = { 'basename': basename(self.file) }
52 patterns = [ ]
53 for line in f:
54 if not line.strip():
55 continue
56 pattern = re.escape(line.rstrip() % env)
57 pattern = pattern.replace('\\*', '.*')
58 pattern = '^%s$' % pattern
59 patterns.append(pattern)
60 # Compare actual output with the expected
61 outlines = [ s for s in output.stdout.split('\n') if s ]
62 if len(outlines) != len(patterns):
63 return True
64 for i in xrange(len(patterns)):
65 if not re.match(patterns[i], outlines[i]):
66 return True
67 return False
68
69 def GetLabel(self):
70 return "%s %s" % (self.mode, self.GetName())
71
72 def GetName(self):
73 return self.path[-1]
74
75 def GetCommand(self):
76 result = [self.config.context.GetVm(self.mode)]
77 source = open(self.file).read()
78 flags_match = FLAGS_PATTERN.search(source)
79 if flags_match:
80 result += flags_match.group(1).strip().split()
81 result.append(self.file)
82 return result
83
84 def GetSource(self):
85 return (open(self.file).read()
86 + "\n--- expected output ---\n"
87 + open(self.expected).read())
88
89
90 class MessageTestConfiguration(test.TestConfiguration):
91
92 def __init__(self, context, root):
93 super(MessageTestConfiguration, self).__init__(context, root)
94
95 def Ls(self, path):
96 return [f[:-3] for f in os.listdir(path) if f.endswith('.js')]
97
98 def ListTests(self, current_path, path, mode):
99 mjsunit = [current_path + [t] for t in self.Ls(self.root)]
100 bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs')) ]
101 all_tests = mjsunit + bugs
102 result = []
103 for test in all_tests:
104 if self.Contains(path, test):
105 file_prefix = join(self.root, reduce(join, test[1:], ""))
106 file_path = file_prefix + ".js"
107 output_path = file_prefix + ".out"
108 if not exists(output_path):
109 print "Could not find %s" % output_path
110 continue
111 result.append(MessageTestCase(test, file_path, output_path, mode,
112 self.context, self))
113 return result
114
115 def GetBuildRequirements(self):
116 return ['sample', 'sample=shell']
117
118 def GetTestStatus(self, sections, defs):
119 status_file = join(self.root, 'message.status')
120 if exists(status_file):
121 test.ReadConfigurationInto(status_file, sections, defs)
122
123
124 def GetConfiguration(context, root):
125 return MessageTestConfiguration(context, root)
OLDNEW
« no previous file with comments | « test/message/simple-throw.out ('k') | test/mozilla/mozilla.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698