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

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

Issue 3164023: Refactor the tools/test.py script and related testcfg.py files.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « test/message/testcfg.py ('k') | test/mozilla/testcfg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2008 the V8 project authors. All rights reserved. 1 # Copyright 2008 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without 2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are 3 # modification, are permitted provided that the following conditions are
4 # met: 4 # met:
5 # 5 #
6 # * Redistributions of source code must retain the above copyright 6 # * Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer. 7 # notice, this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above 8 # * Redistributions in binary form must reproduce the above
9 # copyright notice, this list of conditions and the following 9 # copyright notice, this list of conditions and the following
10 # disclaimer in the documentation and/or other materials provided 10 # disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 import test 28 import test
29 import os 29 import os
30 from os.path import join, dirname, exists 30 from os.path import join, dirname, exists
31 import re 31 import re
32 import tempfile 32 import tempfile
33 33
34 MJSUNIT_DEBUG_FLAGS = ['--enable-slow-asserts', '--debug-code', '--verify-heap']
35 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") 34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
36 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") 35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
37 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") 36 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
38 37
39 38
40 class MjsunitTestCase(test.TestCase): 39 class MjsunitTestCase(test.TestCase):
41 40
42 def __init__(self, path, file, mode, context, config): 41 def __init__(self, path, file, mode, context, config):
43 super(MjsunitTestCase, self).__init__(context, path) 42 super(MjsunitTestCase, self).__init__(context, path, mode)
44 self.file = file 43 self.file = file
45 self.config = config 44 self.config = config
46 self.mode = mode
47 self.self_script = False 45 self.self_script = False
48 46
49 def GetLabel(self): 47 def GetLabel(self):
50 return "%s %s" % (self.mode, self.GetName()) 48 return "%s %s" % (self.mode, self.GetName())
51 49
52 def GetName(self): 50 def GetName(self):
53 return self.path[-1] 51 return self.path[-1]
54 52
55 def GetCommand(self): 53 def GetCommand(self):
56 result = [self.config.context.GetVm(self.mode)] 54 result = self.config.context.GetVmCommand(self, self.mode)
57 source = open(self.file).read() 55 source = open(self.file).read()
58 flags_match = FLAGS_PATTERN.search(source) 56 flags_match = FLAGS_PATTERN.search(source)
59 if flags_match: 57 if flags_match:
60 result += flags_match.group(1).strip().split() 58 result += flags_match.group(1).strip().split()
61 if self.mode == 'debug':
62 result += MJSUNIT_DEBUG_FLAGS
63 additional_files = [] 59 additional_files = []
64 files_match = FILES_PATTERN.search(source); 60 files_match = FILES_PATTERN.search(source);
65 # Accept several lines of 'Files:' 61 # Accept several lines of 'Files:'
66 while True: 62 while True:
67 if files_match: 63 if files_match:
68 additional_files += files_match.group(1).strip().split() 64 additional_files += files_match.group(1).strip().split()
69 files_match = FILES_PATTERN.search(source, files_match.end()) 65 files_match = FILES_PATTERN.search(source, files_match.end())
70 else: 66 else:
71 break 67 break
72 for a_file in additional_files: 68 for a_file in additional_files:
(...skipping 14 matching lines...) Expand all
87 {'name': name, \ 83 {'name': name, \
88 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') } 84 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') }
89 try: 85 try:
90 os.write(fd_self_script, MakeJsConst('TEST_FILE_NAME', self.file)) 86 os.write(fd_self_script, MakeJsConst('TEST_FILE_NAME', self.file))
91 except IOError, e: 87 except IOError, e:
92 test.PrintError("write() " + str(e)) 88 test.PrintError("write() " + str(e))
93 os.close(fd_self_script) 89 os.close(fd_self_script)
94 self.self_script = self_script 90 self.self_script = self_script
95 return self_script 91 return self_script
96 92
97 def Cleanup(self): 93 def AfterRun(self, result):
98 if self.self_script: 94 if self.self_script and (not result.HasPreciousOutput()):
99 test.CheckedUnlink(self.self_script) 95 test.CheckedUnlink(self.self_script)
100 96
101 class MjsunitTestConfiguration(test.TestConfiguration): 97 class MjsunitTestConfiguration(test.TestConfiguration):
102 98
103 def __init__(self, context, root): 99 def __init__(self, context, root):
104 super(MjsunitTestConfiguration, self).__init__(context, root) 100 super(MjsunitTestConfiguration, self).__init__(context, root)
105 101
106 def Ls(self, path): 102 def Ls(self, path):
107 def SelectTest(name): 103 def SelectTest(name):
108 return name.endswith('.js') and name != 'mjsunit.js' 104 return name.endswith('.js') and name != 'mjsunit.js'
(...skipping 19 matching lines...) Expand all
128 124
129 def GetTestStatus(self, sections, defs): 125 def GetTestStatus(self, sections, defs):
130 status_file = join(self.root, 'mjsunit.status') 126 status_file = join(self.root, 'mjsunit.status')
131 if exists(status_file): 127 if exists(status_file):
132 test.ReadConfigurationInto(status_file, sections, defs) 128 test.ReadConfigurationInto(status_file, sections, defs)
133 129
134 130
135 131
136 def GetConfiguration(context, root): 132 def GetConfiguration(context, root):
137 return MjsunitTestConfiguration(context, root) 133 return MjsunitTestConfiguration(context, root)
OLDNEW
« no previous file with comments | « test/message/testcfg.py ('k') | test/mozilla/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698