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

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

Issue 372053: Added test runner for sputnik tests. (Closed)
Patch Set: Created 11 years, 1 month 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 # Copyright 2008 the V8 project authors. All rights reserved.
Mads Ager (chromium) 2009/11/09 09:26:51 2009
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 import os
30 from os.path import join, exists
31 import sys
32 import test
33 import time
34
35
36 class SputnikTestCase(test.TestCase):
37
38 def __init__(self, case, path, context, mode):
39 super(SputnikTestCase, self).__init__(context, path)
40 self.case = case
41 self.mode = mode
42 self.tmpfile = None
43 self.source = None
44
45 def IsNegative(self):
46 return '@negative' in self.GetSource()
47
48 def IsFailureOutput(self, output):
49 if output.exit_code != 0:
50 return True
51 out = output.stdout
52 return "SputnikError" in out
53
54 def BeforeRun(self):
55 self.tmpfile = sputnik.TempFile(suffix='.js', prefix='sputnik-', text=True)
56 self.tmpfile.Write(self.GetSource())
57 self.tmpfile.Close()
58
59 def AfterRun(self):
60 self.tmpfile.Dispose()
61 self.tmpfile = None
62
63 def GetCommand(self):
64 result = [self.context.GetVm(self.mode)]
65 result.append(self.tmpfile.name)
66 return result
67
68 def GetLabel(self):
69 return "%s sputnik %s" % (self.mode, self.GetName())
70
71 def GetName(self):
72 return self.path[-1]
73
74 def GetSource(self):
75 if not self.source:
76 self.source = self.case.GetSource()
77 return self.source
78
79 class SputnikTestConfiguration(test.TestConfiguration):
80
81 def __init__(self, context, root):
82 super(SputnikTestConfiguration, self).__init__(context, root)
83
84 def ListTests(self, current_path, path, mode):
85 # Import the sputnik test runner script as a module
86 testroot = join(self.root, 'sputniktests')
87 modroot = join(testroot, 'tools')
88 sys.path.append(modroot)
89 import sputnik
90 globals()['sputnik'] = sputnik
91 test_suite = sputnik.TestSuite(testroot)
92 test_suite.Validate()
93 tests = test_suite.EnumerateTests([])
94 result = []
95 for test in tests:
96 full_path = current_path + [test.GetPath()[-1]]
97 if self.Contains(path, full_path):
98 case = SputnikTestCase(test, full_path, self.context, mode)
99 result.append(case)
100 return result
101
102 def GetBuildRequirements(self):
103 return ['sample', 'sample=shell']
104
105 def GetTestStatus(self, sections, defs):
106 status_file = join(self.root, 'sputnik.status')
107 if exists(status_file):
108 test.ReadConfigurationInto(status_file, sections, defs)
109
110
111 def GetConfiguration(context, root):
112 checkout = join(root, 'sputniktests')
113 if not exists(checkout):
114 print "No checkout of sputniktests found. Check out the tests under"
115 print "v8/test/sputnik using:"
116 print " svn co http://sputniktests.googlecode.com/svn/trunk/ sputniktests"
117 sys.exit(0)
118 return SputnikTestConfiguration(context, root)
OLDNEW
« test/sputnik/sputnik.status ('K') | « test/sputnik/sputnik.status ('k') | tools/test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698