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

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

Issue 155161: Add automatic tests for Tick Processor, take two. (Closed)
Patch Set: Created 11 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
« no previous file with comments | « no previous file | test/mjsunit/tools/tickprocessor.js » ('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 11 matching lines...) Expand all
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 33
33 34
34 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)") 35 FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
35 FILES_PATTERN = re.compile(r"//\s+Files:(.*)") 36 FILES_PATTERN = re.compile(r"//\s+Files:(.*)")
37 SELF_SCRIPT_PATTERN = re.compile(r"//\s+Env: TEST_FILE_NAME")
36 38
37 39
38 class MjsunitTestCase(test.TestCase): 40 class MjsunitTestCase(test.TestCase):
39 41
40 def __init__(self, path, file, mode, context, config): 42 def __init__(self, path, file, mode, context, config):
41 super(MjsunitTestCase, self).__init__(context, path) 43 super(MjsunitTestCase, self).__init__(context, path)
42 self.file = file 44 self.file = file
43 self.config = config 45 self.config = config
44 self.mode = mode 46 self.mode = mode
47 self.self_script = False
45 48
46 def GetLabel(self): 49 def GetLabel(self):
47 return "%s %s" % (self.mode, self.GetName()) 50 return "%s %s" % (self.mode, self.GetName())
48 51
49 def GetName(self): 52 def GetName(self):
50 return self.path[-1] 53 return self.path[-1]
51 54
52 def GetCommand(self): 55 def GetCommand(self):
53 result = [self.config.context.GetVm(self.mode)] 56 result = [self.config.context.GetVm(self.mode)]
54 source = open(self.file).read() 57 source = open(self.file).read()
55 flags_match = FLAGS_PATTERN.search(source) 58 flags_match = FLAGS_PATTERN.search(source)
56 if flags_match: 59 if flags_match:
57 result += flags_match.group(1).strip().split() 60 result += flags_match.group(1).strip().split()
61 additional_files = []
58 files_match = FILES_PATTERN.search(source); 62 files_match = FILES_PATTERN.search(source);
59 additional_files = [] 63 # Accept several lines of 'Files:'
60 if files_match: 64 while True:
61 additional_files += files_match.group(1).strip().split() 65 if files_match:
66 additional_files += files_match.group(1).strip().split()
67 files_match = FILES_PATTERN.search(source, files_match.end())
68 else:
69 break
62 for a_file in additional_files: 70 for a_file in additional_files:
63 result.append(join(dirname(self.config.root), '..', a_file)) 71 result.append(join(dirname(self.config.root), '..', a_file))
64 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js') 72 framework = join(dirname(self.config.root), 'mjsunit', 'mjsunit.js')
73 if SELF_SCRIPT_PATTERN.search(source):
74 result.append(self.CreateSelfScript())
65 result += [framework, self.file] 75 result += [framework, self.file]
66 return result 76 return result
67 77
68 def GetSource(self): 78 def GetSource(self):
69 return open(self.file).read() 79 return open(self.file).read()
70 80
81 def CreateSelfScript(self):
82 (fd_self_script, self_script) = tempfile.mkstemp(suffix=".js")
83 def MakeJsConst(name, value):
84 return "var %(name)s=\'%(value)s\';\n" % \
85 {'name': name, \
86 'value': value.replace('\\', '\\\\').replace('\'', '\\\'') }
87 try:
88 os.write(fd_self_script, MakeJsConst('TEST_FILE_NAME', self.file))
89 except IOError, e:
90 test.PrintError("write() " + str(e))
91 os.close(fd_self_script)
92 self.self_script = self_script
93 return self_script
94
95 def Cleanup(self):
96 if self.self_script:
97 test.CheckedUnlink(self.self_script)
71 98
72 class MjsunitTestConfiguration(test.TestConfiguration): 99 class MjsunitTestConfiguration(test.TestConfiguration):
73 100
74 def __init__(self, context, root): 101 def __init__(self, context, root):
75 super(MjsunitTestConfiguration, self).__init__(context, root) 102 super(MjsunitTestConfiguration, self).__init__(context, root)
76 103
77 def Ls(self, path): 104 def Ls(self, path):
78 def SelectTest(name): 105 def SelectTest(name):
79 return name.endswith('.js') and name != 'mjsunit.js' 106 return name.endswith('.js') and name != 'mjsunit.js'
80 return [f[:-3] for f in os.listdir(path) if SelectTest(f)] 107 return [f[:-3] for f in os.listdir(path) if SelectTest(f)]
(...skipping 16 matching lines...) Expand all
97 124
98 def GetTestStatus(self, sections, defs): 125 def GetTestStatus(self, sections, defs):
99 status_file = join(self.root, 'mjsunit.status') 126 status_file = join(self.root, 'mjsunit.status')
100 if exists(status_file): 127 if exists(status_file):
101 test.ReadConfigurationInto(status_file, sections, defs) 128 test.ReadConfigurationInto(status_file, sections, defs)
102 129
103 130
104 131
105 def GetConfiguration(context, root): 132 def GetConfiguration(context, root):
106 return MjsunitTestConfiguration(context, root) 133 return MjsunitTestConfiguration(context, root)
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/tools/tickprocessor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698