mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[pkg/frontend_server] use package:lints/recommended.yaml
Change-Id: I13f6ede17a29972b53283e0bb32960b4ea364aa5 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282388 Reviewed-by: Alexander Aprelev <aam@google.com> Commit-Queue: Devon Carew <devoncarew@google.com>
This commit is contained in:
parent
fae934c4b1
commit
12f0711a5b
|
@ -1,5 +1,8 @@
|
|||
include: package:lints/core.yaml
|
||||
include: package:lints/recommended.yaml
|
||||
|
||||
linter:
|
||||
rules:
|
||||
- depend_on_referenced_packages
|
||||
- directives_ordering
|
||||
- sort_pub_dependencies
|
||||
- unawaited_futures
|
||||
|
|
|
@ -9,7 +9,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:frontend_server/starter.dart';
|
||||
|
||||
Future<Null> main(List<String> args) async {
|
||||
Future<void> main(List<String> args) async {
|
||||
exitCode = await starter(args);
|
||||
if (exitCode != 0) {
|
||||
exit(exitCode);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// 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.
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
|
||||
/// A library to invoke the CFE to compute kernel summary files.
|
||||
///
|
||||
/// Used by `utils/bazel/kernel_worker.dart`.
|
||||
|
@ -9,9 +11,9 @@ import 'dart:async';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:_fe_analyzer_shared/src/macros/executor/isolated_executor.dart'
|
||||
as isolatedExecutor;
|
||||
as isolated_executor;
|
||||
import 'package:_fe_analyzer_shared/src/macros/executor/process_executor.dart'
|
||||
as processExecutor;
|
||||
as process_executor;
|
||||
import 'package:_fe_analyzer_shared/src/macros/executor/serialization.dart'
|
||||
show SerializationMode;
|
||||
import 'package:args/args.dart';
|
||||
|
@ -34,25 +36,25 @@ import 'package:vm/target/vm.dart';
|
|||
/// This is how individual work request args are differentiated from startup
|
||||
/// args in bazel (individual work request args go in that file).
|
||||
List<String> preprocessArgs(List<String> args) {
|
||||
args = new List.from(args);
|
||||
args = List.from(args);
|
||||
if (args.isEmpty) {
|
||||
return args;
|
||||
}
|
||||
String lastArg = args.last;
|
||||
if (lastArg.startsWith('@')) {
|
||||
File argsFile = new File(lastArg.substring(1));
|
||||
File argsFile = File(lastArg.substring(1));
|
||||
try {
|
||||
args.removeLast();
|
||||
args.addAll(argsFile.readAsLinesSync());
|
||||
} on FileSystemException catch (e) {
|
||||
throw new Exception('Failed to read file specified by $lastArg : $e');
|
||||
throw Exception('Failed to read file specified by $lastArg : $e');
|
||||
}
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
/// An [ArgParser] for generating kernel summaries.
|
||||
final summaryArgsParser = new ArgParser()
|
||||
final summaryArgsParser = ArgParser()
|
||||
..addFlag('help', negatable: false, abbr: 'h')
|
||||
..addFlag('exclude-non-sources',
|
||||
negatable: false,
|
||||
|
@ -147,7 +149,7 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
if (parsedArgs['help']) {
|
||||
out.writeln(summaryArgsParser.usage);
|
||||
if (!isWorker) exit(0);
|
||||
return new ComputeKernelResult(false, previousState);
|
||||
return ComputeKernelResult(false, previousState);
|
||||
}
|
||||
|
||||
// Bazel creates an overlay file system where some files may be located in the
|
||||
|
@ -155,7 +157,7 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
// system hides this from the front end.
|
||||
var multiRoots = parsedArgs['multi-root'].map(Uri.base.resolve).toList();
|
||||
if (multiRoots.isEmpty) multiRoots.add(Uri.base);
|
||||
MultiRootFileSystem mrfs = new MultiRootFileSystem(
|
||||
MultiRootFileSystem mrfs = MultiRootFileSystem(
|
||||
parsedArgs['multi-root-scheme'],
|
||||
multiRoots,
|
||||
fe.StandardFileSystem.instance);
|
||||
|
@ -169,7 +171,7 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
var summaryOnly = parsedArgs['summary-only'] as bool;
|
||||
var summary = parsedArgs['summary'] as bool;
|
||||
if (summaryOnly && !summary) {
|
||||
throw new ArgumentError('--summary-only conflicts with --no-summary');
|
||||
throw ArgumentError('--summary-only conflicts with --no-summary');
|
||||
}
|
||||
var trackWidgetCreation = parsedArgs['track-widget-creation'] as bool;
|
||||
|
||||
|
@ -177,40 +179,40 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
// compatible while we migrate existing clients of this tool.
|
||||
var targetName =
|
||||
(parsedArgs['target'] as String?) ?? (summaryOnly ? 'ddc' : 'vm');
|
||||
var targetFlags = new TargetFlags(
|
||||
var targetFlags = TargetFlags(
|
||||
trackWidgetCreation: trackWidgetCreation,
|
||||
soundNullSafety: nnbdMode == fe.NnbdMode.Strong);
|
||||
Target target;
|
||||
switch (targetName) {
|
||||
case 'vm':
|
||||
target = new VmTarget(targetFlags);
|
||||
target = VmTarget(targetFlags);
|
||||
if (summaryOnly) {
|
||||
out.writeln('error: --summary-only not supported for the vm target');
|
||||
}
|
||||
break;
|
||||
case 'flutter':
|
||||
target = new FlutterTarget(targetFlags);
|
||||
target = FlutterTarget(targetFlags);
|
||||
if (summaryOnly) {
|
||||
throw new ArgumentError(
|
||||
throw ArgumentError(
|
||||
'error: --summary-only not supported for the flutter target');
|
||||
}
|
||||
break;
|
||||
case 'flutter_runner':
|
||||
target = new FlutterRunnerTarget(targetFlags);
|
||||
target = FlutterRunnerTarget(targetFlags);
|
||||
if (summaryOnly) {
|
||||
throw new ArgumentError('error: --summary-only not supported for the '
|
||||
throw ArgumentError('error: --summary-only not supported for the '
|
||||
'flutter_runner target');
|
||||
}
|
||||
break;
|
||||
case 'dart2js':
|
||||
target = new Dart2jsTarget('dart2js', targetFlags);
|
||||
target = Dart2jsTarget('dart2js', targetFlags);
|
||||
if (summaryOnly) {
|
||||
out.writeln(
|
||||
'error: --summary-only not supported for the dart2js target');
|
||||
}
|
||||
break;
|
||||
case 'dart2js_summary':
|
||||
target = new Dart2jsSummaryTarget(
|
||||
target = Dart2jsSummaryTarget(
|
||||
'dart2js', sources, excludeNonSources, targetFlags);
|
||||
if (!summaryOnly) {
|
||||
out.writeln(
|
||||
|
@ -221,7 +223,7 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
// TODO(jakemac):If `generateKernel` changes to return a summary
|
||||
// component, process the component instead.
|
||||
target =
|
||||
new DevCompilerSummaryTarget(sources, excludeNonSources, targetFlags);
|
||||
DevCompilerSummaryTarget(sources, excludeNonSources, targetFlags);
|
||||
if (!summaryOnly) {
|
||||
out.writeln('error: --no-summary-only not supported for the '
|
||||
'ddc target');
|
||||
|
@ -296,7 +298,7 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
verbose: verbose,
|
||||
nnbdMode: nnbdMode);
|
||||
var uriTranslator = await helper.processedOpts.getUriTranslator();
|
||||
_FakeFileSystem ffs = fileSystem = new _FakeFileSystem(fileSystem);
|
||||
_FakeFileSystem ffs = fileSystem = _FakeFileSystem(fileSystem);
|
||||
for (MapEntry<Uri, Uri> entry in redirectsToFrom.entries) {
|
||||
ffs.addRedirect(
|
||||
uriTranslator.translate(entry.value, false) ?? entry.value,
|
||||
|
@ -393,14 +395,14 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
switch (format) {
|
||||
case 'kernel':
|
||||
macroExecutor.registerExecutorFactory(
|
||||
() => isolatedExecutor.start(serializationMode, programUri),
|
||||
() => isolated_executor.start(serializationMode, programUri),
|
||||
{library});
|
||||
break;
|
||||
case 'aot':
|
||||
macroExecutor.registerExecutorFactory(
|
||||
() => processExecutor.start(
|
||||
() => process_executor.start(
|
||||
serializationMode,
|
||||
processExecutor.CommunicationChannel.socket,
|
||||
process_executor.CommunicationChannel.socket,
|
||||
programUri.toFilePath()),
|
||||
{library});
|
||||
break;
|
||||
|
@ -441,12 +443,12 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
if (lib.importUri.isScheme("dart")) continue;
|
||||
Uri? uri = state.libraryToInputDill![lib.importUri];
|
||||
if (uri == null) {
|
||||
throw new StateError("Library ${lib.importUri} was recorded as used, "
|
||||
throw StateError("Library ${lib.importUri} was recorded as used, "
|
||||
"but was not in the list of known libraries.");
|
||||
}
|
||||
usedOutlines.add(uri);
|
||||
}
|
||||
var outputUsedFile = new File(parsedArgs["used-inputs"]);
|
||||
var outputUsedFile = File(parsedArgs["used-inputs"]);
|
||||
outputUsedFile.createSync(recursive: true);
|
||||
outputUsedFile.writeAsStringSync(usedOutlines.join("\n"));
|
||||
wroteUsedDills = true;
|
||||
|
@ -490,7 +492,7 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
|
||||
if (!wroteUsedDills && recordUsedInputs) {
|
||||
// The path taken didn't record inputs used: Say we used everything.
|
||||
var outputUsedFile = new File(parsedArgs["used-inputs"]);
|
||||
var outputUsedFile = File(parsedArgs["used-inputs"]);
|
||||
outputUsedFile.createSync(recursive: true);
|
||||
Set<Uri> allFiles = {...summaryInputs, ...linkedInputs};
|
||||
outputUsedFile.writeAsStringSync(allFiles.join("\n"));
|
||||
|
@ -498,14 +500,14 @@ Future<ComputeKernelResult> computeKernel(List<String> args,
|
|||
}
|
||||
|
||||
if (kernel != null) {
|
||||
var outputFile = new File(parsedArgs['output']);
|
||||
var outputFile = File(parsedArgs['output']);
|
||||
outputFile.createSync(recursive: true);
|
||||
outputFile.writeAsBytesSync(kernel);
|
||||
} else {
|
||||
assert(!succeeded);
|
||||
}
|
||||
|
||||
return new ComputeKernelResult(succeeded, state);
|
||||
return ComputeKernelResult(succeeded, state);
|
||||
}
|
||||
|
||||
/// Make sure the output is stable by sorting libraries and additional exports.
|
||||
|
@ -544,7 +546,9 @@ class _FakeFileSystem extends FileSystem {
|
|||
}
|
||||
|
||||
class DevCompilerSummaryTarget extends DevCompilerTarget with SummaryMixin {
|
||||
@override
|
||||
final List<Uri> sources;
|
||||
@override
|
||||
final bool excludeNonSources;
|
||||
|
||||
DevCompilerSummaryTarget(
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// ignore_for_file: implementation_imports, constant_identifier_names
|
||||
|
||||
// front_end/src imports below that require lint `ignore_for_file` are a
|
||||
// temporary state of things until frontend team builds better api that would
|
||||
// replace api used below. This api was made private in an effort to discourage
|
||||
// further use.
|
||||
|
||||
library frontend_server;
|
||||
|
||||
import 'dart:async';
|
||||
|
@ -16,14 +23,9 @@ import 'package:dev_compiler/dev_compiler.dart'
|
|||
ExpressionCompiler,
|
||||
parseModuleFormat,
|
||||
ProgramCompiler;
|
||||
|
||||
// front_end/src imports below that require lint `ignore_for_file`
|
||||
// are a temporary state of things until frontend team builds better api
|
||||
// that would replace api used below. This api was made private in
|
||||
// an effort to discourage further use.
|
||||
import 'package:front_end/src/api_unstable/vm.dart';
|
||||
import 'package:front_end/src/api_unstable/ddc.dart' as ddc
|
||||
show IncrementalCompiler;
|
||||
import 'package:front_end/src/api_unstable/vm.dart';
|
||||
import 'package:front_end/widget_cache.dart';
|
||||
import 'package:kernel/ast.dart' show Library, Procedure, LibraryDependency;
|
||||
import 'package:kernel/binary/ast_to_binary.dart';
|
||||
|
@ -32,7 +34,6 @@ import 'package:kernel/kernel.dart'
|
|||
import 'package:kernel/target/targets.dart' show targets, TargetFlags;
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:usage/uuid/uuid.dart';
|
||||
|
||||
import 'package:vm/incremental_compiler.dart' show IncrementalCompiler;
|
||||
import 'package:vm/kernel_front_end.dart';
|
||||
import 'package:vm/target_os.dart'; // For possible --target-os values.
|
||||
|
@ -279,7 +280,7 @@ abstract class CompilerInterface {
|
|||
|
||||
/// Assuming some Dart program was previously compiled, recompile it again
|
||||
/// taking into account some changed(invalidated) sources.
|
||||
Future<Null> recompileDelta({String? entryPoint});
|
||||
Future<void> recompileDelta({String? entryPoint});
|
||||
|
||||
/// Accept results of previous compilation so that next recompilation cycle
|
||||
/// won't recompile sources that were previously reported as changed.
|
||||
|
@ -305,7 +306,7 @@ abstract class CompilerInterface {
|
|||
/// If [klass] is [null],expression is compiled at top-level of
|
||||
/// [libraryUrl] library. If [klass] is not [null], [isStatic] determines
|
||||
/// whether expression can refer to [this] or not.
|
||||
Future<Null> compileExpression(
|
||||
Future<void> compileExpression(
|
||||
String expression,
|
||||
List<String> definitions,
|
||||
List<String> definitionTypes,
|
||||
|
@ -335,7 +336,7 @@ abstract class CompilerInterface {
|
|||
/// variable name is the name originally used in JavaScript to contain the
|
||||
/// module object, for example:
|
||||
/// { 'dart':'dart_sdk', 'main': '/packages/hello_world_main.dart' }
|
||||
Future<Null> compileExpressionToJs(
|
||||
Future<void> compileExpressionToJs(
|
||||
String libraryUri,
|
||||
int line,
|
||||
int column,
|
||||
|
@ -370,17 +371,17 @@ class FrontendCompiler implements CompilerInterface {
|
|||
this.emitDebugMetadata = false,
|
||||
this.emitDebugSymbols = false})
|
||||
: _outputStream = outputStream ?? stdout,
|
||||
printerFactory = printerFactory ?? new BinaryPrinterFactory();
|
||||
printerFactory = printerFactory ?? BinaryPrinterFactory();
|
||||
|
||||
/// Fields with initializers
|
||||
final List<String> errors = <String>[];
|
||||
Set<Uri> previouslyReportedDependencies = Set<Uri>();
|
||||
Set<Uri> previouslyReportedDependencies = <Uri>{};
|
||||
|
||||
/// Initialized in the constructor
|
||||
bool emitDebugMetadata;
|
||||
bool emitDebugSymbols;
|
||||
bool incrementalSerialization;
|
||||
StringSink _outputStream;
|
||||
final StringSink _outputStream;
|
||||
BinaryPrinterFactory printerFactory;
|
||||
bool useDebuggerModuleNames;
|
||||
|
||||
|
@ -782,16 +783,16 @@ class FrontendCompiler implements CompilerInterface {
|
|||
}
|
||||
}
|
||||
|
||||
Future<Null> invalidateIfInitializingFromDill() async {
|
||||
if (_assumeInitializeFromDillUpToDate) return null;
|
||||
if (_kernelBinaryFilename != _kernelBinaryFilenameFull) return null;
|
||||
Future<void> invalidateIfInitializingFromDill() async {
|
||||
if (_assumeInitializeFromDillUpToDate) return;
|
||||
if (_kernelBinaryFilename != _kernelBinaryFilenameFull) return;
|
||||
// If the generator is initialized, it's not going to initialize from dill
|
||||
// again anyway, so there's no reason to spend time invalidating what should
|
||||
// be invalidated by the normal approach anyway.
|
||||
if (_generator.initialized) return null;
|
||||
if (_generator.initialized) return;
|
||||
|
||||
final File f = File(_initializeFromDill);
|
||||
if (!f.existsSync()) return null;
|
||||
if (!f.existsSync()) return;
|
||||
|
||||
Component component;
|
||||
try {
|
||||
|
@ -799,7 +800,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
} catch (e) {
|
||||
// If we cannot load the dill file we shouldn't initialize from it.
|
||||
_generator = _createGenerator(null);
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
nextUri:
|
||||
|
@ -841,7 +842,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<Null> recompileDelta({String? entryPoint}) async {
|
||||
Future<void> recompileDelta({String? entryPoint}) async {
|
||||
final String boundaryKey = Uuid().generateV4();
|
||||
_outputStream.writeln('result $boundaryKey');
|
||||
await invalidateIfInitializingFromDill();
|
||||
|
@ -880,7 +881,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<Null> compileExpression(
|
||||
Future<void> compileExpression(
|
||||
String expression,
|
||||
List<String> definitions,
|
||||
List<String> definitionTypes,
|
||||
|
@ -924,7 +925,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
final Map<String, ProgramCompiler> cachedProgramCompilers = {};
|
||||
|
||||
@override
|
||||
Future<Null> compileExpressionToJs(
|
||||
Future<void> compileExpressionToJs(
|
||||
String libraryUri,
|
||||
int line,
|
||||
int column,
|
||||
|
@ -957,7 +958,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
|
||||
_processedOptions.ticker.logMs('Computed component');
|
||||
|
||||
final expressionCompiler = new ExpressionCompiler(
|
||||
final expressionCompiler = ExpressionCompiler(
|
||||
_compilerOptions,
|
||||
parseModuleFormat(_options['dartdevc-module-format'] as String),
|
||||
errors,
|
||||
|
@ -999,7 +1000,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
/// Map of already serialized dill data. All uris in a serialized component
|
||||
/// maps to the same blob of data. Used by
|
||||
/// [writePackagesToSinkAndTrimComponent].
|
||||
Map<Uri, List<int>> cachedPackageLibraries = Map<Uri, List<int>>();
|
||||
Map<Uri, List<int>> cachedPackageLibraries = <Uri, List<int>>{};
|
||||
|
||||
/// Map of dependencies for already serialized dill data.
|
||||
/// E.g. if blob1 dependents on blob2, but only using a single file from blob1
|
||||
|
@ -1007,7 +1008,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
/// dill file in a weird state that could cause the VM to crash if asked to
|
||||
/// forcefully compile everything. Used by
|
||||
/// [writePackagesToSinkAndTrimComponent].
|
||||
Map<Uri, List<Uri>> cachedPackageDependencies = Map<Uri, List<Uri>>();
|
||||
Map<Uri, List<Uri>> cachedPackageDependencies = <Uri, List<Uri>>{};
|
||||
|
||||
writePackagesToSinkAndTrimComponent(
|
||||
Component deltaProgram, Sink<List<int>> ioSink) {
|
||||
|
@ -1027,8 +1028,8 @@ class FrontendCompiler implements CompilerInterface {
|
|||
..clear()
|
||||
..addAll(libraries);
|
||||
|
||||
Map<String, List<Library>> newPackages = Map<String, List<Library>>();
|
||||
Set<List<int>> alreadyAdded = Set<List<int>>();
|
||||
Map<String, List<Library>> newPackages = <String, List<Library>>{};
|
||||
Set<List<int>> alreadyAdded = <List<int>>{};
|
||||
|
||||
addDataAndDependentData(List<int> data, Uri uri) {
|
||||
if (alreadyAdded.add(data)) {
|
||||
|
@ -1062,11 +1063,11 @@ class FrontendCompiler implements CompilerInterface {
|
|||
printer.writeComponentFile(singleLibrary);
|
||||
|
||||
// Record things this package blob dependent on.
|
||||
Set<Uri> libraryUris = Set<Uri>();
|
||||
Set<Uri> libraryUris = <Uri>{};
|
||||
for (Library lib in libraries) {
|
||||
libraryUris.add(lib.fileUri);
|
||||
}
|
||||
Set<Uri> deps = Set<Uri>();
|
||||
Set<Uri> deps = <Uri>{};
|
||||
for (Library lib in libraries) {
|
||||
for (LibraryDependency dep in lib.dependencies) {
|
||||
Library dependencyLibrary = dep.importedLibraryReference.asLibrary;
|
||||
|
@ -1156,7 +1157,7 @@ class FrontendCompiler implements CompilerInterface {
|
|||
|
||||
/// Runs the given function [f] in a Zone that redirects all prints into
|
||||
/// [_outputStream].
|
||||
Future<T> _runWithPrintRedirection<T>(Future<T> f()) {
|
||||
Future<T> _runWithPrintRedirection<T>(Future<T> Function() f) {
|
||||
return runZoned(() => Future<T>(f),
|
||||
zoneSpecification: ZoneSpecification(
|
||||
print: (Zone self, ZoneDelegate parent, Zone zone, String line) =>
|
||||
|
@ -1168,10 +1169,12 @@ class FrontendCompiler implements CompilerInterface {
|
|||
class ByteSink implements Sink<List<int>> {
|
||||
final BytesBuilder builder = BytesBuilder();
|
||||
|
||||
@override
|
||||
void add(List<int> data) {
|
||||
builder.add(data);
|
||||
}
|
||||
|
||||
@override
|
||||
void close() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,18 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
// @dart = 2.15
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io' as io;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:_fe_analyzer_shared/src/macros/compiler/request_channel.dart';
|
||||
import 'package:front_end/src/base/nnbd_mode.dart' as fe;
|
||||
import 'package:front_end/src/api_prototype/compiler_options.dart' as fe;
|
||||
import 'package:front_end/src/api_prototype/file_system.dart' as fe;
|
||||
import 'package:front_end/src/api_prototype/kernel_generator.dart' as fe;
|
||||
import 'package:front_end/src/base/nnbd_mode.dart' as fe;
|
||||
import 'package:front_end/src/fasta/kernel/utils.dart' as fe;
|
||||
import 'package:kernel/ast.dart' as fe;
|
||||
import 'package:kernel/target/targets.dart' as fe;
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:front_end/src/api_unstable/vm.dart' show FileSystem;
|
||||
import 'package:dev_compiler/dev_compiler.dart';
|
||||
import 'package:front_end/src/api_unstable/vm.dart' show FileSystem;
|
||||
import 'package:kernel/ast.dart';
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
import 'package:kernel/core_types.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
import 'strong_components.dart';
|
||||
|
||||
/// Produce a special bundle format for compiled JavaScript.
|
||||
|
@ -306,8 +309,8 @@ class IncrementalJavaScriptBundler {
|
|||
final resolvedUri = packageConfig.resolve(componentUri)!;
|
||||
final package = packageConfig.packageOf(resolvedUri)!;
|
||||
final root = package.root;
|
||||
final relativeRoot = root.pathSegments
|
||||
.lastWhere((segment) => segment.isNotEmpty, orElse: null);
|
||||
final relativeRoot =
|
||||
root.pathSegments.lastWhere((segment) => segment.isNotEmpty);
|
||||
final relativeUrl = resolvedUri.toString().replaceFirst('$root', '');
|
||||
|
||||
// Relative component url (used as server path in the browser):
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// ignore_for_file: implementation_imports
|
||||
|
||||
// front_end/src imports below that require lint `ignore_for_file` are a
|
||||
// temporary state of things until frontend team builds better api that would
|
||||
// replace api used below. This api was made private in an effort to discourage
|
||||
// further use.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io'
|
||||
|
@ -9,11 +16,6 @@ import 'dart:io'
|
|||
import 'dart:typed_data' show Uint8List;
|
||||
|
||||
import 'package:args/args.dart';
|
||||
|
||||
// front_end/src imports below that require lint `ignore_for_file`
|
||||
// are a temporary state of things until frontend team builds better api
|
||||
// that would replace api used below. This api was made private in
|
||||
// an effort to discourage further use.
|
||||
import 'package:front_end/src/api_unstable/vm.dart';
|
||||
|
||||
import '../frontend_server.dart';
|
||||
|
@ -22,7 +24,7 @@ import '../frontend_server.dart';
|
|||
/// source files on all platforms. This has no effect on correctness,
|
||||
/// but may result in more files being marked as modified than strictly
|
||||
/// required.
|
||||
const _STAT_GRANULARITY = const Duration(seconds: 1);
|
||||
const _stateGranularity = Duration(seconds: 1);
|
||||
|
||||
/// Ensures the info file is removed if Ctrl-C is sent to the server.
|
||||
/// Mostly used when debugging.
|
||||
|
@ -36,16 +38,16 @@ extension on DateTime {
|
|||
/// granularity. We must floor the system time
|
||||
/// by 1 second so that if a file is modified within the same second of
|
||||
/// the last compile time, it will be correctly detected as being modified.
|
||||
DateTime floorTime({Duration amount = _STAT_GRANULARITY}) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(this.millisecondsSinceEpoch -
|
||||
this.millisecondsSinceEpoch % amount.inMilliseconds);
|
||||
DateTime floorTime({Duration amount = _stateGranularity}) {
|
||||
return DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch -
|
||||
millisecondsSinceEpoch % amount.inMilliseconds);
|
||||
}
|
||||
}
|
||||
|
||||
enum _ResidentState {
|
||||
WAITING_FOR_FIRST_COMPILE,
|
||||
COMPILING,
|
||||
WAITING_FOR_RECOMPILE,
|
||||
waitingForFirstCompile,
|
||||
compiling,
|
||||
waitingForRecompile,
|
||||
}
|
||||
|
||||
/// A wrapper around the FrontendCompiler, along with all the state needed
|
||||
|
@ -64,13 +66,13 @@ enum _ResidentState {
|
|||
/// TODO Fix the race condition that occurs when the same entry point is
|
||||
/// compiled concurrently.
|
||||
class ResidentCompiler {
|
||||
File _entryPoint;
|
||||
File _outputDill;
|
||||
final File _entryPoint;
|
||||
final File _outputDill;
|
||||
File? _currentPackage;
|
||||
ArgResults _compileOptions;
|
||||
late FrontendCompiler _compiler;
|
||||
DateTime _lastCompileStartTime = DateTime.now().floorTime();
|
||||
_ResidentState _state = _ResidentState.WAITING_FOR_FIRST_COMPILE;
|
||||
_ResidentState _state = _ResidentState.waitingForFirstCompile;
|
||||
final StringBuffer _compilerOutput = StringBuffer();
|
||||
final Set<Uri> trackedSources = <Uri>{};
|
||||
final List<String> _formattedOutput = <String>[];
|
||||
|
@ -91,7 +93,7 @@ class ResidentCompiler {
|
|||
// Refresh the compiler's output for the next compile
|
||||
_compilerOutput.clear();
|
||||
_formattedOutput.clear();
|
||||
_state = _ResidentState.WAITING_FOR_FIRST_COMPILE;
|
||||
_state = _ResidentState.waitingForFirstCompile;
|
||||
}
|
||||
|
||||
/// The current compiler options are outdated when any option has changed
|
||||
|
@ -121,7 +123,7 @@ class ResidentCompiler {
|
|||
// check which source files need to be recompiled in the incremental
|
||||
// compilation request. If no files have been modified, we can return
|
||||
// the cached kernel. Otherwise, perform an incremental compilation.
|
||||
if (_state == _ResidentState.WAITING_FOR_RECOMPILE) {
|
||||
if (_state == _ResidentState.waitingForRecompile) {
|
||||
var invalidatedUris =
|
||||
await _getSourceFilesToRecompile(_lastCompileStartTime);
|
||||
// No changes to source files detected and cached kernel file exists
|
||||
|
@ -132,15 +134,16 @@ class ResidentCompiler {
|
|||
_outputDill.path, _formattedOutput, _compiler.errors.length,
|
||||
usingCachedKernel: true);
|
||||
}
|
||||
_state = _ResidentState.COMPILING;
|
||||
_state = _ResidentState.compiling;
|
||||
incremental = true;
|
||||
invalidatedUris
|
||||
.forEach((invalidatedUri) => _compiler.invalidate(invalidatedUri));
|
||||
for (var invalidatedUri in invalidatedUris) {
|
||||
_compiler.invalidate(invalidatedUri);
|
||||
}
|
||||
_compiler.errors.clear();
|
||||
_lastCompileStartTime = DateTime.now().floorTime();
|
||||
await _compiler.recompileDelta(entryPoint: _entryPoint.path);
|
||||
} else {
|
||||
_state = _ResidentState.COMPILING;
|
||||
_state = _ResidentState.compiling;
|
||||
_lastCompileStartTime = DateTime.now().floorTime();
|
||||
_compiler.errors.clear();
|
||||
await _compiler.compile(_entryPoint.path, _compileOptions);
|
||||
|
@ -158,9 +161,9 @@ class ResidentCompiler {
|
|||
_compiler
|
||||
..acceptLastDelta()
|
||||
..resetIncrementalCompiler();
|
||||
_state = _ResidentState.WAITING_FOR_RECOMPILE;
|
||||
_state = _ResidentState.waitingForRecompile;
|
||||
} else {
|
||||
_state = _ResidentState.WAITING_FOR_FIRST_COMPILE;
|
||||
_state = _ResidentState.waitingForFirstCompile;
|
||||
}
|
||||
return _encodeCompilerOutput(
|
||||
_outputDill.path, _formattedOutput, _compiler.errors.length,
|
||||
|
@ -458,9 +461,8 @@ Future<StreamSubscription<Socket>?> residentListenAndCompile(
|
|||
throw StateError('A server is already running.');
|
||||
}
|
||||
server = await ServerSocket.bind(address, port);
|
||||
serverInfoFile
|
||||
..writeAsStringSync(
|
||||
'address:${server.address.address} port:${server.port}');
|
||||
serverInfoFile.writeAsStringSync(
|
||||
'address:${server.address.address} port:${server.port}');
|
||||
} on StateError catch (e) {
|
||||
print('Error: $e\n');
|
||||
return null;
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:kernel/ast.dart';
|
||||
import 'package:kernel/util/graph.dart';
|
||||
// ignore_for_file: implementation_imports
|
||||
|
||||
import 'package:front_end/src/api_unstable/vm.dart' show FileSystem;
|
||||
import 'package:kernel/ast.dart';
|
||||
import 'package:kernel/util/graph.dart';
|
||||
|
||||
/// Compute the strongly connected components for JavaScript compilation.
|
||||
///
|
||||
|
@ -79,7 +80,7 @@ class StrongComponents {
|
|||
}
|
||||
|
||||
if (entrypoint == null) {
|
||||
throw Exception('Could not find entrypoint ${mainUri} in Component.');
|
||||
throw Exception('Could not find entrypoint $mainUri in Component.');
|
||||
}
|
||||
|
||||
final List<List<Library>> results = computeStrongComponents(
|
||||
|
|
|
@ -6,18 +6,15 @@ import 'dart:async' show StreamController;
|
|||
import 'dart:convert' show utf8, LineSplitter;
|
||||
import 'dart:io' show Directory, File, FileSystemEntity, IOSink, exitCode;
|
||||
|
||||
import 'package:front_end/src/api_prototype/language_version.dart'
|
||||
show uriUsesLegacyLanguageVersion;
|
||||
import 'package:front_end/src/api_unstable/vm.dart'
|
||||
show CompilerOptions, NnbdMode, StandardFileSystem;
|
||||
import 'package:frontend_server/starter.dart';
|
||||
import 'package:kernel/ast.dart' show Component;
|
||||
import 'package:kernel/kernel.dart' show loadComponentFromBytes;
|
||||
import 'package:kernel/verifier.dart' show verifyComponent;
|
||||
|
||||
import 'package:front_end/src/api_prototype/language_version.dart'
|
||||
show uriUsesLegacyLanguageVersion;
|
||||
|
||||
import 'package:front_end/src/api_unstable/vm.dart'
|
||||
show CompilerOptions, NnbdMode, StandardFileSystem;
|
||||
|
||||
import 'package:frontend_server/starter.dart';
|
||||
|
||||
main(List<String> args) async {
|
||||
String? flutterDir;
|
||||
String? flutterPlatformDir;
|
||||
|
@ -29,11 +26,11 @@ main(List<String> args) async {
|
|||
}
|
||||
}
|
||||
|
||||
await compileTests(flutterDir, flutterPlatformDir, new StdoutLogger());
|
||||
await compileTests(flutterDir, flutterPlatformDir, StdoutLogger());
|
||||
}
|
||||
|
||||
Future<NnbdMode> _getNNBDMode(Uri script, Uri packageConfigUri) async {
|
||||
final CompilerOptions compilerOptions = new CompilerOptions()
|
||||
final CompilerOptions compilerOptions = CompilerOptions()
|
||||
..sdkRoot = null
|
||||
..fileSystem = StandardFileSystem.instance
|
||||
..packagesFileUri = packageConfigUri
|
||||
|
@ -49,7 +46,7 @@ Future<NnbdMode> _getNNBDMode(Uri script, Uri packageConfigUri) async {
|
|||
Future compileTests(
|
||||
String? flutterDir, String? flutterPlatformDir, Logger logger,
|
||||
{String? filter, int shards = 1, int shard = 0}) async {
|
||||
if (flutterDir == null || !(new Directory(flutterDir).existsSync())) {
|
||||
if (flutterDir == null || !(Directory(flutterDir).existsSync())) {
|
||||
throw "Didn't get a valid flutter directory to work with.";
|
||||
}
|
||||
if (shards < 1) {
|
||||
|
@ -63,17 +60,17 @@ Future compileTests(
|
|||
}
|
||||
// Ensure the path ends in a slash.
|
||||
final Directory flutterDirectory =
|
||||
new Directory.fromUri(new Directory(flutterDir).uri);
|
||||
Directory.fromUri(Directory(flutterDir).uri);
|
||||
|
||||
List<FileSystemEntity> allFlutterFiles =
|
||||
flutterDirectory.listSync(recursive: true, followLinks: false);
|
||||
Directory flutterPlatformDirectoryTmp;
|
||||
|
||||
if (flutterPlatformDir == null) {
|
||||
List<File> platformFiles = new List<File>.from(allFlutterFiles.where((f) =>
|
||||
f.uri
|
||||
.toString()
|
||||
.endsWith("/flutter_patched_sdk/platform_strong.dill")));
|
||||
List<File> platformFiles = List<File>.from(allFlutterFiles.where((f) => f
|
||||
.uri
|
||||
.toString()
|
||||
.endsWith("/flutter_patched_sdk/platform_strong.dill")));
|
||||
if (platformFiles.isEmpty) {
|
||||
throw "Expected to find a flutter platform file but didn't.";
|
||||
}
|
||||
|
@ -86,20 +83,19 @@ Future compileTests(
|
|||
}
|
||||
// Ensure the path ends in a slash.
|
||||
final Directory flutterPlatformDirectory =
|
||||
new Directory.fromUri(flutterPlatformDirectoryTmp.uri);
|
||||
Directory.fromUri(flutterPlatformDirectoryTmp.uri);
|
||||
|
||||
if (!new File.fromUri(
|
||||
if (!File.fromUri(
|
||||
flutterPlatformDirectory.uri.resolve("platform_strong.dill"))
|
||||
.existsSync()) {
|
||||
throw "$flutterPlatformDirectory doesn't contain a "
|
||||
"platform_strong.dill file.";
|
||||
}
|
||||
logger.notice("Using $flutterPlatformDirectory as platform directory.");
|
||||
List<File> packageConfigFiles = new List<File>.from(allFlutterFiles.where(
|
||||
(f) =>
|
||||
(f.uri.toString().contains("/examples/") ||
|
||||
f.uri.toString().contains("/packages/")) &&
|
||||
f.uri.toString().endsWith("/.dart_tool/package_config.json")));
|
||||
List<File> packageConfigFiles = List<File>.from(allFlutterFiles.where((f) =>
|
||||
(f.uri.toString().contains("/examples/") ||
|
||||
f.uri.toString().contains("/packages/")) &&
|
||||
f.uri.toString().endsWith("/.dart_tool/package_config.json")));
|
||||
|
||||
List<String> allCompilationErrors = [];
|
||||
final Directory systemTempDir = Directory.systemTemp;
|
||||
|
@ -108,7 +104,7 @@ Future compileTests(
|
|||
for (int i = 0; i < packageConfigFiles.length; i++) {
|
||||
File packageConfig = packageConfigFiles[i];
|
||||
Directory testDir =
|
||||
new Directory.fromUri(packageConfig.parent.uri.resolve("../test/"));
|
||||
Directory.fromUri(packageConfig.parent.uri.resolve("../test/"));
|
||||
if (!testDir.existsSync()) continue;
|
||||
if (testDir.toString().contains("packages/flutter_web_plugins/test/")) {
|
||||
// TODO(jensj): Figure out which tests are web-tests, and compile those
|
||||
|
@ -116,7 +112,7 @@ Future compileTests(
|
|||
continue;
|
||||
}
|
||||
List<File> testFiles =
|
||||
new List<File>.from(testDir.listSync(recursive: true).where((f) {
|
||||
List<File>.from(testDir.listSync(recursive: true).where((f) {
|
||||
if (!f.path.endsWith("_test.dart")) return false;
|
||||
if (filter != null) {
|
||||
String testName = f.path.substring(flutterDirectory.path.length);
|
||||
|
@ -142,7 +138,7 @@ Future compileTests(
|
|||
}
|
||||
for (List<File> files in [weak, strong]) {
|
||||
if (files.isEmpty) continue;
|
||||
queue.add(new _QueueEntry(files, packageConfig, testDir));
|
||||
queue.add(_QueueEntry(files, packageConfig, testDir));
|
||||
totalFiles += files.length;
|
||||
}
|
||||
}
|
||||
|
@ -240,14 +236,14 @@ Future<List<String>> attemptStuff(
|
|||
String? filter) async {
|
||||
if (testFiles.isEmpty) return [];
|
||||
|
||||
File dillFile = new File('${tempDir.path}/dill.dill');
|
||||
File dillFile = File('${tempDir.path}/dill.dill');
|
||||
if (dillFile.existsSync()) {
|
||||
throw "$dillFile already exists.";
|
||||
}
|
||||
|
||||
List<int> platformData = new File.fromUri(
|
||||
flutterPlatformDirectory.uri.resolve("platform_strong.dill"))
|
||||
.readAsBytesSync();
|
||||
List<int> platformData =
|
||||
File.fromUri(flutterPlatformDirectory.uri.resolve("platform_strong.dill"))
|
||||
.readAsBytesSync();
|
||||
final List<String> args = <String>[
|
||||
'--sdk-root',
|
||||
flutterPlatformDirectory.path,
|
||||
|
@ -259,16 +255,16 @@ Future<List<String>> attemptStuff(
|
|||
// '--unsafe-package-serialization',
|
||||
];
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch()..start();
|
||||
Stopwatch stopwatch = Stopwatch()..start();
|
||||
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
new StreamController<List<int>>();
|
||||
StreamController<List<int>>();
|
||||
final StreamController<List<int>> stdoutStreamController =
|
||||
new StreamController<List<int>>();
|
||||
final IOSink ioSink = new IOSink(stdoutStreamController.sink);
|
||||
StreamController<Result> receivedResults = new StreamController<Result>();
|
||||
StreamController<List<int>>();
|
||||
final IOSink ioSink = IOSink(stdoutStreamController.sink);
|
||||
StreamController<Result> receivedResults = StreamController<Result>();
|
||||
|
||||
final outputParser = new OutputParser(receivedResults);
|
||||
final outputParser = OutputParser(receivedResults);
|
||||
stdoutStreamController.stream
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
|
@ -284,7 +280,7 @@ Future<List<String>> attemptStuff(
|
|||
|
||||
logger.logTestStart(testName);
|
||||
logger.notice(" => $testName");
|
||||
Stopwatch stopwatch2 = new Stopwatch()..start();
|
||||
Stopwatch stopwatch2 = Stopwatch()..start();
|
||||
inputStreamController
|
||||
.add('compile ${testFileIterator.current.path}\n'.codeUnits);
|
||||
int compilations = 0;
|
||||
|
@ -354,7 +350,7 @@ class OutputParser {
|
|||
OutputParser(this._receivedResults);
|
||||
bool expectSources = true;
|
||||
|
||||
StreamController<Result> _receivedResults;
|
||||
final StreamController<Result> _receivedResults;
|
||||
List<String>? _receivedSources;
|
||||
|
||||
String? _boundaryKey;
|
||||
|
@ -365,9 +361,9 @@ class OutputParser {
|
|||
void listener(String s) {
|
||||
allReceived.add(s);
|
||||
if (_boundaryKey == null) {
|
||||
const String RESULT_OUTPUT_SPACE = 'result ';
|
||||
if (s.startsWith(RESULT_OUTPUT_SPACE)) {
|
||||
_boundaryKey = s.substring(RESULT_OUTPUT_SPACE.length);
|
||||
const String resultOutputSpace = 'result ';
|
||||
if (s.startsWith(resultOutputSpace)) {
|
||||
_boundaryKey = s.substring(resultOutputSpace.length);
|
||||
}
|
||||
_readingSources = false;
|
||||
_receivedSources?.clear();
|
||||
|
@ -384,7 +380,7 @@ class OutputParser {
|
|||
}
|
||||
// Second boundaryKey indicates end of frontend server response
|
||||
expectSources = true;
|
||||
_receivedResults.add(new Result(
|
||||
_receivedResults.add(Result(
|
||||
s.length > _boundaryKey!.length
|
||||
? s.substring(_boundaryKey!.length + 1)
|
||||
: null,
|
||||
|
@ -405,7 +401,7 @@ class Result {
|
|||
Result(this.status, this.sources);
|
||||
|
||||
void expectNoErrors({String? filename}) {
|
||||
CompilationResult result = new CompilationResult.parse(status!);
|
||||
CompilationResult result = CompilationResult.parse(status!);
|
||||
if (result.errorsCount != 0) {
|
||||
throw "Got ${result.errorsCount} errors. Expected 0.";
|
||||
}
|
||||
|
@ -443,7 +439,7 @@ abstract class Logger {
|
|||
}
|
||||
|
||||
class StdoutLogger extends Logger {
|
||||
List<String> _log = <String>[];
|
||||
final List<String> _log = <String>[];
|
||||
|
||||
@override
|
||||
void logExpectedResult(String testName) {
|
||||
|
@ -466,10 +462,12 @@ class StdoutLogger extends Logger {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void log(String s) {
|
||||
_log.add(s);
|
||||
}
|
||||
|
||||
@override
|
||||
void notice(String s) {
|
||||
print(s);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class Options {
|
|||
this.flutterPlatformDir);
|
||||
|
||||
static Options parse(List<String> args) {
|
||||
var parser = new ArgParser()
|
||||
var parser = ArgParser()
|
||||
..addOption("named-configuration",
|
||||
abbr: "n",
|
||||
defaultsTo: suiteNamePrefix,
|
||||
|
@ -70,7 +70,7 @@ class Options {
|
|||
class ResultLogger extends Logger {
|
||||
final SuiteConfiguration suiteConfiguration;
|
||||
final Map<String, Stopwatch> stopwatches = {};
|
||||
List<String> _log = <String>[];
|
||||
final List<String> _log = <String>[];
|
||||
|
||||
ResultLogger(this.suiteConfiguration);
|
||||
|
||||
|
@ -106,10 +106,11 @@ class ResultLogger extends Logger {
|
|||
}
|
||||
if (suiteConfiguration.verbose) {
|
||||
String result = matchedExpectations ? "PASS" : "FAIL";
|
||||
print("${fullTestName}: ${result}");
|
||||
print("$fullTestName: $result");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void logTestStart(String testName) {
|
||||
stopwatches[testName] = Stopwatch()..start();
|
||||
_log.clear();
|
||||
|
@ -189,9 +190,9 @@ main([List<String> arguments = const <String>[]]) async {
|
|||
List<String> results = [];
|
||||
List<String> logs = [];
|
||||
Options options = Options.parse(arguments);
|
||||
ReceivePort resultsPort = new ReceivePort()
|
||||
ReceivePort resultsPort = ReceivePort()
|
||||
..listen((resultEntry) => results.add(resultEntry));
|
||||
ReceivePort logsPort = new ReceivePort()
|
||||
ReceivePort logsPort = ReceivePort()
|
||||
..listen((logEntry) => logs.add(logEntry));
|
||||
String? filter = options.testFilter;
|
||||
|
||||
|
@ -199,9 +200,9 @@ main([List<String> arguments = const <String>[]]) async {
|
|||
List<Future<bool>> futures = [];
|
||||
for (int shard = 0; shard < shards; shard++) {
|
||||
// Start the test suite in a new isolate.
|
||||
ReceivePort exitPort = new ReceivePort();
|
||||
ReceivePort errorPort = new ReceivePort();
|
||||
SuiteConfiguration configuration = new SuiteConfiguration(
|
||||
ReceivePort exitPort = ReceivePort();
|
||||
ReceivePort errorPort = ReceivePort();
|
||||
SuiteConfiguration configuration = SuiteConfiguration(
|
||||
resultsPort.sendPort,
|
||||
logsPort.sendPort,
|
||||
options.verbose,
|
||||
|
@ -237,7 +238,7 @@ main([List<String> arguments = const <String>[]]) async {
|
|||
timer.cancel();
|
||||
if (!timedOut && !gotError) {
|
||||
int seconds = stopwatch.elapsedMilliseconds ~/ 1000;
|
||||
print("Suite finished (shard #$shard) (took ${seconds} seconds)");
|
||||
print("Suite finished (shard #$shard) (took $seconds seconds)");
|
||||
}
|
||||
return timedOut || gotError;
|
||||
});
|
||||
|
|
|
@ -10,8 +10,8 @@ import 'dart:io';
|
|||
import 'dart:isolate';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:_fe_analyzer_shared/src/macros/compiler/request_channel.dart';
|
||||
import 'package:args/args.dart';
|
||||
import 'package:front_end/src/api_unstable/vm.dart';
|
||||
import 'package:frontend_server/frontend_server.dart';
|
||||
import 'package:frontend_server/starter.dart';
|
||||
|
@ -54,7 +54,7 @@ class _MockedCompiler implements CompilerInterface {
|
|||
this.verifyRecompileDelta = nopVerifyRecompileDelta,
|
||||
this.verifyInvalidate = nopVerifyInvalidate,
|
||||
this.verifyAcceptLastDelta = nopVerify,
|
||||
this.verifyResetIncrementalCompiler = nopVerify}) {}
|
||||
this.verifyResetIncrementalCompiler = nopVerify});
|
||||
|
||||
@override
|
||||
void acceptLastDelta() {
|
||||
|
@ -62,7 +62,7 @@ class _MockedCompiler implements CompilerInterface {
|
|||
}
|
||||
|
||||
@override
|
||||
Future<Null> recompileDelta({String? entryPoint}) async {
|
||||
Future<void> recompileDelta({String? entryPoint}) async {
|
||||
verifyRecompileDelta(entryPoint);
|
||||
}
|
||||
|
||||
|
@ -124,10 +124,11 @@ void main() async {
|
|||
|
||||
group('batch compile with mocked compiler', () {
|
||||
test('compile from command line', () async {
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final List<String> args = <String>[
|
||||
'server.dart',
|
||||
|
@ -138,11 +139,12 @@ void main() async {
|
|||
});
|
||||
|
||||
test('compile from command line with link platform', () async {
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
expect(opts['link-platform'], equals(true));
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final List<String> args = <String>[
|
||||
'server.dart',
|
||||
|
@ -154,12 +156,13 @@ void main() async {
|
|||
});
|
||||
|
||||
test('compile from command line with widget cache', () async {
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
expect(opts['link-platform'], equals(true));
|
||||
expect(opts['flutter-widget-cache'], equals(true));
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final List<String> args = <String>[
|
||||
'server.dart',
|
||||
|
@ -179,11 +182,12 @@ void main() async {
|
|||
|
||||
test('compile one file', () async {
|
||||
final compileCalled = ReceivePort();
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
compileCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
StreamController<List<int>>();
|
||||
|
@ -201,11 +205,12 @@ void main() async {
|
|||
|
||||
test('compile one file to JavaScript', () async {
|
||||
final compileCalled = ReceivePort();
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
compileCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
StreamController<List<int>>();
|
||||
|
@ -231,11 +236,12 @@ void main() async {
|
|||
|
||||
test('compile one file', () async {
|
||||
final compileCalled = ReceivePort();
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
compileCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
StreamController<List<int>>();
|
||||
|
@ -254,11 +260,12 @@ void main() async {
|
|||
test('compile few files', () async {
|
||||
final compileCalled = ReceivePort();
|
||||
int counter = 1;
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(entryPoint, equals('server${counter++}.dart'));
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
compileCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
StreamController<List<int>>();
|
||||
|
@ -287,15 +294,17 @@ void main() async {
|
|||
final recompileDeltaCalled = ReceivePort();
|
||||
int invalidated = 0;
|
||||
int counter = 1;
|
||||
final verifyI = (Uri uri) {
|
||||
verifyI(Uri uri) {
|
||||
expect(uri.path, contains('file${counter++}.dart'));
|
||||
invalidated += 1;
|
||||
};
|
||||
final verifyR = (String? entryPoint) {
|
||||
}
|
||||
|
||||
verifyR(String? entryPoint) {
|
||||
expect(invalidated, equals(2));
|
||||
expect(entryPoint, equals(null));
|
||||
recompileDeltaCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(
|
||||
verifyInvalidate: verifyI, verifyRecompileDelta: verifyR);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
|
@ -318,15 +327,17 @@ void main() async {
|
|||
test('recompile one file with widget cache does not fail', () async {
|
||||
final recompileDeltaCalled = ReceivePort();
|
||||
bool invalidated = false;
|
||||
final verifyR = (String? entryPoint) {
|
||||
verifyR(String? entryPoint) {
|
||||
expect(invalidated, equals(true));
|
||||
expect(entryPoint, equals(null));
|
||||
recompileDeltaCalled.sendPort.send(true);
|
||||
};
|
||||
final verifyI = (Uri uri) {
|
||||
}
|
||||
|
||||
verifyI(Uri uri) {
|
||||
invalidated = true;
|
||||
expect(uri.path, contains('file1.dart'));
|
||||
};
|
||||
}
|
||||
|
||||
// The component will not contain the flutter framework sources so
|
||||
// this should no-op.
|
||||
final compiler = _MockedCompiler(
|
||||
|
@ -350,15 +361,17 @@ void main() async {
|
|||
int invalidated = 0;
|
||||
final recompileDeltaCalled = ReceivePort();
|
||||
int counter = 1;
|
||||
final verifyI = (Uri uri) {
|
||||
verifyI(Uri uri) {
|
||||
expect(uri.path, contains('file${counter++}.dart'));
|
||||
invalidated += 1;
|
||||
};
|
||||
final verifyR = (String? entryPoint) {
|
||||
}
|
||||
|
||||
verifyR(String? entryPoint) {
|
||||
expect(invalidated, equals(2));
|
||||
expect(entryPoint, equals('file2.dart'));
|
||||
recompileDeltaCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(
|
||||
verifyRecompileDelta: verifyR, verifyInvalidate: verifyI);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
|
@ -379,9 +392,10 @@ void main() async {
|
|||
|
||||
test('accept', () async {
|
||||
final acceptCalled = ReceivePort();
|
||||
final verify = () {
|
||||
verify() {
|
||||
acceptCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyAcceptLastDelta: verify);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
StreamController<List<int>>();
|
||||
|
@ -399,9 +413,10 @@ void main() async {
|
|||
|
||||
test('reset', () async {
|
||||
final resetCalled = ReceivePort();
|
||||
final verify = () {
|
||||
verify() {
|
||||
resetCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyResetIncrementalCompiler: verify);
|
||||
final StreamController<List<int>> inputStreamController =
|
||||
StreamController<List<int>>();
|
||||
|
@ -422,28 +437,32 @@ void main() async {
|
|||
bool compile = false;
|
||||
int invalidate = 0;
|
||||
bool acceptDelta = false;
|
||||
final verifyC = (String entryPoint, ArgResults opts) {
|
||||
verifyC(String entryPoint, ArgResults opts) {
|
||||
compile = true;
|
||||
expect(entryPoint, equals('file1.dart'));
|
||||
};
|
||||
final verifyA = () {
|
||||
}
|
||||
|
||||
verifyA() {
|
||||
expect(compile, equals(true));
|
||||
acceptDelta = true;
|
||||
};
|
||||
}
|
||||
|
||||
int counter = 2;
|
||||
final verifyI = (Uri uri) {
|
||||
verifyI(Uri uri) {
|
||||
expect(compile, equals(true));
|
||||
expect(acceptDelta, equals(true));
|
||||
expect(uri.path, contains('file${counter++}.dart'));
|
||||
invalidate += 1;
|
||||
};
|
||||
final verifyR = (String? entryPoint) {
|
||||
}
|
||||
|
||||
verifyR(String? entryPoint) {
|
||||
expect(compile, equals(true));
|
||||
expect(invalidate, equals(2));
|
||||
expect(acceptDelta, equals(true));
|
||||
expect(entryPoint, equals(null));
|
||||
recompileDeltaCalled.sendPort.send(true);
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(
|
||||
verifyCompile: verifyC,
|
||||
verifyRecompileDelta: verifyR,
|
||||
|
@ -496,10 +515,10 @@ void main() async {
|
|||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen((String s) {
|
||||
const String RESULT_OUTPUT_SPACE = 'result ';
|
||||
const String resultOutputSpace = 'result ';
|
||||
if (boundaryKey == null) {
|
||||
if (s.startsWith(RESULT_OUTPUT_SPACE)) {
|
||||
boundaryKey = s.substring(RESULT_OUTPUT_SPACE.length);
|
||||
if (s.startsWith(resultOutputSpace)) {
|
||||
boundaryKey = s.substring(resultOutputSpace.length);
|
||||
}
|
||||
} else {
|
||||
if (s.startsWith(boundaryKey!)) {
|
||||
|
@ -536,9 +555,10 @@ void main() async {
|
|||
});
|
||||
|
||||
group('compile with output path', () {
|
||||
final verify = (String entryPoint, ArgResults opts) {
|
||||
verify(String entryPoint, ArgResults opts) {
|
||||
expect(opts['sdk-root'], equals('sdkroot'));
|
||||
};
|
||||
}
|
||||
|
||||
final compiler = _MockedCompiler(verifyCompile: verify);
|
||||
test('compile from command line', () async {
|
||||
final List<String> args = <String>[
|
||||
|
@ -568,7 +588,7 @@ void main() async {
|
|||
setUp(() {
|
||||
var systemTempDir = Directory.systemTemp;
|
||||
tempDir = systemTempDir.createTempSync('frontendServerTest');
|
||||
new Directory('${tempDir.path}/.dart_tool').createSync();
|
||||
Directory('${tempDir.path}/.dart_tool').createSync();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
|
@ -1690,7 +1710,7 @@ class BarState extends State<FizzWidget> {
|
|||
|
||||
final host = serverSocket.address.address;
|
||||
final addressStr = '$host:${serverSocket.port}';
|
||||
expect(await starter(['--binary-protocol-address=${addressStr}']), 0);
|
||||
expect(await starter(['--binary-protocol-address=$addressStr']), 0);
|
||||
|
||||
await testFinished.future;
|
||||
}
|
||||
|
@ -2241,8 +2261,7 @@ e() {
|
|||
|
||||
var source = sourceFile.readAsStringSync();
|
||||
// Split on the comment at the end of each module.
|
||||
var jsModules =
|
||||
source.split(RegExp("\/\/# sourceMappingURL=.*\.map"));
|
||||
var jsModules = source.split(RegExp("//# sourceMappingURL=.*.map"));
|
||||
|
||||
expect(jsModules[0], contains('<<a>>'));
|
||||
expect(jsModules[0], contains('<<b>>'));
|
||||
|
@ -2281,8 +2300,7 @@ d() {
|
|||
|
||||
var source = incrementalSourceFile.readAsStringSync();
|
||||
// Split on the comment at the end of each module.
|
||||
var jsModules =
|
||||
source.split(RegExp("\/\/# sourceMappingURL=.*\.map"));
|
||||
var jsModules = source.split(RegExp("//# sourceMappingURL=.*.map"));
|
||||
|
||||
expect(jsModules[0], not(contains('<<a>>')));
|
||||
expect(jsModules[0], not(contains('<<b>>')));
|
||||
|
@ -2317,8 +2335,7 @@ e() {
|
|||
|
||||
var source = incrementalSourceFile.readAsStringSync();
|
||||
// Split on the comment at the end of each module.
|
||||
var jsModules =
|
||||
source.split(RegExp("\/\/# sourceMappingURL=.*\.map"));
|
||||
var jsModules = source.split(RegExp("//# sourceMappingURL=.*.map"));
|
||||
|
||||
expect(jsModules[0], not(contains('<<a>>')));
|
||||
expect(jsModules[0], not(contains('<<b>>')));
|
||||
|
@ -2400,7 +2417,7 @@ e() {
|
|||
|
||||
var source = sourceFile.readAsStringSync();
|
||||
// Split on the comment at the end of each module.
|
||||
var jsModules = source.split(RegExp("\/\/# sourceMappingURL=.*\.map"));
|
||||
var jsModules = source.split(RegExp("//# sourceMappingURL=.*.map"));
|
||||
|
||||
// Both modules should include the unsound null safety check.
|
||||
expect(
|
||||
|
@ -2472,7 +2489,7 @@ e() {
|
|||
|
||||
var source = sourceFile.readAsStringSync();
|
||||
// Split on the comment at the end of each module.
|
||||
var jsModules = source.split(RegExp("\/\/# sourceMappingURL=.*\.map"));
|
||||
var jsModules = source.split(RegExp("//# sourceMappingURL=.*.map"));
|
||||
|
||||
// Both modules should include the sound null safety validation.
|
||||
expect(
|
||||
|
@ -3006,7 +3023,7 @@ method(int i) => i?.isEven;
|
|||
if (hideWarnings) '--verbosity=error',
|
||||
file.path,
|
||||
];
|
||||
StringBuffer output = new StringBuffer();
|
||||
StringBuffer output = StringBuffer();
|
||||
expect(await starter(args, output: output), 0);
|
||||
String result = output.toString();
|
||||
Matcher matcher =
|
||||
|
@ -3062,7 +3079,7 @@ class CompilationResult {
|
|||
|
||||
class OutputParser {
|
||||
bool expectSources = true;
|
||||
StreamController<Result> _receivedResults;
|
||||
final StreamController<Result> _receivedResults;
|
||||
|
||||
List<String>? _receivedSources;
|
||||
String? _boundaryKey;
|
||||
|
@ -3072,9 +3089,9 @@ class OutputParser {
|
|||
|
||||
void listener(String s) {
|
||||
if (_boundaryKey == null) {
|
||||
const String RESULT_OUTPUT_SPACE = 'result ';
|
||||
if (s.startsWith(RESULT_OUTPUT_SPACE)) {
|
||||
_boundaryKey = s.substring(RESULT_OUTPUT_SPACE.length);
|
||||
const String resultOutputSpace = 'result ';
|
||||
if (s.startsWith(resultOutputSpace)) {
|
||||
_boundaryKey = s.substring(resultOutputSpace.length);
|
||||
}
|
||||
_readingSources = false;
|
||||
_receivedSources?.clear();
|
||||
|
@ -3098,9 +3115,7 @@ class OutputParser {
|
|||
_boundaryKey = null;
|
||||
} else {
|
||||
if (_readingSources) {
|
||||
if (_receivedSources == null) {
|
||||
_receivedSources = <String>[];
|
||||
}
|
||||
_receivedSources ??= <String>[];
|
||||
_receivedSources!.add(s);
|
||||
}
|
||||
}
|
||||
|
@ -3160,7 +3175,7 @@ class FrontendServer {
|
|||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.listen(outputParser.listener);
|
||||
return new FrontendServer._internal(inputStreamController,
|
||||
return FrontendServer._internal(inputStreamController,
|
||||
stdoutStreamController, ioSink, receivedResults, outputParser);
|
||||
}
|
||||
|
||||
|
@ -3211,7 +3226,7 @@ class FrontendServer {
|
|||
// TODO(johnniwinther): Use (required) named arguments.
|
||||
void compile(String path) {
|
||||
outputParser.expectSources = true;
|
||||
inputStreamController.add('compile ${path}\n'.codeUnits);
|
||||
inputStreamController.add('compile $path\n'.codeUnits);
|
||||
}
|
||||
|
||||
/// Recompiles the program.
|
||||
|
@ -3232,10 +3247,10 @@ class FrontendServer {
|
|||
invalidatedUris ??= [if (invalidatedUri != null) invalidatedUri];
|
||||
outputParser.expectSources = true;
|
||||
inputStreamController.add('recompile '
|
||||
'${entryPoint != null ? '${entryPoint} ' : ''}'
|
||||
'${boundaryKey}\n'
|
||||
'${entryPoint != null ? '$entryPoint ' : ''}'
|
||||
'$boundaryKey\n'
|
||||
'${invalidatedUris.map((uri) => '$uri\n').join()}'
|
||||
'${boundaryKey}\n'
|
||||
'$boundaryKey\n'
|
||||
.codeUnits);
|
||||
}
|
||||
|
||||
|
@ -3264,12 +3279,12 @@ class FrontendServer {
|
|||
// <klass: String>
|
||||
// <isStatic: true|false>
|
||||
outputParser.expectSources = false;
|
||||
inputStreamController.add('compile-expression ${boundaryKey}\n'
|
||||
'${expression}\n'
|
||||
'${boundaryKey}\n'
|
||||
'${boundaryKey}\n'
|
||||
'${library}\n'
|
||||
'${className}\n'
|
||||
inputStreamController.add('compile-expression $boundaryKey\n'
|
||||
'$expression\n'
|
||||
'$boundaryKey\n'
|
||||
'$boundaryKey\n'
|
||||
'$library\n'
|
||||
'$className\n'
|
||||
'${isStatic != null ? '$isStatic' : ''}\n'
|
||||
.codeUnits);
|
||||
}
|
||||
|
@ -3296,14 +3311,14 @@ class FrontendServer {
|
|||
// moduleName
|
||||
// expression
|
||||
outputParser.expectSources = false;
|
||||
inputStreamController.add('compile-expression-to-js ${boundaryKey}\n'
|
||||
'${libraryUri}\n'
|
||||
'${line}\n'
|
||||
'${column}\n'
|
||||
'${boundaryKey}\n'
|
||||
'${boundaryKey}\n'
|
||||
'${moduleName}\n'
|
||||
'${expression}\n'
|
||||
inputStreamController.add('compile-expression-to-js $boundaryKey\n'
|
||||
'$libraryUri\n'
|
||||
'$line\n'
|
||||
'$column\n'
|
||||
'$boundaryKey\n'
|
||||
'$boundaryKey\n'
|
||||
'$moduleName\n'
|
||||
'$expression\n'
|
||||
.codeUnits);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:frontend_server/starter.dart';
|
||||
import 'package:frontend_server/src/resident_frontend_server.dart';
|
||||
import 'package:frontend_server/starter.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:test/test.dart';
|
||||
|
||||
|
@ -16,7 +16,7 @@ void main() async {
|
|||
// granularity of file stat on windows.
|
||||
// Waiting for this number of milliseconds guarantees that the files in
|
||||
// the unit tests will not be counted as modified.
|
||||
const STAT_GRANULARITY = 1100;
|
||||
const statGranularity = 1100;
|
||||
|
||||
group('Resident Frontend Server: invalid input: ', () {
|
||||
test('no command given', () async {
|
||||
|
@ -160,7 +160,7 @@ void main() async {
|
|||
});
|
||||
|
||||
test('incremental compilation', () async {
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
final compileResults1 = jsonDecode(
|
||||
await ResidentFrontendServer.handleRequest(
|
||||
ResidentFrontendServer.createCompileJSON(
|
||||
|
@ -198,7 +198,7 @@ void main() async {
|
|||
test(
|
||||
'compiling twice with no modifications returns cached kernel without invoking compiler',
|
||||
() async {
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
final compileResults1 = jsonDecode(
|
||||
await ResidentFrontendServer.handleRequest(
|
||||
ResidentFrontendServer.createCompileJSON(
|
||||
|
@ -260,7 +260,7 @@ void main() async {
|
|||
});
|
||||
|
||||
test('Cached kernel is removed between compilation requests', () async {
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
final compileResults1 = jsonDecode(
|
||||
await ResidentFrontendServer.handleRequest(
|
||||
ResidentFrontendServer.createCompileJSON(
|
||||
|
@ -290,7 +290,7 @@ void main() async {
|
|||
});
|
||||
|
||||
test('maintains tracked sources', () async {
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
final executable2 = File(path.join(d.path, 'src2.dart'))
|
||||
..createSync()
|
||||
..writeAsStringSync('''
|
||||
|
@ -341,7 +341,7 @@ void main() async {
|
|||
package.writeAsStringSync(package.readAsStringSync());
|
||||
// Forces package to be behind the next computed kernel by 1 second
|
||||
// so that the final compilation will be incremental
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
|
||||
final compileResult2 = jsonDecode(
|
||||
await ResidentFrontendServer.handleRequest(
|
||||
|
@ -382,7 +382,7 @@ void main() async {
|
|||
test('continues to work after compiler error is produced', () async {
|
||||
final originalContent = executable.readAsStringSync();
|
||||
final newContent = originalContent.replaceAll(';', '@');
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
|
||||
executable.writeAsStringSync(newContent);
|
||||
final compileResults1 = jsonDecode(
|
||||
|
@ -418,7 +418,7 @@ void main() async {
|
|||
test('using cached kernel maintains error messages', () async {
|
||||
final originalContent = executable.readAsStringSync();
|
||||
executable.writeAsStringSync(originalContent.replaceFirst(';', ''));
|
||||
await Future.delayed(Duration(milliseconds: STAT_GRANULARITY));
|
||||
await Future.delayed(Duration(milliseconds: statGranularity));
|
||||
|
||||
final compileResults1 = jsonDecode(
|
||||
await ResidentFrontendServer.handleRequest(
|
||||
|
|
Loading…
Reference in a new issue