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

Side by Side Diff: dart/tests/co19/testcfg.py

Issue 8408002: Add a new variable environment for testing, to replace the misusage of 'arch'. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « dart/tests/co19/co19-runtime.status ('k') | dart/tests/corelib/corelib.status » ('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 (c) 2011, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 import os 6 import os
7 from os.path import join, exists 7 from os.path import join, exists
8 import re 8 import re
9 9
10 import test 10 import test
11 import utils 11 import utils
12 12
13 13
14 class Error(Exception): 14 class Error(Exception):
15 pass 15 pass
16 16
17 17
18 class Co19TestCase(test.TestCase): 18 class Co19TestCase(test.TestCase):
19 def __init__(self, path, context, filename, mode, arch): 19 def __init__(self, path, context, filename, mode, arch, component):
20 super(Co19TestCase, self).__init__(context, path) 20 super(Co19TestCase, self).__init__(context, path)
21 self.filename = filename 21 self.filename = filename
22 self.mode = mode 22 self.mode = mode
23 self.arch = arch 23 self.arch = arch
24 self.component = component
24 self._is_negative = None 25 self._is_negative = None
25 26
26 def IsNegative(self): 27 def IsNegative(self):
27 if self._is_negative is None : 28 if self._is_negative is None :
28 contents = self.GetSource() 29 contents = self.GetSource()
29 for tag in ('@compile-error','@static-type-error', 30 for tag in ('@compile-error','@static-type-error',
30 '@dynamic-type-error', '@runtime-error'): 31 '@dynamic-type-error', '@runtime-error'):
31 if tag in contents: 32 if tag in contents:
32 self._is_negative = True 33 self._is_negative = True
33 break 34 break
34 else : 35 else :
35 self._is_negative = False 36 self._is_negative = False
36 37
37 return self._is_negative 38 return self._is_negative
38 39
39 def GetLabel(self): 40 def GetLabel(self):
40 return "%s%s %s" % (self.mode, self.arch, "/".join(self.path)) 41 return "%s%s %s %s" % (self.mode, self.arch, self.component, "/".join(self.p ath))
41 42
42 def GetCommand(self): 43 def GetCommand(self):
43 # Parse the options by reading the .dart source file. 44 # Parse the options by reading the .dart source file.
44 source = self.GetSource() 45 source = self.GetSource()
45 vm_options = utils.ParseTestOptions(test.VM_OPTIONS_PATTERN, source, 46 vm_options = utils.ParseTestOptions(test.VM_OPTIONS_PATTERN, source,
46 self.context.workspace) 47 self.context.workspace)
47 dart_options = utils.ParseTestOptions(test.DART_OPTIONS_PATTERN, source, 48 dart_options = utils.ParseTestOptions(test.DART_OPTIONS_PATTERN, source,
48 self.context.workspace) 49 self.context.workspace)
49 50
50 # Combine everything into a command array and return it. 51 # Combine everything into a command array and return it.
51 command = self.context.GetDart(self.mode, self.arch) 52 command = self.context.GetDart(self.mode, self.arch, self.component)
52 command += self.context.flags 53 command += self.context.flags
53 if self.mode == 'release': command += ['--optimize'] 54 if self.mode == 'release': command += ['--optimize']
54 if vm_options: command += vm_options 55 if vm_options: command += vm_options
55 if dart_options: command += dart_options 56 if dart_options: command += dart_options
56 else: 57 else:
57 command += [self.filename] 58 command += [self.filename]
58 return command 59 return command
59 60
60 def GetName(self): 61 def GetName(self):
61 return self.path[-1] 62 return self.path[-1]
62 63
63 def GetPath(self): 64 def GetPath(self):
64 return os.path.dirname(self.filename) 65 return os.path.dirname(self.filename)
65 66
66 def GetSource(self): 67 def GetSource(self):
67 return file(self.filename).read() 68 return file(self.filename).read()
68 69
69 70
70 class Co19TestConfiguration(test.TestConfiguration): 71 class Co19TestConfiguration(test.TestConfiguration):
71 def __init__(self, context, root): 72 def __init__(self, context, root):
72 super(Co19TestConfiguration, self).__init__(context, root) 73 super(Co19TestConfiguration, self).__init__(context, root)
73 74
74 def ListTests(self, current_path, path, mode, arch): 75 def ListTests(self, current_path, path, mode, arch, component):
75 tests = [] 76 tests = []
76 src_dir = join(self.root, "src") 77 src_dir = join(self.root, "src")
77 strip = len(src_dir.split(os.path.sep)) 78 strip = len(src_dir.split(os.path.sep))
78 for root, dirs, files in os.walk(src_dir): 79 for root, dirs, files in os.walk(src_dir):
79 ignore_dirs = [d for d in dirs if d.startswith('.')] 80 ignore_dirs = [d for d in dirs if d.startswith('.')]
80 for d in ignore_dirs: 81 for d in ignore_dirs:
81 dirs.remove(d) 82 dirs.remove(d)
82 for f in [x for x in files if self.IsTest(x)]: 83 for f in [x for x in files if self.IsTest(x)]:
83 test_path = [] + current_path 84 test_path = [] + current_path
84 test_path.extend(root.split(os.path.sep)[strip:]) 85 test_path.extend(root.split(os.path.sep)[strip:])
85 test_name = short_name = f 86 test_name = short_name = f
86 87
87 # shotlen test_name 88 # shotlen test_name
88 # remove repeats 89 # remove repeats
89 if short_name.startswith(test_path[-1]): 90 if short_name.startswith(test_path[-1]):
90 short_name = short_name[len(test_path[-1]) : ] 91 short_name = short_name[len(test_path[-1]) : ]
91 92
92 # remove suffixes 93 # remove suffixes
93 if short_name.endswith(".dart"): 94 if short_name.endswith(".dart"):
94 short_name = short_name[:-5] # Remove .dart suffix. 95 short_name = short_name[:-5] # Remove .dart suffix.
95 # now .app suffix discarded at self.IsTest() 96 # now .app suffix discarded at self.IsTest()
96 #elif short_name.endswith(".app"): 97 #elif short_name.endswith(".app"):
97 # short_name = short_name[:-4] # Remove .app suffix. 98 # short_name = short_name[:-4] # Remove .app suffix.
98 else: 99 else:
99 raise Error('Unknown suffix in "%s", fix IsTest() predicate' % f) 100 raise Error('Unknown suffix in "%s", fix IsTest() predicate' % f)
100 101
101 102
102 while short_name.startswith('_'): 103 while short_name.startswith('_'):
103 short_name = short_name[1:] 104 short_name = short_name[1:]
104 105
105 test_path.extend(short_name.split('_')) 106 test_path.extend(short_name.split('_'))
106 107
107 # test full name and shorted name matches given path pattern 108 # test full name and shorted name matches given path pattern
108 if self.Contains(path, test_path): pass 109 if self.Contains(path, test_path): pass
109 elif self.Contains(path, test_path + [test_name]): pass 110 elif self.Contains(path, test_path + [test_name]): pass
110 else: 111 else:
111 continue 112 continue
112 113
113 tests.append(Co19TestCase(test_path, 114 tests.append(Co19TestCase(test_path,
114 self.context, 115 self.context,
115 join(root, f), 116 join(root, f),
116 mode, 117 mode,
117 arch)) 118 arch,
119 component))
118 return tests 120 return tests
119 121
120 _TESTNAME_PATTERN = re.compile(r'.*_t[0-9]{2}\.dart$') 122 _TESTNAME_PATTERN = re.compile(r'.*_t[0-9]{2}\.dart$')
121 def IsTest(self, name): 123 def IsTest(self, name):
122 return self._TESTNAME_PATTERN.match(name) 124 return self._TESTNAME_PATTERN.match(name)
123 125
124 def GetTestStatus(self, sections, defs): 126 def GetTestStatus(self, sections, defs):
125 status = join(self.root, "co19-runtime.status") 127 status = join(self.root, "co19-runtime.status")
126 if exists(status): 128 if exists(status):
127 test.ReadConfigurationInto(status, sections, defs) 129 test.ReadConfigurationInto(status, sections, defs)
128 status = join(self.root, "co19-compiler.status") 130 status = join(self.root, "co19-compiler.status")
129 if exists(status): 131 if exists(status):
130 test.ReadConfigurationInto(status, sections, defs) 132 test.ReadConfigurationInto(status, sections, defs)
131 133
132 def Contains(self, path, file): 134 def Contains(self, path, file):
133 """ reimplemented for support '**' glob pattern """ 135 """ reimplemented for support '**' glob pattern """
134 if len(path) > len(file): 136 if len(path) > len(file):
135 return 137 return
136 # ** matches to any number of directories, a/**/d matches a/b/c/d 138 # ** matches to any number of directories, a/**/d matches a/b/c/d
137 # paths like a/**/x/**/b not allowed 139 # paths like a/**/x/**/b not allowed
138 patterns = [p.pattern for p in path] 140 patterns = [p.pattern for p in path]
139 if '**' in patterns: 141 if '**' in patterns:
140 idx = patterns.index('**') 142 idx = patterns.index('**')
141 patterns[idx : idx] = ['*'] * (len(file) - len(path)) 143 patterns[idx : idx] = ['*'] * (len(file) - len(path))
142 path = [test.Pattern(p) for p in patterns] 144 path = [test.Pattern(p) for p in patterns]
143 145
144 for i in xrange(len(path)): 146 for i in xrange(len(path)):
145 if not path[i].match(file[i]): 147 if not path[i].match(file[i]):
146 return False 148 return False
147 return True 149 return True
148 150
149 def GetConfiguration(context, root): 151 def GetConfiguration(context, root):
150 return Co19TestConfiguration(context, root) 152 return Co19TestConfiguration(context, root)
OLDNEW
« no previous file with comments | « dart/tests/co19/co19-runtime.status ('k') | dart/tests/corelib/corelib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698