7c0e4d67c7
- Remove unsound platform .dill files from the packaged SDK. - Throw and error referencing the sound null safety requirements of Dart 3 when compiling with `--no-sound-null-safety` and an unsound platform .dill file is not found. Change-Id: I703a446e3e92c76a6b48168577fc0161eea83854 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289280 Commit-Queue: Nate Biggs <natebiggs@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
96 lines
3.7 KiB
Dart
96 lines
3.7 KiB
Dart
// Copyright (c) 2016, 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 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:_fe_analyzer_shared/src/testing/annotated_code_helper.dart';
|
|
import 'package:args/args.dart';
|
|
import 'package:async_helper/async_helper.dart';
|
|
import 'package:compiler/src/commandline_options.dart';
|
|
import 'package:compiler/src/dart2js.dart' as entry;
|
|
import 'package:expect/expect.dart';
|
|
import 'package:sourcemap_testing/src/stepping_helper.dart';
|
|
|
|
import 'package:compiler/src/util/memory_compiler.dart';
|
|
|
|
void main(List<String> args) {
|
|
ArgParser argParser = ArgParser(allowTrailingOptions: true);
|
|
argParser.addFlag('debug', abbr: 'd', defaultsTo: false);
|
|
argParser.addFlag('verbose', abbr: 'v', defaultsTo: false);
|
|
argParser.addFlag('continued', abbr: 'c', defaultsTo: false);
|
|
ArgResults argResults = argParser.parse(args);
|
|
Directory dataDir = Directory.fromUri(Platform.script.resolve('stepping'));
|
|
asyncTest(() async {
|
|
bool continuing = false;
|
|
await for (FileSystemEntity entity in dataDir.list()) {
|
|
String name = entity.uri.pathSegments.last;
|
|
if (argResults.rest.isNotEmpty &&
|
|
!argResults.rest.contains(name) &&
|
|
!continuing) {
|
|
continue;
|
|
}
|
|
print('----------------------------------------------------------------');
|
|
print('Checking ${entity.uri}');
|
|
print('----------------------------------------------------------------');
|
|
String annotatedCode = await File.fromUri(entity.uri).readAsString();
|
|
await testAnnotatedCode(annotatedCode,
|
|
verbose: argResults['verbose'], debug: argResults['debug']);
|
|
if (argResults['continued']) {
|
|
continuing = true;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
const String kernelMarker = 'kernel.';
|
|
|
|
Future testAnnotatedCode(String code,
|
|
{bool debug = false, bool verbose = false}) async {
|
|
AnnotatedCode annotatedCode =
|
|
AnnotatedCode.fromText(code, commentStart, commentEnd);
|
|
print(annotatedCode.sourceCode);
|
|
Map<String, AnnotatedCode> split =
|
|
splitByPrefixes(annotatedCode, [kernelMarker]);
|
|
print('---from kernel------------------------------------------------------');
|
|
await runTest(split[kernelMarker]!, kernelMarker,
|
|
debug: debug, verbose: verbose);
|
|
}
|
|
|
|
Future runTest(AnnotatedCode annotatedCode, String config,
|
|
{bool debug = false,
|
|
bool verbose = false,
|
|
List<String> options = const <String>[]}) async {
|
|
Directory dir = Directory.systemTemp.createTempSync('stepping_test');
|
|
String testFileName = 'test.dart';
|
|
String path = dir.path;
|
|
String inputFile = '$path/$testFileName';
|
|
File(inputFile).writeAsStringSync(annotatedCode.sourceCode);
|
|
String outputFile = '$path/js.js';
|
|
List<String> arguments = <String>[
|
|
'--out=$outputFile',
|
|
inputFile,
|
|
Flags.disableInlining,
|
|
Flags.noSoundNullSafety,
|
|
// Unsound platform dill files are no longer packaged in the SDK and must
|
|
// be read from the build directory during tests.
|
|
'--platform-binaries=$buildPlatformBinariesPath',
|
|
'--libraries-spec=$sdkLibrariesSpecificationUri',
|
|
];
|
|
CompilationResult compilationResult = await entry.internalMain(arguments);
|
|
Expect.isTrue(compilationResult.isSuccess);
|
|
List<String> scriptD8Command = [
|
|
'$sdkPath/_internal/js_runtime/lib/preambles/d8.js',
|
|
outputFile
|
|
];
|
|
ProcessResult result =
|
|
runD8AndStep(dir.path, testFileName, annotatedCode, scriptD8Command);
|
|
List<String> d8output = result.stdout.split("\n");
|
|
if (verbose) {
|
|
d8output.forEach(print);
|
|
}
|
|
checkD8Steps(dir.path, d8output, annotatedCode, debug: debug);
|
|
dir.deleteSync(recursive: true);
|
|
}
|