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

Side by Side Diff: tools/testing/dart/dartino_test_suite.dart

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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 | « tools/servicec_blaze.dart ('k') | tools/testing/dart/test_options.dart » ('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) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 /// Test suite for running tests in a shared Dart VM. Take a look at 5 /// Test suite for running tests in a shared Dart VM. Take a look at
6 /// ../../../tests/dartino_tests/all_tests.dart for more information. 6 /// ../../../tests/dartino_tests/all_tests.dart for more information.
7 library test.dartino_test_suite; 7 library test.dartino_test_suite;
8 8
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 // Define a path for temporary output generated during tests. 101 // Define a path for temporary output generated during tests.
102 String tempDirPath = '$buildDir/temporary_test_output'; 102 String tempDirPath = '$buildDir/temporary_test_output';
103 io.Directory tempDir = new io.Directory(tempDirPath); 103 io.Directory tempDir = new io.Directory(tempDirPath);
104 try { 104 try {
105 tempDir.deleteSync(recursive: true); 105 tempDir.deleteSync(recursive: true);
106 } on io.FileSystemException catch (e) { 106 } on io.FileSystemException catch (e) {
107 // Ignored, we assume the file did not exist. 107 // Ignored, we assume the file did not exist.
108 } 108 }
109 109
110 String javaHome = _guessJavaHome(configuration["arch"]);
111 if (javaHome == null) {
112 String arch = configuration["arch"];
113 print("Notice: Java tests are disabled");
114 print("Unable to find a JDK installation for architecture $arch");
115 print("Install a JDK or set JAVA_PATH to an existing installation.");
116 // TODO(zerny): Throw an error if no-java is not supplied.
117 } else {
118 print("Notice: Enabled Java tests using JDK at $javaHome");
119 }
120
121 bool helperProgramExited = false; 110 bool helperProgramExited = false;
122 io.Process vmProcess; 111 io.Process vmProcess;
123 ReadTestExpectationsInto( 112 ReadTestExpectationsInto(
124 expectations, '$testSuiteDir/dartino_tests.status', 113 expectations, '$testSuiteDir/dartino_tests.status',
125 configuration).then((_) { 114 configuration).then((_) {
126 return new io.File('$buildDir/gen/version.cc').readAsLines(); 115 return new io.File('$buildDir/gen/version.cc').readAsLines();
127 }).then((List<String> versionFileLines) { 116 }).then((List<String> versionFileLines) {
128 // Search for the 'return "version_string";' line. 117 // Search for the 'return "version_string";' line.
129 for (String line in versionFileLines) { 118 for (String line in versionFileLines) {
130 if (line.contains('return')) { 119 if (line.contains('return')) {
131 version = line.substring( 120 version = line.substring(
132 line.indexOf('"') + 1, line.lastIndexOf('"')); 121 line.indexOf('"') + 1, line.lastIndexOf('"'));
133 } 122 }
134 } 123 }
135 assert(version != null); 124 assert(version != null);
136 }).then((_) { 125 }).then((_) {
137 return io.ServerSocket.bind(io.InternetAddress.LOOPBACK_IP_V4, 0); 126 return io.ServerSocket.bind(io.InternetAddress.LOOPBACK_IP_V4, 0);
138 }).then((io.ServerSocket server) { 127 }).then((io.ServerSocket server) {
139 return io.Process.start( 128 return io.Process.start(
140 runtimeConfiguration.dartBinary, 129 runtimeConfiguration.dartBinary,
141 ['-Ddartino-vm=$buildDir/dartino-vm', 130 ['-Ddartino-vm=$buildDir/dartino-vm',
142 '-Ddartino.version=$version', 131 '-Ddartino.version=$version',
143 '-Ddart-sdk=third_party/dart/sdk/', 132 '-Ddart-sdk=third_party/dart/sdk/',
144 '-Dtests-dir=tests/', 133 '-Dtests-dir=tests/',
145 '-Djava-home=$javaHome',
146 '-Dtest.dart.build-dir=$buildDir', 134 '-Dtest.dart.build-dir=$buildDir',
147 '-Dtest.dart.build-arch=${configuration["arch"]}', 135 '-Dtest.dart.build-arch=${configuration["arch"]}',
148 '-Dtest.dart.build-system=${configuration["system"]}', 136 '-Dtest.dart.build-system=${configuration["system"]}',
149 '-Dtest.dart.build-clang=${configuration["clang"]}', 137 '-Dtest.dart.build-clang=${configuration["clang"]}',
150 '-Dtest.dart.build-asan=${configuration["asan"]}', 138 '-Dtest.dart.build-asan=${configuration["asan"]}',
151 '-Dtest.dart.analytics-disable=true', 139 '-Dtest.dart.analytics-disable=true',
152 '-Dtest.dart.temp-dir=$tempDirPath', 140 '-Dtest.dart.temp-dir=$tempDirPath',
153 '-Dtest.dart.servicec-dir=tools/servicec/',
154 '-c', 141 '-c',
155 '--packages=.packages', 142 '--packages=.packages',
156 '-Dtest.dartino_test_suite.port=${server.port}', 143 '-Dtest.dartino_test_suite.port=${server.port}',
157 '$testSuiteDir/dartino_test_suite.dart']).then((io.Process process) { 144 '$testSuiteDir/dartino_test_suite.dart']).then((io.Process process) {
158 process.exitCode.then((_) { 145 process.exitCode.then((_) {
159 helperProgramExited = true; 146 helperProgramExited = true;
160 server.close(); 147 server.close();
161 }); 148 });
162 vmProcess = process; 149 vmProcess = process;
163 return process.stdin.close(); 150 return process.stdin.close();
(...skipping 26 matching lines...) Expand all
190 enqueueNewTestCase(testCase); 177 enqueueNewTestCase(testCase);
191 } 178 }
192 }).then((_) { 179 }).then((_) {
193 onDone(); 180 onDone();
194 }); 181 });
195 } 182 }
196 183
197 void cleanup() { 184 void cleanup() {
198 completer.allDone(); 185 completer.allDone();
199 } 186 }
200
201 String _guessJavaHome(String buildArchitecture) {
202 String arch = buildArchitecture == 'ia32' ? '32' : '64';
203
204 // Try to locate a valid installation based on JAVA_HOME.
205 String javaHome =
206 _guessJavaHomeArch(io.Platform.environment['JAVA_HOME'], arch);
207 if (javaHome != null) return javaHome;
208
209 // Try to locate a valid installation using the java_home utility.
210 String javaHomeUtil = '/usr/libexec/java_home';
211 if (new io.File(javaHomeUtil).existsSync()) {
212 List<String> args = <String>['-v', '1.6+', '-d', arch];
213 io.ProcessResult result =
214 io.Process.runSync(javaHomeUtil, args);
215 if (result.exitCode == 0) {
216 String javaHome = result.stdout.trim();
217 if (_isValidJDK(javaHome)) return javaHome;
218 }
219 }
220
221 // Try to locate a valid installation using the path to javac.
222 io.ProcessResult result =
223 io.Process.runSync('command', ['-v', 'javac'], runInShell: true);
224 if (result.exitCode == 0) {
225 String javac = result.stdout.trim();
226 while (io.FileSystemEntity.isLinkSync(javac)) {
227 javac = new io.Link(javac).resolveSymbolicLinksSync();
228 }
229 // TODO(zerny): Take into account Mac javac paths can be of the form:
230 // .../Versions/X/Commands/javac
231 String javaHome =
232 _guessJavaHomeArch(javac.replaceAll('/bin/javac', ''), arch);
233 if (javaHome != null) return javaHome;
234 }
235
236 return null;
237 }
238
239 String _guessJavaHomeArch(String javaHome, String arch) {
240 if (javaHome == null) return null;
241
242 // Check if the java installation supports the requested architecture.
243 if (new io.File('$javaHome/bin/java').existsSync()) {
244 int supportsVersion = io.Process.runSync(
245 '$javaHome/bin/java', ['-d$arch', '-version']).exitCode;
246 if (supportsVersion == 0 && _isValidJDK(javaHome)) return javaHome;
247 }
248
249 // Check for architecture specific installation by post-fixing arch.
250 String archPostfix = '${javaHome}-$arch';
251 if (_isValidJDK(archPostfix)) return archPostfix;
252
253 // Check for architecture specific installation by replacing amd64 and i386.
254 String archReplace;
255 if (arch == '32' && javaHome.contains('amd64')) {
256 archReplace = javaHome.replaceAll('amd64', 'i386');
257 } else if (arch == '64' && javaHome.contains('i386')) {
258 archReplace = javaHome.replaceAll('i386', 'amd64');
259 }
260 if (_isValidJDK(archReplace)) return archReplace;
261
262 return null;
263 }
264
265 bool _isValidJDK(String javaHome) {
266 if (javaHome == null) return false;
267 return new io.File('$javaHome/include/jni.h').existsSync();
268 }
269 } 187 }
270 188
271 /// Pattern that matches warnings (from dart2js) that contain a comment saying 189 /// Pattern that matches warnings (from dart2js) that contain a comment saying
272 /// "NO_LINT". 190 /// "NO_LINT".
273 final RegExp noLintFilter = 191 final RegExp noLintFilter =
274 new RegExp(r"[^\n]*\n[^\n]*\n[^\n]* // NO_LINT\n *\^+\n"); 192 new RegExp(r"[^\n]*\n[^\n]*\n[^\n]* // NO_LINT\n *\^+\n");
275 193
276 class DartinoTestOutputCommand implements CommandOutput { 194 class DartinoTestOutputCommand implements CommandOutput {
277 final Command command; 195 final Command command;
278 final Duration time; 196 final Duration time;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 process(messages); 446 process(messages);
529 } 447 }
530 }); 448 });
531 } 449 }
532 450
533 void allDone() { 451 void allDone() {
534 // This should cause the vmProcess to exit. 452 // This should cause the vmProcess to exit.
535 socket.close(); 453 socket.close();
536 } 454 }
537 } 455 }
OLDNEW
« no previous file with comments | « tools/servicec_blaze.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698