mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:57:17 +00:00
[CLI] Make passing --resident a prerequisite for passing --resident-compiler-info-file
TEST=test case added to pkg/dartdev/test/commands/compilation_server_test.dart Issue: https://github.com/dart-lang/sdk/issues/54245 Change-Id: I3d982a8d85b63fed8510144bade71e2c95ced121 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359581 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Derek Xu <derekx@google.com>
This commit is contained in:
parent
1ea64da84b
commit
c490c4bd4c
|
@ -326,14 +326,21 @@ class RunCommand extends DartdevCommand {
|
|||
final String? residentCompilerInfoFileArg =
|
||||
args[CompilationServerCommand.residentCompilerInfoFileFlag] ??
|
||||
args[CompilationServerCommand.legacyResidentServerInfoFileFlag];
|
||||
final useResidentServer =
|
||||
args.wasParsed(residentOption) || residentCompilerInfoFileArg != null;
|
||||
final useResidentCompiler = args.wasParsed(residentOption);
|
||||
if (residentCompilerInfoFileArg != null && !useResidentCompiler) {
|
||||
log.stderr(
|
||||
'Error: the --resident flag must be passed whenever the '
|
||||
'--resident-compiler-info-file option is passed.',
|
||||
);
|
||||
return errorExitCode;
|
||||
}
|
||||
|
||||
DartExecutableWithPackageConfig executable;
|
||||
final hasExperiments = args.enabledExperiments.isNotEmpty;
|
||||
try {
|
||||
executable = await getExecutableForCommand(
|
||||
mainCommand,
|
||||
allowSnapshot: !(useResidentServer || hasExperiments),
|
||||
allowSnapshot: !(useResidentCompiler || hasExperiments),
|
||||
nativeAssets: nativeAssets,
|
||||
);
|
||||
} on CommandResolutionFailedException catch (e) {
|
||||
|
@ -345,7 +352,7 @@ class RunCommand extends DartdevCommand {
|
|||
? File(maybeUriToFilename(residentCompilerInfoFileArg))
|
||||
: defaultResidentServerInfoFile;
|
||||
|
||||
if (useResidentServer && residentCompilerInfoFile != null) {
|
||||
if (useResidentCompiler && residentCompilerInfoFile != null) {
|
||||
try {
|
||||
// Ensure the parent directory exists.
|
||||
if (!residentCompilerInfoFile.parent.existsSync()) {
|
||||
|
|
|
@ -44,6 +44,7 @@ void main() {
|
|||
final serverInfoFile = path.join(p.dirPath, 'info');
|
||||
final runResult = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
|
|
|
@ -858,6 +858,7 @@ void residentRun() {
|
|||
serverInfoFile = path.join(serverInfoDirectory.dirPath, 'info');
|
||||
final result = await serverInfoDirectory.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
serverInfoDirectory.relativeFilePath,
|
||||
]);
|
||||
|
@ -881,10 +882,30 @@ void residentRun() {
|
|||
} catch (_) {}
|
||||
});
|
||||
|
||||
test(
|
||||
'passing --resident is a prerequisite for passing --resident-compiler-info-file',
|
||||
() async {
|
||||
p = project(mainSrc: 'void main() {}');
|
||||
final result = await p.run([
|
||||
'run',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
|
||||
expect(result.exitCode, 255);
|
||||
expect(
|
||||
result.stderr,
|
||||
contains(
|
||||
'Error: the --resident flag must be passed whenever the --resident-compiler-info-file option is passed.',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test("'Hello World'", () async {
|
||||
p = project(mainSrc: "void main() { print('Hello World'); }");
|
||||
final result = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
|
@ -907,6 +928,7 @@ void residentRun() {
|
|||
p = project(mainSrc: "void main() { print('Hello World'); }");
|
||||
final result = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--resident-server-info-file=$serverInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
|
@ -929,6 +951,7 @@ void residentRun() {
|
|||
p = project(mainSrc: "void main() { print('Hello World'); }");
|
||||
final result = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption',
|
||||
path.relative(serverInfoFile, from: p.dirPath),
|
||||
p.relativeFilePath,
|
||||
|
@ -956,6 +979,7 @@ void residentRun() {
|
|||
);
|
||||
final result = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
'--enable-experiment=test-experiment',
|
||||
p.relativeFilePath,
|
||||
|
@ -981,11 +1005,13 @@ void residentRun() {
|
|||
|
||||
final runResult1 = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
final runResult2 = await p2.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
p2.relativeFilePath,
|
||||
]);
|
||||
|
@ -1014,6 +1040,7 @@ void residentRun() {
|
|||
|
||||
final runResult1 = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
path.join(p.dirPath, 'lib/main.dart'),
|
||||
]);
|
||||
|
@ -1023,6 +1050,7 @@ void residentRun() {
|
|||
|
||||
final runResult2 = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
path.join(p.dirPath, 'bin/main.dart'),
|
||||
]);
|
||||
|
@ -1041,6 +1069,7 @@ void residentRun() {
|
|||
p.deleteFile('.dart_tool/package_config.json');
|
||||
final runResult = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
|
@ -1072,6 +1101,7 @@ void residentRun() {
|
|||
TestProject p2 = project(mainSrc: 'void main() {}');
|
||||
final runResult1 = await p2.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$tempServerInfoFile',
|
||||
p2.relativeFilePath,
|
||||
]);
|
||||
|
@ -1081,11 +1111,13 @@ void residentRun() {
|
|||
|
||||
await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$tempServerInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
final runResult2 = await p.run([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$tempServerInfoFile',
|
||||
p.relativeFilePath,
|
||||
]);
|
||||
|
@ -1132,6 +1164,7 @@ void residentRun() {
|
|||
|
||||
await p.runWithVmService([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
'--observe=0',
|
||||
'--pause-isolates-on-start',
|
||||
|
@ -1153,6 +1186,7 @@ void residentRun() {
|
|||
sawCFEMsg = false;
|
||||
await p.runWithVmService([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
'--observe=0',
|
||||
'--pause-isolates-on-start',
|
||||
|
@ -1196,6 +1230,7 @@ void residentRun() {
|
|||
|
||||
await p.runWithVmService([
|
||||
'run',
|
||||
'--resident',
|
||||
'--$residentCompilerInfoFileOption=$serverInfoFile',
|
||||
'--observe=0/::1',
|
||||
'--pause-isolates-on-start',
|
||||
|
|
Loading…
Reference in a new issue