Skip to content

Commit b0aebc3

Browse files
sigmundchCommit Bot
authored and
Commit Bot
committed
[test_runner]: remove uses of dartdevc script in test_runner.
These scripts will be removed in a future version of Dart, so we switch to run ddc from either sources or from the snapshot instead. Change-Id: I1c8e2cf6014d484b5951ec66ae9c4f667470b435 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229303 Reviewed-by: Alexander Thomas <[email protected]> Reviewed-by: Nicholas Shahan <[email protected]>
1 parent 20ed5e0 commit b0aebc3

File tree

2 files changed

+67
-11
lines changed

2 files changed

+67
-11
lines changed

pkg/test_runner/lib/src/command.dart

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ class CompilationCommand extends ProcessCommand {
186186
if (displayName == 'precompiler' || displayName == 'app_jit') {
187187
return VMCommandOutput(
188188
this, exitCode, timedOut, stdout, stderr, time, pid);
189-
} else if (displayName == 'dartdevc') {
190-
return DevCompilerCommandOutput(this, exitCode, timedOut, stdout, stderr,
191-
time, compilationSkipped, pid);
192189
}
193190

194191
return CompilationCommandOutput(
@@ -300,6 +297,61 @@ class Dart2jsCompilationCommand extends CompilationCommand {
300297
}
301298
}
302299

300+
class DevCompilerCompilationCommand extends CompilationCommand {
301+
final String compilerPath;
302+
303+
DevCompilerCompilationCommand(
304+
String outputFile,
305+
List<Uri> bootstrapDependencies,
306+
String executable,
307+
List<String> arguments,
308+
Map<String, String> environmentOverrides,
309+
{this.compilerPath,
310+
bool alwaysCompile,
311+
String workingDirectory,
312+
int index = 0})
313+
: super("dartdevc", outputFile, bootstrapDependencies, executable,
314+
arguments, environmentOverrides,
315+
alwaysCompile: alwaysCompile,
316+
workingDirectory: workingDirectory,
317+
index: index);
318+
319+
@override
320+
CommandOutput createOutput(int exitCode, bool timedOut, List<int> stdout,
321+
List<int> stderr, Duration time, bool compilationSkipped,
322+
[int pid = 0]) {
323+
return DevCompilerCommandOutput(this, exitCode, timedOut, stdout, stderr,
324+
time, compilationSkipped, pid);
325+
}
326+
327+
@override
328+
List<String> get batchArguments {
329+
return <String>[
330+
compilerPath,
331+
...super.batchArguments,
332+
];
333+
}
334+
335+
@override
336+
List<String> get nonBatchArguments {
337+
return <String>[
338+
compilerPath,
339+
...super.nonBatchArguments,
340+
];
341+
}
342+
343+
@override
344+
void _buildHashCode(HashCodeBuilder builder) {
345+
super._buildHashCode(builder);
346+
builder.addJson(compilerPath);
347+
}
348+
349+
@override
350+
bool _equal(DevCompilerCompilationCommand other) {
351+
return super._equal(other) && compilerPath == other.compilerPath;
352+
}
353+
}
354+
303355
class FastaCompilationCommand extends CompilationCommand {
304356
final Uri _compilerLocation;
305357

pkg/test_runner/lib/src/compiler_configuration.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,14 @@ class DevCompilerConfiguration extends CompilerConfiguration {
504504
DevCompilerConfiguration(TestConfiguration configuration)
505505
: super._subclass(configuration);
506506

507-
bool get useKernel => _configuration.compiler == Compiler.dartdevk;
508-
509507
String computeCompilerPath() {
510-
var dir = _useSdk ? "${_configuration.buildDirectory}/dart-sdk" : "sdk";
511-
return "$dir/bin/dartdevc$shellScriptExtension";
508+
// The compiler is a Dart program and not an executable itself, so the
509+
// command to spawn as a subprocess is a Dart VM. Internally the
510+
// [DevCompilerCompilationCommand] will prepend the snapshot or Dart library
511+
// entrypoint that is executed by the VM.
512+
// This will change once we update the DDC to use AOT instead of a snapshot.
513+
var dir = _useSdk ? '${_configuration.buildDirectory}/dart-sdk' : 'sdk';
514+
return '$dir/bin/dart$executableExtension';
512515
}
513516

514517
List<String> computeCompilerArguments(
@@ -581,11 +584,12 @@ class DevCompilerConfiguration extends CompilerConfiguration {
581584
}
582585
}
583586

584-
var inputDir = Path(inputFile).append("..").canonicalize().toNativePath();
585-
var displayName = useKernel ? 'dartdevk' : 'dartdevc';
586-
return CompilationCommand(displayName, outputFile, bootstrapDependencies(),
587+
var compilerPath = _useSdk
588+
? '${_configuration.buildDirectory}/dart-sdk/bin/snapshots/dartdevc.dart.snapshot'
589+
: Repository.uri.resolve('pkg/dev_compiler/bin/dartdevc.dart').path;
590+
return DevCompilerCompilationCommand(outputFile, bootstrapDependencies(),
587591
computeCompilerPath(), args, environment,
588-
workingDirectory: inputDir);
592+
compilerPath: compilerPath);
589593
}
590594

591595
CommandArtifact computeCompilationArtifact(String tempDir,

0 commit comments

Comments
 (0)