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

Side by Side Diff: tests/stub-generator/testcfg.py

Issue 9360017: Remove unused support files for old version of tools/test.py. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove testcfg.py files. Created 8 years, 10 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 | « tests/standalone/testcfg.py ('k') | tools/run.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # BSD-style license that can be found in the LICENSE file.
4
5 import os
6 import re
7 import shutil
8 import sys
9 import tempfile
10
11 import test
12 from testing import test_case,test_configuration
13 import utils
14
15 from os.path import join, exists, isdir
16
17 def GeneratedName(src):
18 return re.sub('\.dart$', '-generatedTest.dart', src)
19
20 class DartStubTestCase(test_case.StandardTestCase):
21 def __init__(self, context, path, filename, mode, arch, component):
22 super(DartStubTestCase, self).__init__(context, path, filename, mode, arch,
23 component)
24 self.filename = filename
25 self.mode = mode
26 self.arch = arch
27 self.component = component
28
29 def IsBatchable(self):
30 return False
31
32 def GetStubs(self):
33 source = self.GetSource()
34 stub_classes = utils.ParseTestOptions(test.ISOLATE_STUB_PATTERN, source,
35 self.context.workspace)
36 if stub_classes is None:
37 return (None, None, None)
38 (interface, _, classes) = stub_classes[0].partition(':')
39 (interface, _, implementation) = interface.partition('+')
40 return (interface, classes, implementation)
41
42 def IsFailureOutput(self, output):
43 return output.exit_code != 0 or not '##DONE##' in output.stdout
44
45 def BeforeRun(self):
46 if not self.context.generate:
47 return
48 (interface, classes, _) = self.GetStubs()
49 if interface is None:
50 return
51 d = join(self.GetPath(), 'generated')
52 if not isdir(d):
53 os.mkdir(d)
54 tmpdir = tempfile.mkdtemp()
55 src = join(self.GetPath(), interface)
56 dest = join(self.GetPath(), GeneratedName(interface))
57 (_, tmp) = tempfile.mkstemp()
58 command = self.context.GetDartC(self.mode, self.arch)
59 self.RunCommand(command + [ src,
60 # dartc generates output even if it has no
61 # output to generate.
62 '-noincremental',
63 '-out', tmpdir,
64 '-isolate-stub-out', tmp,
65 '-generate-isolate-stubs', classes ])
66 shutil.rmtree(tmpdir)
67
68 # Copy comments and # commands from the beginning of the source to
69 # the beginning of the generated file, then copy the remaining
70 # source to the end.
71 d = open(dest, 'w')
72 s = open(src, 'r')
73 t = open(tmp, 'r')
74 while True:
75 line = s.readline()
76 if not (re.match('^\s+$', line) or line.startswith('//')
77 or line.startswith('#')):
78 break
79 d.write(line)
80 d.write(t.read())
81 os.remove(tmp)
82 d.write(line)
83 d.write(s.read())
84
85 def GetCommand(self):
86 # Parse the options by reading the .dart source file.
87 source = self.GetSource()
88 vm_options = utils.ParseTestOptions(test.VM_OPTIONS_PATTERN, source,
89 self.context.workspace)
90 dart_options = utils.ParseTestOptions(test.DART_OPTIONS_PATTERN, source,
91 self.context.workspace)
92 (interface, _, implementation) = self.GetStubs()
93
94 # Combine everything into a command array and return it.
95 command = self.context.GetDart(self.mode, self.arch, self.component)
96 if interface is None:
97 f = self.filename
98 else:
99 f = GeneratedName(interface)
100 files = [ join(self.GetPath(), f) ]
101 if vm_options: command += vm_options
102 if dart_options: command += dart_options
103 else: command += files
104 return command
105
106
107 class DartStubTestConfiguration(test_configuration.StandardTestConfiguration):
108 def __init__(self, context, root):
109 super(DartStubTestConfiguration, self).__init__(context, root)
110
111 def ListTests(self, current_path, path, mode, arch, component):
112 dartc = self.context.GetDartC(mode, arch)
113 self.context.generate = os.access(dartc[0], os.X_OK)
114 tests = []
115 for root, dirs, files in os.walk(join(self.root, 'src')):
116 # Skip remnants from the subdirectory that used to be used for
117 # generated code.
118 if root.endswith('generated'):
119 continue
120 for f in [x for x in files if self.IsTest(x)]:
121 # If we can generate code, do not use the checked-in generated
122 # code. Conversely, if we cannot, then only use the
123 # checked-in generated code.
124 if self.context.generate == f.endswith('-generatedTest.dart'):
125 continue
126 test_path = current_path + [ f[:-5] ] # Remove .dart suffix.
127 if not self.Contains(path, test_path):
128 continue
129 tests.append(DartStubTestCase(self.context,
130 test_path,
131 join(root, f),
132 mode,
133 arch,
134 component))
135 return tests
136
137
138 def GetConfiguration(context, root):
139 return DartStubTestConfiguration(context, root)
OLDNEW
« no previous file with comments | « tests/standalone/testcfg.py ('k') | tools/run.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698