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

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

Issue 3601010: [Isolates] Allow running multiple isolates in shell and use this in tests. (Closed)
Patch Set: Created 10 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
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 20 matching lines...) Expand all
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 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
37 37
38 38
39 class MjsunitTestCase(test.TestCase): 39 class MjsunitTestCase(test.TestCase):
40 40
41 def __init__(self, path, file, mode, context, config): 41 def __init__(self, path, file, mode, context, config, isolates):
42 super(MjsunitTestCase, self).__init__(context, path, mode) 42 super(MjsunitTestCase, self).__init__(context, path, mode)
43 self.file = file 43 self.file = file
44 self.config = config 44 self.config = config
45 self.self_script = False 45 self.self_script = False
46 self.isolates = isolates
46 47
47 def GetLabel(self): 48 def GetLabel(self):
48 return "%s %s" % (self.mode, self.GetName()) 49 return "%s %s" % (self.mode, self.GetName())
49 50
50 def GetName(self): 51 def GetName(self):
51 return self.path[-1] 52 return self.path[-1] + ["", "-isolates"][self.isolates]
52 53
53 def GetCommand(self): 54 def TestsIsolates(self):
55 return self.isolates
56
57 def GetVmCommand(self, source):
54 result = self.config.context.GetVmCommand(self, self.mode) 58 result = self.config.context.GetVmCommand(self, self.mode)
55 source = open(self.file).read()
56 flags_match = FLAGS_PATTERN.search(source) 59 flags_match = FLAGS_PATTERN.search(source)
57 if flags_match: 60 if flags_match:
58 result += flags_match.group(1).strip().split() 61 result += flags_match.group(1).strip().split()
62 return result
63
64 def GetVmArguments(self, source):
65 result = []
59 additional_files = [] 66 additional_files = []
60 files_match = FILES_PATTERN.search(source); 67 files_match = FILES_PATTERN.search(source);
61 # Accept several lines of 'Files:' 68 # Accept several lines of 'Files:'
62 while True: 69 while True:
63 if files_match: 70 if files_match:
64 additional_files += files_match.group(1).strip().split() 71 additional_files += files_match.group(1).strip().split()
65 files_match = FILES_PATTERN.search(source, files_match.end()) 72 files_match = FILES_PATTERN.search(source, files_match.end())
66 else: 73 else:
67 break 74 break
68 for a_file in additional_files: 75 for a_file in additional_files:
69 result.append(join(dirname(self.config.root), '..', a_file)) 76 result.append(join(dirname(self.config.root), '..', a_file))
70 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js') 77 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js')
71 if SELF_SCRIPT_PATTERN.search(source): 78 if SELF_SCRIPT_PATTERN.search(source):
72 result.append(self.CreateSelfScript()) 79 result.append(self.CreateSelfScript())
73 result += [framework, self.file] 80 result += [framework, self.file]
74 return result 81 return result
75 82
83 def GetCommand(self):
84 source = open(self.file).read()
85 result = self.GetVmCommand(source)
86 result += self.GetVmArguments(source)
87 if self.isolates:
88 result.append("--isolate")
89 result += self.GetVmArguments(source)
90 return result
91
76 def GetSource(self): 92 def GetSource(self):
77 return open(self.file).read() 93 return open(self.file).read()
78 94
79 def CreateSelfScript(self): 95 def CreateSelfScript(self):
80 (fd_self_script, self_script) = tempfile.mkstemp(suffix=".js") 96 (fd_self_script, self_script) = tempfile.mkstemp(suffix=".js")
81 def MakeJsConst(name, value): 97 def MakeJsConst(name, value):
82 return "var %(name)s=\'%(value)s\';\n" % \ 98 return "var %(name)s=\'%(value)s\';\n" % \
83 {'name': name, \ 99 {'name': name, \
84 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') } 100 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') }
85 try: 101 try:
(...skipping 23 matching lines...) Expand all
109 regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'r egress'))] 125 regress = [current_path + ['regress', t] for t in self.Ls(join(self.root, 'r egress'))]
110 bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs')) ] 126 bugs = [current_path + ['bugs', t] for t in self.Ls(join(self.root, 'bugs')) ]
111 third_party = [current_path + ['third_party', t] for t in self.Ls(join(self. root, 'third_party'))] 127 third_party = [current_path + ['third_party', t] for t in self.Ls(join(self. root, 'third_party'))]
112 tools = [current_path + ['tools', t] for t in self.Ls(join(self.root, 'tools '))] 128 tools = [current_path + ['tools', t] for t in self.Ls(join(self.root, 'tools '))]
113 compiler = [current_path + ['compiler', t] for t in self.Ls(join(self.root, 'compiler'))] 129 compiler = [current_path + ['compiler', t] for t in self.Ls(join(self.root, 'compiler'))]
114 all_tests = mjsunit + regress + bugs + third_party + tools + compiler 130 all_tests = mjsunit + regress + bugs + third_party + tools + compiler
115 result = [] 131 result = []
116 for test in all_tests: 132 for test in all_tests:
117 if self.Contains(path, test): 133 if self.Contains(path, test):
118 file_path = join(self.root, reduce(join, test[1:], "") + ".js") 134 file_path = join(self.root, reduce(join, test[1:], "") + ".js")
119 result.append(MjsunitTestCase(test, file_path, mode, self.context, self) ) 135 result.append(MjsunitTestCase(test, file_path, mode, self.context, self, False))
136 result.append(MjsunitTestCase(test, file_path, mode, self.context, self, True))
120 return result 137 return result
121 138
122 def GetBuildRequirements(self): 139 def GetBuildRequirements(self):
123 return ['sample', 'sample=shell'] 140 return ['sample', 'sample=shell']
124 141
125 def GetTestStatus(self, sections, defs): 142 def GetTestStatus(self, sections, defs):
126 status_file = join(self.root, 'mjsunit.status') 143 status_file = join(self.root, 'mjsunit.status')
127 if exists(status_file): 144 if exists(status_file):
128 test.ReadConfigurationInto(status_file, sections, defs) 145 test.ReadConfigurationInto(status_file, sections, defs)
129 146
130 147
131 148
132 def GetConfiguration(context, root): 149 def GetConfiguration(context, root):
133 return MjsunitTestConfiguration(context, root) 150 return MjsunitTestConfiguration(context, root)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698