[ddc] Run modular test suite in weak mode

Preparation to unfork the SDK.

- Added the test suite to run in weak mode. Need to assess how we
  want to migrate these tests in the future.
- Updated one test to be legacy/nnbd agnostic.
- Update step names from DDK to DDC.

Change-Id: I0d2f1218c9acad82ab70dd525b0a0ad3cdc2ca92

Issue: https://github.com/dart-lang/sdk/issues/40266
Change-Id: If92e7778984de6a5a049faaf421a069c6f492b36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142557
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Nicholas Shahan 2020-04-08 18:25:14 +00:00 committed by commit-bot@chromium.org
parent 3a40332fa7
commit aa47d74666
4 changed files with 39 additions and 18 deletions

View file

@ -26,7 +26,7 @@ void main(List<String> args) async {
_options,
IOPipeline([
SourceToSummaryDillStep(),
DDKStep(),
DDCStep(),
RunD8(),
], cacheSharedModules: true));
}
@ -120,7 +120,7 @@ class SourceToSummaryDillStep implements IOModularStep {
}
}
class DDKStep implements IOModularStep {
class DDCStep implements IOModularStep {
@override
List<DataId> get resultData => const [jsId];
@ -139,7 +139,7 @@ class DDKStep implements IOModularStep {
@override
Future<void> execute(Module module, Uri root, ModuleDataToRelativeUri toUri,
List<String> flags) async {
if (_options.verbose) print('\nstep: ddk on $module');
if (_options.verbose) print('\nstep: ddc on $module');
var transitiveDependencies = computeTransitiveDependencies(module);
await _createPackagesFile(module, root, transitiveDependencies);
@ -192,7 +192,7 @@ class DDKStep implements IOModularStep {
@override
void notifyCached(Module module) {
if (_options.verbose) print('\ncached step: ddk on $module');
if (_options.verbose) print('\ncached step: ddc on $module');
}
}

View file

@ -21,12 +21,12 @@ void main(List<String> args) async {
_options = Options.parse(args);
await _resolveScripts();
await runSuite(
sdkRoot.resolve('tests/compiler/dartdevc/modular/'),
'tests/compiler/dartdevc/modular',
sdkRoot.resolve('tests/modular/'),
'tests/modular',
_options,
IOPipeline([
SourceToSummaryDillStep(),
DDKStep(),
DDCStep(),
RunD8(),
], cacheSharedModules: true));
}
@ -77,7 +77,7 @@ class SourceToSummaryDillStep implements IOModularStep {
sources = ['dart:core'];
extraArgs = [
'--libraries-file',
'$rootScheme:///sdk_nnbd/lib/libraries_nnbd_mix_hack.json'
'$rootScheme:///sdk_nnbd/lib/libraries.json',
];
assert(transitiveDependencies.isEmpty);
} else {
@ -109,6 +109,10 @@ class SourceToSummaryDillStep implements IOModularStep {
.where((m) => !m.isSdk)
.expand((m) => ['--input-summary', '${toUri(m, dillId)}'])),
...(sources.expand((String uri) => ['--source', uri])),
// TODO(40266) After unfork of dart:_runtime only need experiment when
// compiling SDK. For now always use the Null Safety experiment.
'--enable-experiment',
'non-nullable',
...(flags.expand((String flag) => ['--enable-experiment', flag])),
];
@ -123,7 +127,7 @@ class SourceToSummaryDillStep implements IOModularStep {
}
}
class DDKStep implements IOModularStep {
class DDCStep implements IOModularStep {
@override
List<DataId> get resultData => const [jsId];
@ -142,7 +146,7 @@ class DDKStep implements IOModularStep {
@override
Future<void> execute(Module module, Uri root, ModuleDataToRelativeUri toUri,
List<String> flags) async {
if (_options.verbose) print('\nstep: ddk on $module');
if (_options.verbose) print('\nstep: ddc on $module');
var transitiveDependencies = computeTransitiveDependencies(module);
await _createPackagesFile(module, root, transitiveDependencies);
@ -152,11 +156,10 @@ class DDKStep implements IOModularStep {
List<String> extraArgs;
if (module.isSdk) {
sources = ['dart:core'];
// extraArgs = [];
extraArgs = [
'--compile-sdk',
'--libraries-file',
'$rootScheme:///sdk_nnbd/lib/libraries_nnbd_mix_hack.json'
'$rootScheme:///sdk_nnbd/lib/libraries.json',
];
assert(transitiveDependencies.isEmpty);
} else {
@ -179,7 +182,6 @@ class DDKStep implements IOModularStep {
'--packages=${sdkRoot.toFilePath()}/.packages',
_dartdevcScript,
'--kernel',
'--summarize-text',
'--modules=es6',
'--no-summarize',
'--no-source-map',
@ -187,6 +189,10 @@ class DDKStep implements IOModularStep {
rootScheme,
...sources,
...extraArgs,
// TODO(40266) After unfork of dart:_runtime only need experiment when
// compiling SDK. For now always use the Null Safety experiment.
'--enable-experiment',
'non-nullable',
for (String flag in flags) '--enable-experiment=$flag',
...(transitiveDependencies
.where((m) => !m.isSdk)
@ -201,7 +207,7 @@ class DDKStep implements IOModularStep {
@override
void notifyCached(Module module) {
if (_options.verbose) print('\ncached step: ddk on $module');
if (_options.verbose) print('\ncached step: ddc on $module');
}
}
@ -238,6 +244,7 @@ class RunD8 implements IOModularStep {
var runjs = '''
import { dart, _isolate_helper } from 'dart_sdk.js';
import { main } from 'main.js';
dart.strictSubtypeChecks(false);
_isolate_helper.startRootIsolate(() => {}, []);
main.main();
''';
@ -310,9 +317,11 @@ Future<void> _createPackagesFile(
if (module.isPackage) {
packagesContents.write('${module.name}:${module.packageBase}\n');
}
var unusedNum = 0;
for (var dependency in transitiveDependencies) {
if (dependency.isPackage) {
packagesContents.write('${dependency.name}:unused\n');
unusedNum++;
packagesContents.write('${dependency.name}:unused$unusedNum\n');
}
}

View file

@ -1,10 +1,11 @@
// Copyright (c) 2019, 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 'f0.dart';
class B1 extends A0 {
A0 get foo => null;
A0 get foo => A0();
}
A0 createA0() => new A0();

View file

@ -1379,7 +1379,7 @@
"standalone/io"
]
},
{
{
"name": "vm nnbd tests in strong mode",
"arguments": [
"-ndartkp-strong-${system}-${mode}-${arch}",
@ -2231,6 +2231,17 @@
"pkg/dev_compiler/tool/check_nnbd_sdk.dart"
]
},
{
"name": "ddc weak modular tests",
"script": "out/ReleaseX64NNBD/dart-sdk/bin/dart",
"testRunner": true,
"arguments": [
"pkg/dev_compiler/test/modular_suite_nnbd.dart",
"-ndartdevk-weak-${system}-release-chrome",
"--verbose",
"--use-sdk"
]
},
{
"name": "ddc nnbd weak tests",
"arguments": [
@ -3832,4 +3843,4 @@
"linux": "buildtools/linux-x64/clang/bin/llvm-symbolizer",
"macos": "buildtools/mac-x64/clang/bin/llvm-symbolizer"
}
}
}