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

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

Issue 7310025: Remove support for logging into a memory buffer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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
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 15 matching lines...) Expand all
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 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") 34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") 35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
36 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME") 36 ENV_VARS_PATTERN = re.compile(r"//\s+Env:(.*)")
37 SELF_SCRIPT_PATTERN = re.compile("TEST_FILE_NAME")
38 LOG_FILE_PATTERN = re.compile("LOG_FILE_NAME")
37 39
38 40
39 class MjsunitTestCase(test.TestCase): 41 class MjsunitTestCase(test.TestCase):
40 42
41 def __init__(self, path, file, mode, context, config, isolates): 43 def __init__(self, path, file, mode, context, config, isolates):
42 super(MjsunitTestCase, self).__init__(context, path, mode) 44 super(MjsunitTestCase, self).__init__(context, path, mode)
43 self.file = file 45 self.file = file
44 self.config = config 46 self.config = config
45 self.self_script = False 47 self.self_script = False
48 self.log_file = False
46 self.isolates = isolates 49 self.isolates = isolates
47 50
48 def GetLabel(self): 51 def GetLabel(self):
49 return "%s %s" % (self.mode, self.GetName()) 52 return "%s %s" % (self.mode, self.GetName())
50 53
51 def GetName(self): 54 def GetName(self):
52 return self.path[-1] + ["", "-isolates"][self.isolates] 55 return self.path[-1] + ["", "-isolates"][self.isolates]
53 56
54 def TestsIsolates(self): 57 def TestsIsolates(self):
55 return self.isolates 58 return self.isolates
56 59
57 def GetVmCommand(self, source): 60 def GetVmCommand(self, source):
58 result = self.config.context.GetVmCommand(self, self.mode) 61 result = self.config.context.GetVmCommand(self, self.mode)
59 flags_match = FLAGS_PATTERN.search(source) 62 flags_match = FLAGS_PATTERN.search(source)
60 if flags_match: 63 if flags_match:
61 result += flags_match.group(1).strip().split() 64 result += flags_match.group(1).strip().split()
62 return result 65 return result
63 66
67 def GetEnvArguments(self, source):
68 result = []
69 env_vars_match = ENV_VARS_PATTERN.search(source)
70 if env_vars_match:
71 env_vars = env_vars_match.group(1)
72 provide_test_file_name = SELF_SCRIPT_PATTERN.search(env_vars)
73 provide_log_file_name = LOG_FILE_PATTERN.search(env_vars)
74 else:
75 return result
76 if provide_test_file_name or provide_log_file_name:
77 self_script_file = self.CreateSelfScript(
78 provide_test_file_name, provide_log_file_name)
79 if self.log_file:
80 result.append("--logfile=" + self.log_file)
81 result.append(self_script_file)
82 return result
83
64 def GetVmArguments(self, source): 84 def GetVmArguments(self, source):
65 result = [] 85 result = []
66 additional_files = [] 86 additional_files = []
67 files_match = FILES_PATTERN.search(source); 87 files_match = FILES_PATTERN.search(source);
68 # Accept several lines of 'Files:' 88 # Accept several lines of 'Files:'
69 while True: 89 while True:
70 if files_match: 90 if files_match:
71 additional_files += files_match.group(1).strip().split() 91 additional_files += files_match.group(1).strip().split()
72 files_match = FILES_PATTERN.search(source, files_match.end()) 92 files_match = FILES_PATTERN.search(source, files_match.end())
73 else: 93 else:
74 break 94 break
75 for a_file in additional_files: 95 for a_file in additional_files:
76 result.append(join(dirname(self.config.root), '..', a_file)) 96 result.append(join(dirname(self.config.root), '..', a_file))
77 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js') 97 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js')
78 if SELF_SCRIPT_PATTERN.search(source):
79 result.append(self.CreateSelfScript())
80 result += [framework, self.file] 98 result += [framework, self.file]
81 return result 99 return result
82 100
83 def GetCommand(self): 101 def GetCommand(self):
84 source = open(self.file).read() 102 source = open(self.file).read()
85 result = self.GetVmCommand(source) 103 result = self.GetVmCommand(source)
104 result += self.GetEnvArguments(source)
86 result += self.GetVmArguments(source) 105 result += self.GetVmArguments(source)
87 if self.isolates: 106 if self.isolates:
88 result.append("--isolate") 107 result.append("--isolate")
89 result += self.GetVmArguments(source) 108 result += self.GetVmArguments(source)
90 return result 109 return result
91 110
92 def GetSource(self): 111 def GetSource(self):
93 return open(self.file).read() 112 return open(self.file).read()
94 113
95 def CreateSelfScript(self): 114 def CreateSelfScript(self, provide_test_file_name, provide_log_file_name):
96 (fd_self_script, self_script) = tempfile.mkstemp(suffix=".js") 115 (fd_self_script, self_script) = tempfile.mkstemp(suffix=".js")
116 if provide_log_file_name:
117 (fd_log_file, log_file) = tempfile.mkstemp(suffix=".log")
118 os.close(fd_log_file)
119 self.log_file = log_file
97 def MakeJsConst(name, value): 120 def MakeJsConst(name, value):
98 return "var %(name)s=\'%(value)s\';\n" % \ 121 return "var %(name)s=\'%(value)s\';\n" % \
99 {'name': name, \ 122 {'name': name, \
100 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') } 123 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') }
101 try: 124 try:
102 os.write(fd_self_script, MakeJsConst('TEST_FILE_NAME', self.file)) 125 if provide_test_file_name:
126 os.write(fd_self_script, MakeJsConst('TEST_FILE_NAME', self.file))
127 if provide_log_file_name:
128 os.write(fd_self_script, MakeJsConst('LOG_FILE_NAME', log_file))
103 except IOError, e: 129 except IOError, e:
104 test.PrintError("write() " + str(e)) 130 test.PrintError("write() " + str(e))
105 os.close(fd_self_script) 131 os.close(fd_self_script)
106 self.self_script = self_script 132 self.self_script = self_script
107 return self_script 133 return self_script
108 134
109 def AfterRun(self, result): 135 def AfterRun(self, result):
110 if self.self_script and (not result or (not result.HasPreciousOutput())): 136 if not result or (not result.HasPreciousOutput()):
111 test.CheckedUnlink(self.self_script) 137 if self.self_script:
138 test.CheckedUnlink(self.self_script)
139 if self.log_file:
140 test.CheckedUnlink(self.log_file)
112 141
113 class MjsunitTestConfiguration(test.TestConfiguration): 142 class MjsunitTestConfiguration(test.TestConfiguration):
114 143
115 def __init__(self, context, root): 144 def __init__(self, context, root):
116 super(MjsunitTestConfiguration, self).__init__(context, root) 145 super(MjsunitTestConfiguration, self).__init__(context, root)
117 146
118 def Ls(self, path): 147 def Ls(self, path):
119 def SelectTest(name): 148 def SelectTest(name):
120 return name.endswith('.js') and name != 'mjsunit.js' 149 return name.endswith('.js') and name != 'mjsunit.js'
121 return [f[:-3] for f in os.listdir(path) if SelectTest(f)] 150 return [f[:-3] for f in os.listdir(path) if SelectTest(f)]
(...skipping 27 matching lines...) Expand all
149 178
150 def GetTestStatus(self, sections, defs): 179 def GetTestStatus(self, sections, defs):
151 status_file = join(self.root, 'mjsunit.status') 180 status_file = join(self.root, 'mjsunit.status')
152 if exists(status_file): 181 if exists(status_file):
153 test.ReadConfigurationInto(status_file, sections, defs) 182 test.ReadConfigurationInto(status_file, sections, defs)
154 183
155 184
156 185
157 def GetConfiguration(context, root): 186 def GetConfiguration(context, root):
158 return MjsunitTestConfiguration(context, root) 187 return MjsunitTestConfiguration(context, root)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698