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

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

Issue 2947473002: Basic support for dev_compiler in test.dart. (Closed)
Patch Set: Revise. Created 3 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/testing/dart/browser_test.dart ('k') | tools/testing/dart/compiler_configuration.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow 6 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow
7 // CommandOutput.exitCode in subclasses of CommandOutput. 7 // CommandOutput.exitCode in subclasses of CommandOutput.
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'command_output.dart'; 10 import 'command_output.dart';
(...skipping 22 matching lines...) Expand all
33 static Command browserHtmlTest( 33 static Command browserHtmlTest(
34 String url, Configuration configuration, List<String> expectedMessages, 34 String url, Configuration configuration, List<String> expectedMessages,
35 {bool retry}) { 35 {bool retry}) {
36 return new BrowserHtmlTestCommand._( 36 return new BrowserHtmlTestCommand._(
37 url, configuration, expectedMessages, retry); 37 url, configuration, expectedMessages, retry);
38 } 38 }
39 39
40 static Command compilation( 40 static Command compilation(
41 String displayName, 41 String displayName,
42 String outputFile, 42 String outputFile,
43 bool neverSkipCompilation,
44 List<Uri> bootstrapDependencies, 43 List<Uri> bootstrapDependencies,
45 String executable, 44 String executable,
46 List<String> arguments, 45 List<String> arguments,
47 Map<String, String> environment) { 46 Map<String, String> environment,
48 return new CompilationCommand._( 47 {bool alwaysCompile: false}) {
49 displayName, 48 return new CompilationCommand._(displayName, outputFile, alwaysCompile,
50 outputFile, 49 bootstrapDependencies, executable, arguments, environment);
51 neverSkipCompilation,
52 bootstrapDependencies,
53 executable,
54 arguments,
55 environment);
56 } 50 }
57 51
58 static Command kernelCompilation( 52 static Command kernelCompilation(
59 String outputFile, 53 String outputFile,
60 bool neverSkipCompilation, 54 bool neverSkipCompilation,
61 List<Uri> bootstrapDependencies, 55 List<Uri> bootstrapDependencies,
62 String executable, 56 String executable,
63 List<String> arguments, 57 List<String> arguments,
64 Map<String, String> environment) { 58 Map<String, String> environment) {
65 return new KernelCompilationCommand._(outputFile, neverSkipCompilation, 59 return new KernelCompilationCommand._(outputFile, neverSkipCompilation,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 144
151 void _buildHashCode(HashCodeBuilder builder) { 145 void _buildHashCode(HashCodeBuilder builder) {
152 builder.addJson(displayName); 146 builder.addJson(displayName);
153 } 147 }
154 148
155 bool _equal(covariant Command other) => 149 bool _equal(covariant Command other) =>
156 hashCode == other.hashCode && displayName == other.displayName; 150 hashCode == other.hashCode && displayName == other.displayName;
157 151
158 String toString() => reproductionCommand; 152 String toString() => reproductionCommand;
159 153
160 Future<bool> get outputIsUpToDate => new Future.value(false); 154 bool get outputIsUpToDate => false;
161 } 155 }
162 156
163 class ProcessCommand extends Command { 157 class ProcessCommand extends Command {
164 /// Path to the executable of this command. 158 /// Path to the executable of this command.
165 String executable; 159 String executable;
166 160
167 /// Command line arguments to the executable. 161 /// Command line arguments to the executable.
168 final List<String> arguments; 162 final List<String> arguments;
169 163
170 /// Environment for the command. 164 /// Environment for the command.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 : env.write('$key=${escapeCommandLineArgument(value)} ')); 201 : env.write('$key=${escapeCommandLineArgument(value)} '));
208 var command = ([executable]..addAll(batchArguments)..addAll(arguments)) 202 var command = ([executable]..addAll(batchArguments)..addAll(arguments))
209 .map(escapeCommandLineArgument) 203 .map(escapeCommandLineArgument)
210 .join(' '); 204 .join(' ');
211 if (workingDirectory != null) { 205 if (workingDirectory != null) {
212 command = "$command (working directory: $workingDirectory)"; 206 command = "$command (working directory: $workingDirectory)";
213 } 207 }
214 return "$env$command"; 208 return "$env$command";
215 } 209 }
216 210
217 Future<bool> get outputIsUpToDate => new Future.value(false); 211 bool get outputIsUpToDate => false;
218 212
219 /// Arguments that are passed to the process when starting batch mode. 213 /// Arguments that are passed to the process when starting batch mode.
220 /// 214 ///
221 /// In non-batch mode, they should be passed before [arguments]. 215 /// In non-batch mode, they should be passed before [arguments].
222 List<String> get batchArguments => const []; 216 List<String> get batchArguments => const [];
223 } 217 }
224 218
225 class CompilationCommand extends ProcessCommand { 219 class CompilationCommand extends ProcessCommand {
226 final String _outputFile; 220 final String _outputFile;
227 final bool _neverSkipCompilation; 221
222 /// If true, then the compilation is run even if the input files are older
223 /// than the output file.
224 final bool _alwaysCompile;
228 final List<Uri> _bootstrapDependencies; 225 final List<Uri> _bootstrapDependencies;
229 226
230 CompilationCommand._( 227 CompilationCommand._(
231 String displayName, 228 String displayName,
232 this._outputFile, 229 this._outputFile,
233 this._neverSkipCompilation, 230 this._alwaysCompile,
234 this._bootstrapDependencies, 231 this._bootstrapDependencies,
235 String executable, 232 String executable,
236 List<String> arguments, 233 List<String> arguments,
237 Map<String, String> environmentOverrides) 234 Map<String, String> environmentOverrides)
238 : super._(displayName, executable, arguments, environmentOverrides); 235 : super._(displayName, executable, arguments, environmentOverrides);
239 236
240 Future<bool> get outputIsUpToDate { 237 bool get outputIsUpToDate {
241 if (_neverSkipCompilation) return new Future.value(false); 238 if (_alwaysCompile) return false;
242 239
243 Future<List<Uri>> readDepsFile(String path) { 240 List<Uri> readDepsFile(String path) {
244 var file = new io.File(new Path(path).toNativePath()); 241 var file = new io.File(new Path(path).toNativePath());
245 if (!file.existsSync()) { 242 if (!file.existsSync()) return null;
246 return new Future.value(null); 243
244 var lines = file.readAsLinesSync();
245 var dependencies = <Uri>[];
246 for (var line in lines) {
247 line = line.trim();
248 if (line.isNotEmpty) {
249 dependencies.add(Uri.parse(line));
250 }
247 } 251 }
248 return file.readAsLines().then((List<String> lines) { 252
249 var dependencies = new List<Uri>(); 253 return dependencies;
250 for (var line in lines) {
251 line = line.trim();
252 if (line.length > 0) {
253 dependencies.add(Uri.parse(line));
254 }
255 }
256 return dependencies;
257 });
258 } 254 }
259 255
260 return readDepsFile("$_outputFile.deps").then((dependencies) { 256 var dependencies = readDepsFile("$_outputFile.deps");
261 if (dependencies != null) { 257 if (dependencies == null) return false;
262 dependencies.addAll(_bootstrapDependencies); 258
263 var jsOutputLastModified = TestUtils.lastModifiedCache 259 dependencies.addAll(_bootstrapDependencies);
264 .getLastModified(new Uri(scheme: 'file', path: _outputFile)); 260 var jsOutputLastModified = TestUtils.lastModifiedCache
265 if (jsOutputLastModified != null) { 261 .getLastModified(new Uri(scheme: 'file', path: _outputFile));
266 for (var dependency in dependencies) { 262 if (jsOutputLastModified == null) return false;
267 var dependencyLastModified = 263
268 TestUtils.lastModifiedCache.getLastModified(dependency); 264 for (var dependency in dependencies) {
269 if (dependencyLastModified == null || 265 var dependencyLastModified =
270 dependencyLastModified.isAfter(jsOutputLastModified)) { 266 TestUtils.lastModifiedCache.getLastModified(dependency);
271 return false; 267 if (dependencyLastModified == null ||
272 } 268 dependencyLastModified.isAfter(jsOutputLastModified)) {
273 } 269 return false;
274 return true;
275 }
276 } 270 }
277 return false; 271 }
278 }); 272 return true;
279 } 273 }
280 274
281 void _buildHashCode(HashCodeBuilder builder) { 275 void _buildHashCode(HashCodeBuilder builder) {
282 super._buildHashCode(builder); 276 super._buildHashCode(builder);
283 builder.addJson(_outputFile); 277 builder.addJson(_outputFile);
284 builder.addJson(_neverSkipCompilation); 278 builder.addJson(_alwaysCompile);
285 builder.addJson(_bootstrapDependencies); 279 builder.addJson(_bootstrapDependencies);
286 } 280 }
287 281
288 bool _equal(CompilationCommand other) => 282 bool _equal(CompilationCommand other) =>
289 super._equal(other) && 283 super._equal(other) &&
290 _outputFile == other._outputFile && 284 _outputFile == other._outputFile &&
291 _neverSkipCompilation == other._neverSkipCompilation && 285 _alwaysCompile == other._alwaysCompile &&
292 deepJsonCompare(_bootstrapDependencies, other._bootstrapDependencies); 286 deepJsonCompare(_bootstrapDependencies, other._bootstrapDependencies);
293 } 287 }
294 288
295 class KernelCompilationCommand extends CompilationCommand { 289 class KernelCompilationCommand extends CompilationCommand {
296 KernelCompilationCommand._( 290 KernelCompilationCommand._(
297 String outputFile, 291 String outputFile,
298 bool neverSkipCompilation, 292 bool neverSkipCompilation,
299 List<Uri> bootstrapDependencies, 293 List<Uri> bootstrapDependencies,
300 String executable, 294 String executable,
301 List<String> arguments, 295 List<String> arguments,
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 594
601 void _buildHashCode(HashCodeBuilder builder) { 595 void _buildHashCode(HashCodeBuilder builder) {
602 super._buildHashCode(builder); 596 super._buildHashCode(builder);
603 builder.addJson(_link); 597 builder.addJson(_link);
604 builder.addJson(_target); 598 builder.addJson(_target);
605 } 599 }
606 600
607 bool _equal(MakeSymlinkCommand other) => 601 bool _equal(MakeSymlinkCommand other) =>
608 super._equal(other) && _link == other._link && _target == other._target; 602 super._equal(other) && _link == other._link && _target == other._target;
609 } 603 }
OLDNEW
« no previous file with comments | « tools/testing/dart/browser_test.dart ('k') | tools/testing/dart/compiler_configuration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698