mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
[ddc] Add --canary flag to expression compiler worker
Closes: https://github.com/dart-lang/sdk/issues/52776 Change-Id: I639fe7fbadf3e938cc686aa8dbd2320a4cc7af7d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311151 Reviewed-by: Mark Zhou <markzipan@google.com> Commit-Queue: Anna Gringauze <annagrin@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
parent
4a6f9328a2
commit
d2f5b3bfab
|
@ -83,6 +83,7 @@ class ExpressionCompilerWorker {
|
|||
final ProcessedOptions _processedOptions;
|
||||
final CompilerOptions _compilerOptions;
|
||||
final ModuleFormat _moduleFormat;
|
||||
final bool _canaryFeatures;
|
||||
final Component _sdkComponent;
|
||||
|
||||
void Function()? onDone;
|
||||
|
@ -91,6 +92,7 @@ class ExpressionCompilerWorker {
|
|||
this._processedOptions,
|
||||
this._compilerOptions,
|
||||
this._moduleFormat,
|
||||
this._canaryFeatures,
|
||||
this._sdkComponent,
|
||||
this.requestStream,
|
||||
this.sendResponse,
|
||||
|
@ -194,6 +196,7 @@ class ExpressionCompilerWorker {
|
|||
trackWidgetCreation: parsedArgs['track-widget-creation'] as bool,
|
||||
soundNullSafety: parsedArgs['sound-null-safety'] as bool,
|
||||
moduleFormat: moduleFormat,
|
||||
canaryFeatures: parsedArgs['canary'] as bool,
|
||||
verbose: parsedArgs['verbose'] as bool,
|
||||
requestStream: requestStream,
|
||||
sendResponse: sendResponse,
|
||||
|
@ -219,6 +222,7 @@ class ExpressionCompilerWorker {
|
|||
bool trackWidgetCreation = false,
|
||||
bool soundNullSafety = false,
|
||||
ModuleFormat moduleFormat = ModuleFormat.amd,
|
||||
bool canaryFeatures = false,
|
||||
bool verbose = false,
|
||||
Stream<Map<String, dynamic>>? requestStream, // Defaults to read from stdin
|
||||
void Function(Map<String, dynamic>)?
|
||||
|
@ -258,8 +262,15 @@ class ExpressionCompilerWorker {
|
|||
if (sdkComponent == null) {
|
||||
throw Exception('Could not load SDK component: $sdkSummary');
|
||||
}
|
||||
return ExpressionCompilerWorker._(processedOptions, compilerOptions,
|
||||
moduleFormat, sdkComponent, requestStream, sendResponse, onDone)
|
||||
return ExpressionCompilerWorker._(
|
||||
processedOptions,
|
||||
compilerOptions,
|
||||
moduleFormat,
|
||||
canaryFeatures,
|
||||
sdkComponent,
|
||||
requestStream,
|
||||
sendResponse,
|
||||
onDone)
|
||||
.._updateCache(sdkComponent, dartSdkModule, true);
|
||||
}
|
||||
|
||||
|
@ -440,7 +451,9 @@ class ExpressionCompilerWorker {
|
|||
summarizeApi: false,
|
||||
moduleName: moduleName,
|
||||
soundNullSafety: _compilerOptions.nnbdMode == NnbdMode.Strong,
|
||||
enableAsserts: _enableAsserts),
|
||||
enableAsserts: _enableAsserts,
|
||||
canaryFeatures: _canaryFeatures,
|
||||
),
|
||||
_moduleCache.componentForLibrary,
|
||||
_moduleCache.moduleNameForComponent,
|
||||
coreTypes: coreTypes,
|
||||
|
@ -776,6 +789,7 @@ final argParser = ArgParser()
|
|||
..addOption('module-format', defaultsTo: 'amd')
|
||||
..addFlag('track-widget-creation', defaultsTo: false)
|
||||
..addFlag('sound-null-safety', negatable: true, defaultsTo: true)
|
||||
..addFlag('canary', negatable: true, defaultsTo: false)
|
||||
..addFlag('verbose', defaultsTo: false);
|
||||
|
||||
Uri? _argToUri(String? uriArg) =>
|
||||
|
|
|
@ -153,7 +153,9 @@ class TestCompiler {
|
|||
moduleName: moduleName,
|
||||
experiments: experiments,
|
||||
soundNullSafety: setup.soundNullSafety,
|
||||
emitDebugMetadata: true);
|
||||
emitDebugMetadata: true,
|
||||
canaryFeatures: false,
|
||||
);
|
||||
var coreTypes = compilerResult.coreTypes;
|
||||
|
||||
final importToSummary = Map<Library, Component>.identity();
|
||||
|
|
|
@ -117,7 +117,9 @@ class TestCompiler {
|
|||
replCompile: true,
|
||||
moduleName: moduleName,
|
||||
soundNullSafety: setup.soundNullSafety,
|
||||
moduleFormats: [setup.moduleFormat]);
|
||||
moduleFormats: [setup.moduleFormat],
|
||||
canaryFeatures: false,
|
||||
);
|
||||
var coreTypes = compilerResult.coreTypes;
|
||||
|
||||
final importToSummary = Map<Library, Component>.identity();
|
||||
|
@ -277,8 +279,25 @@ void main() {
|
|||
for (var moduleFormat in [ModuleFormat.amd, ModuleFormat.ddc]) {
|
||||
group('Module format: $moduleFormat |', () {
|
||||
group('Unsound null safety |', () {
|
||||
runUnsoundTests(moduleFormat);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
for (var moduleFormat in [ModuleFormat.amd, ModuleFormat.ddc]) {
|
||||
group('Module format: $moduleFormat |', () {
|
||||
group('Sound null safety |', () {
|
||||
runSoundTests(moduleFormat);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void runUnsoundTests(ModuleFormat moduleFormat) {
|
||||
var options = SetupCompilerOptions(
|
||||
soundNullSafety: false, moduleFormat: moduleFormat);
|
||||
soundNullSafety: false,
|
||||
moduleFormat: moduleFormat,
|
||||
);
|
||||
|
||||
group('Expression compilations on the same expression compiler |', () {
|
||||
var source = '''
|
||||
|
@ -434,8 +453,7 @@ void main() {
|
|||
''');
|
||||
});
|
||||
|
||||
test(
|
||||
'expression referencing another library with the same named import',
|
||||
test('expression referencing another library with the same named import',
|
||||
() async {
|
||||
await driver.check(
|
||||
scope: <String, String>{},
|
||||
|
@ -452,8 +470,7 @@ void main() {
|
|||
});
|
||||
});
|
||||
|
||||
group(
|
||||
'Expression compiler tests for interactions with module containers:',
|
||||
group('Expression compiler tests for interactions with module containers:',
|
||||
() {
|
||||
var source = '''
|
||||
${options.dartLangComment}
|
||||
|
@ -482,8 +499,7 @@ void main() {
|
|||
driver.delete();
|
||||
});
|
||||
|
||||
test(
|
||||
'evaluation that non-destructively appends to the type container',
|
||||
test('evaluation that non-destructively appends to the type container',
|
||||
() async {
|
||||
await driver.check(
|
||||
scope: <String, String>{'a': 'null', 'check': 'null'},
|
||||
|
@ -524,8 +540,7 @@ void main() {
|
|||
''');
|
||||
});
|
||||
|
||||
test(
|
||||
'evaluation that non-destructively appends to the constant container',
|
||||
test('evaluation that non-destructively appends to the constant container',
|
||||
() async {
|
||||
await driver.check(
|
||||
scope: <String, String>{'a': 'null', 'check': 'null'},
|
||||
|
@ -627,14 +642,13 @@ void main() {
|
|||
''');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
for (var moduleFormat in [ModuleFormat.amd, ModuleFormat.ddc]) {
|
||||
group('Module format: $moduleFormat |', () {
|
||||
group('Sound null safety |', () {
|
||||
var options = SetupCompilerOptions(soundNullSafety: true);
|
||||
void runSoundTests(ModuleFormat moduleFormat) {
|
||||
var options = SetupCompilerOptions(
|
||||
soundNullSafety: true,
|
||||
moduleFormat: moduleFormat,
|
||||
);
|
||||
|
||||
group('Expression compilations on the same expression compiler |', () {
|
||||
var source = '''
|
||||
|
@ -790,8 +804,7 @@ void main() {
|
|||
''');
|
||||
});
|
||||
|
||||
test(
|
||||
'expression referencing another library with the same named import',
|
||||
test('expression referencing another library with the same named import',
|
||||
() async {
|
||||
await driver.check(
|
||||
scope: <String, String>{},
|
||||
|
@ -808,8 +821,7 @@ void main() {
|
|||
});
|
||||
});
|
||||
|
||||
group('Expression compiler expressions that import extension symbols',
|
||||
() {
|
||||
group('Expression compiler expressions that import extension symbols', () {
|
||||
var source = '''
|
||||
${options.dartLangComment}
|
||||
void bar() {
|
||||
|
@ -854,7 +866,4 @@ void main() {
|
|||
''');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:dev_compiler/dev_compiler.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'expression_compiler_worker_shared.dart';
|
||||
|
||||
void main() async {
|
||||
// Set to true to enable debug output
|
||||
var debug = false;
|
||||
|
||||
group('canary -', () {
|
||||
group('amd module format -', () {
|
||||
for (var soundNullSafety in [true, false]) {
|
||||
group('${soundNullSafety ? "sound" : "unsound"} null safety -', () {
|
||||
runTests(
|
||||
moduleFormat: ModuleFormat.amd,
|
||||
soundNullSafety: soundNullSafety,
|
||||
canaryFeatures: true,
|
||||
verbose: debug,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -17,6 +17,7 @@ void main() async {
|
|||
runTests(
|
||||
moduleFormat: ModuleFormat.amd,
|
||||
soundNullSafety: soundNullSafety,
|
||||
canaryFeatures: false,
|
||||
verbose: debug,
|
||||
);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:dev_compiler/dev_compiler.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'expression_compiler_worker_shared.dart';
|
||||
|
||||
void main() async {
|
||||
// Set to true to enable debug output
|
||||
var debug = false;
|
||||
|
||||
group('canary -', () {
|
||||
group('ddc module format -', () {
|
||||
for (var soundNullSafety in [true, false]) {
|
||||
group('${soundNullSafety ? "sound" : "unsound"} null safety -', () {
|
||||
runTests(
|
||||
moduleFormat: ModuleFormat.ddc,
|
||||
soundNullSafety: soundNullSafety,
|
||||
canaryFeatures: true,
|
||||
verbose: debug,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -17,6 +17,7 @@ void main() async {
|
|||
runTests(
|
||||
moduleFormat: ModuleFormat.ddc,
|
||||
soundNullSafety: soundNullSafety,
|
||||
canaryFeatures: false,
|
||||
verbose: debug,
|
||||
);
|
||||
});
|
||||
|
|
|
@ -25,6 +25,7 @@ import 'package:test/test.dart';
|
|||
void runTests({
|
||||
required ModuleFormat moduleFormat,
|
||||
required bool soundNullSafety,
|
||||
required bool canaryFeatures,
|
||||
bool verbose = false,
|
||||
}) {
|
||||
group('expression compiler worker on startup', () {
|
||||
|
@ -64,6 +65,7 @@ void runTests({
|
|||
'--module-format',
|
||||
moduleFormat.name,
|
||||
soundNullSafety ? '--sound-null-safety' : '--no-sound-null-safety',
|
||||
if (canaryFeatures) '--canary',
|
||||
if (verbose) '--verbose',
|
||||
],
|
||||
sendPort: receivePort.sendPort,
|
||||
|
@ -75,18 +77,30 @@ void runTests({
|
|||
});
|
||||
|
||||
group('reading assets using standard file system - ', () {
|
||||
runExpressionCompilationTests(
|
||||
StandardFileSystemTestDriver(soundNullSafety, moduleFormat, verbose));
|
||||
runExpressionCompilationTests(StandardFileSystemTestDriver(
|
||||
soundNullSafety,
|
||||
moduleFormat,
|
||||
canaryFeatures,
|
||||
verbose,
|
||||
));
|
||||
});
|
||||
|
||||
group('reading assets using multiroot file system - ', () {
|
||||
runExpressionCompilationTests(
|
||||
MultiRootFileSystemTestDriver(soundNullSafety, moduleFormat, verbose));
|
||||
runExpressionCompilationTests(MultiRootFileSystemTestDriver(
|
||||
soundNullSafety,
|
||||
moduleFormat,
|
||||
canaryFeatures,
|
||||
verbose,
|
||||
));
|
||||
});
|
||||
|
||||
group('reading assets using asset file system -', () {
|
||||
runExpressionCompilationTests(
|
||||
AssetFileSystemTestDriver(soundNullSafety, moduleFormat, verbose));
|
||||
runExpressionCompilationTests(AssetFileSystemTestDriver(
|
||||
soundNullSafety,
|
||||
moduleFormat,
|
||||
canaryFeatures,
|
||||
verbose,
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -950,6 +964,7 @@ class E {
|
|||
abstract class TestDriver {
|
||||
final bool soundNullSafety;
|
||||
final ModuleFormat moduleFormat;
|
||||
final bool canaryFeatures;
|
||||
final bool verbose;
|
||||
|
||||
late FileSystem fileSystem;
|
||||
|
@ -964,7 +979,8 @@ abstract class TestDriver {
|
|||
ExpressionCompilerWorker? worker;
|
||||
Future<void>? workerDone;
|
||||
|
||||
TestDriver(this.soundNullSafety, this.moduleFormat, this.verbose);
|
||||
TestDriver(this.soundNullSafety, this.moduleFormat, this.canaryFeatures,
|
||||
this.verbose);
|
||||
|
||||
/// Initialize file systems, inputs, and start servers if needed.
|
||||
Future<void> start();
|
||||
|
@ -1005,6 +1021,7 @@ abstract class TestDriver {
|
|||
sendResponse: responseController.add,
|
||||
soundNullSafety: soundNullSafety,
|
||||
moduleFormat: moduleFormat,
|
||||
canaryFeatures: canaryFeatures,
|
||||
verbose: verbose,
|
||||
);
|
||||
workerDone = worker?.run();
|
||||
|
@ -1022,8 +1039,9 @@ class StandardFileSystemTestDriver extends TestDriver {
|
|||
StandardFileSystemTestDriver(
|
||||
bool soundNullSafety,
|
||||
ModuleFormat moduleFormat,
|
||||
bool canaryFeatures,
|
||||
bool verbose,
|
||||
) : super(soundNullSafety, moduleFormat, verbose);
|
||||
) : super(soundNullSafety, moduleFormat, canaryFeatures, verbose);
|
||||
|
||||
@override
|
||||
Future<void> start() async {
|
||||
|
@ -1038,8 +1056,9 @@ class MultiRootFileSystemTestDriver extends TestDriver {
|
|||
MultiRootFileSystemTestDriver(
|
||||
bool soundNullSafety,
|
||||
ModuleFormat moduleFormat,
|
||||
bool canaryFeatures,
|
||||
bool verbose,
|
||||
) : super(soundNullSafety, moduleFormat, verbose);
|
||||
) : super(soundNullSafety, moduleFormat, canaryFeatures, verbose);
|
||||
|
||||
@override
|
||||
Future<void> start() async {
|
||||
|
@ -1057,8 +1076,9 @@ class AssetFileSystemTestDriver extends TestDriver {
|
|||
AssetFileSystemTestDriver(
|
||||
bool soundNullSafety,
|
||||
ModuleFormat moduleFormat,
|
||||
bool canaryFeatures,
|
||||
bool verbose,
|
||||
) : super(soundNullSafety, moduleFormat, verbose);
|
||||
) : super(soundNullSafety, moduleFormat, canaryFeatures, verbose);
|
||||
|
||||
@override
|
||||
Future<void> start() async {
|
||||
|
|
|
@ -74,10 +74,13 @@ class SetupCompilerOptions {
|
|||
final String dartLangComment;
|
||||
final ModuleFormat moduleFormat;
|
||||
final bool soundNullSafety;
|
||||
final bool canaryFeatures;
|
||||
|
||||
SetupCompilerOptions(
|
||||
{this.soundNullSafety = true, this.moduleFormat = ModuleFormat.amd})
|
||||
: options = getOptions(soundNullSafety),
|
||||
SetupCompilerOptions({
|
||||
this.soundNullSafety = true,
|
||||
this.moduleFormat = ModuleFormat.amd,
|
||||
this.canaryFeatures = false,
|
||||
}) : options = getOptions(soundNullSafety),
|
||||
dartLangComment =
|
||||
soundNullSafety ? dartSoundComment : dartUnsoundComment {
|
||||
options.onDiagnostic = (DiagnosticMessage m) {
|
||||
|
|
Loading…
Reference in a new issue