mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] use initially parsed package config for language version, sound mode determination (#70323)
This commit is contained in:
parent
ed977dd6a4
commit
0a73ecf6df
@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
|
||||
import 'base/config.dart';
|
||||
import 'base/context.dart';
|
||||
@ -33,9 +34,10 @@ class BuildInfo {
|
||||
@required this.treeShakeIcons,
|
||||
this.performanceMeasurementFile,
|
||||
this.packagesPath = '.packages', // TODO(jonahwilliams): make this required and remove the default.
|
||||
this.nullSafetyMode = NullSafetyMode.autodetect,
|
||||
this.nullSafetyMode = NullSafetyMode.sound,
|
||||
this.codeSizeDirectory,
|
||||
this.androidGradleDaemon = true,
|
||||
this.packageConfig = PackageConfig.empty,
|
||||
});
|
||||
|
||||
final BuildMode mode;
|
||||
@ -134,6 +136,12 @@ class BuildInfo {
|
||||
/// The Gradle daemon may also be disabled in the Android application's properties file.
|
||||
final bool androidGradleDaemon;
|
||||
|
||||
/// The package configuration for the loaded application.
|
||||
///
|
||||
/// This is captured once during startup, but the actual package configuration
|
||||
/// may change during a 'flutter run` workflow.
|
||||
final PackageConfig packageConfig;
|
||||
|
||||
static const BuildInfo debug = BuildInfo(BuildMode.debug, null, treeShakeIcons: false);
|
||||
static const BuildInfo profile = BuildInfo(BuildMode.profile, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
|
||||
static const BuildInfo jitRelease = BuildInfo(BuildMode.jitRelease, null, treeShakeIcons: kIconTreeShakerEnabledDefault);
|
||||
@ -751,5 +759,6 @@ List<String> decodeDartDefines(Map<String, String> environmentDefines, String ke
|
||||
enum NullSafetyMode {
|
||||
sound,
|
||||
unsound,
|
||||
/// The null safety mode was not detected. Only supported for 'flutter test'.
|
||||
autodetect,
|
||||
}
|
||||
|
@ -198,10 +198,7 @@ class WebAssetServer implements AssetReader {
|
||||
// Allow rendering in a iframe.
|
||||
httpServer.defaultResponseHeaders.remove('x-frame-options', 'SAMEORIGIN');
|
||||
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
globals.fs.file(buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
final PackageConfig packageConfig = buildInfo.packageConfig;
|
||||
final Map<String, String> digests = <String, String>{};
|
||||
final Map<String, String> modules = <String, String>{};
|
||||
final WebAssetServer server = WebAssetServer(
|
||||
@ -631,43 +628,35 @@ class WebAssetServer implements AssetReader {
|
||||
return webSdkFile;
|
||||
}
|
||||
|
||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/70121
|
||||
static const Map<WebRendererMode, Map<NullSafetyMode, Artifact>> _dartSdkJsArtifactMap =
|
||||
<WebRendererMode, Map<NullSafetyMode, Artifact>> {
|
||||
WebRendererMode.autoDetect: <NullSafetyMode, Artifact> {
|
||||
NullSafetyMode.sound: Artifact.webPrecompiledCanvaskitAndHtmlSoundSdk,
|
||||
NullSafetyMode.unsound: Artifact.webPrecompiledCanvaskitAndHtmlSdk,
|
||||
NullSafetyMode.autodetect: Artifact.webPrecompiledCanvaskitAndHtmlSdk,
|
||||
},
|
||||
WebRendererMode.canvaskit: <NullSafetyMode, Artifact> {
|
||||
NullSafetyMode.sound: Artifact.webPrecompiledCanvaskitSoundSdk,
|
||||
NullSafetyMode.unsound: Artifact.webPrecompiledCanvaskitSdk,
|
||||
NullSafetyMode.autodetect: Artifact.webPrecompiledCanvaskitSdk,
|
||||
},
|
||||
WebRendererMode.html: <NullSafetyMode, Artifact> {
|
||||
NullSafetyMode.sound: Artifact.webPrecompiledSoundSdk,
|
||||
NullSafetyMode.unsound: Artifact.webPrecompiledSdk,
|
||||
NullSafetyMode.autodetect: Artifact.webPrecompiledSdk,
|
||||
},
|
||||
};
|
||||
|
||||
// TODO(yjbanov): https://github.com/flutter/flutter/issues/70121
|
||||
static const Map<WebRendererMode, Map<NullSafetyMode, Artifact>> _dartSdkJsMapArtifactMap =
|
||||
<WebRendererMode, Map<NullSafetyMode, Artifact>> {
|
||||
WebRendererMode.autoDetect: <NullSafetyMode, Artifact> {
|
||||
NullSafetyMode.sound: Artifact.webPrecompiledCanvaskitAndHtmlSoundSdkSourcemaps,
|
||||
NullSafetyMode.unsound: Artifact.webPrecompiledCanvaskitAndHtmlSdkSourcemaps,
|
||||
NullSafetyMode.autodetect: Artifact.webPrecompiledCanvaskitAndHtmlSdkSourcemaps,
|
||||
},
|
||||
WebRendererMode.canvaskit: <NullSafetyMode, Artifact> {
|
||||
NullSafetyMode.sound: Artifact.webPrecompiledCanvaskitSoundSdkSourcemaps,
|
||||
NullSafetyMode.unsound: Artifact.webPrecompiledCanvaskitSdkSourcemaps,
|
||||
NullSafetyMode.autodetect: Artifact.webPrecompiledCanvaskitSdkSourcemaps,
|
||||
},
|
||||
WebRendererMode.html: <NullSafetyMode, Artifact> {
|
||||
NullSafetyMode.sound: Artifact.webPrecompiledSoundSdkSourcemaps,
|
||||
NullSafetyMode.unsound: Artifact.webPrecompiledSdkSourcemaps,
|
||||
NullSafetyMode.autodetect: Artifact.webPrecompiledSdkSourcemaps,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -508,7 +508,7 @@ class _ResidentWebRunner extends ResidentWebRunner {
|
||||
expressionCompiler: expressionCompiler,
|
||||
chromiumLauncher: _chromiumLauncher,
|
||||
nullAssertions: debuggingOptions.nullAssertions,
|
||||
nullSafetyMode: device.nullSafetyMode,
|
||||
nullSafetyMode: debuggingOptions.buildInfo.nullSafetyMode,
|
||||
);
|
||||
final Uri url = await device.devFS.create();
|
||||
if (debuggingOptions.buildInfo.isDebug) {
|
||||
@ -719,7 +719,8 @@ class _ResidentWebRunner extends ResidentWebRunner {
|
||||
lastCompiled: device.devFS.lastCompiled,
|
||||
urisToMonitor: device.devFS.sources,
|
||||
packagesPath: packagesFilePath,
|
||||
packageConfig: device.devFS.lastPackageConfig,
|
||||
packageConfig: device.devFS.lastPackageConfig
|
||||
?? debuggingOptions.buildInfo.packageConfig,
|
||||
);
|
||||
final Status devFSStatus = globals.logger.startProgress(
|
||||
'Syncing files to device ${device.device.name}...',
|
||||
|
@ -27,8 +27,6 @@ import 'build_system/targets/localizations.dart';
|
||||
import 'bundle.dart';
|
||||
import 'cache.dart';
|
||||
import 'compile.dart';
|
||||
import 'dart/language_version.dart';
|
||||
import 'dart/package_map.dart';
|
||||
import 'devfs.dart';
|
||||
import 'device.dart';
|
||||
import 'features.dart';
|
||||
@ -48,7 +46,6 @@ class FlutterDevice {
|
||||
TargetPlatform targetPlatform,
|
||||
ResidentCompiler generator,
|
||||
this.userIdentifier,
|
||||
this.nullSafetyMode = NullSafetyMode.autodetect,
|
||||
}) : assert(buildInfo.trackWidgetCreation != null),
|
||||
generator = generator ?? ResidentCompiler(
|
||||
globals.artifacts.getArtifactPath(
|
||||
@ -84,7 +81,6 @@ class FlutterDevice {
|
||||
String userIdentifier,
|
||||
}) async {
|
||||
ResidentCompiler generator;
|
||||
NullSafetyMode nullSafetyMode = buildInfo.nullSafetyMode;
|
||||
final TargetPlatform targetPlatform = await device.targetPlatform;
|
||||
if (device.platformType == PlatformType.fuchsia) {
|
||||
targetModel = TargetModel.flutterRunner;
|
||||
@ -96,39 +92,21 @@ class FlutterDevice {
|
||||
// a warning message and dump some debug information which can be
|
||||
// used to file a bug, but the compiler will still start up correctly.
|
||||
if (targetPlatform == TargetPlatform.web_javascript) {
|
||||
// TODO(jonahwilliams): consistently provide these flags across platforms.
|
||||
Artifact platformDillArtifact;
|
||||
List<String> extraFrontEndOptions;
|
||||
final List<String> extraFrontEndOptions = List<String>.of(buildInfo.extraFrontEndOptions ?? <String>[]);
|
||||
if (buildInfo.nullSafetyMode == NullSafetyMode.unsound) {
|
||||
platformDillArtifact = Artifact.webPlatformKernelDill;
|
||||
extraFrontEndOptions = buildInfo.extraFrontEndOptions;
|
||||
if (!extraFrontEndOptions.contains('--no-sound-null-safety')) {
|
||||
extraFrontEndOptions.add('--no-sound-null-safety');
|
||||
}
|
||||
} else if (buildInfo.nullSafetyMode == NullSafetyMode.sound) {
|
||||
platformDillArtifact = Artifact.webPlatformSoundKernelDill;
|
||||
extraFrontEndOptions = buildInfo.extraFrontEndOptions;
|
||||
} else {
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
globals.fs.file(buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
final File entrypointFile = globals.fs.file(target);
|
||||
final LanguageVersion languageVersion = determineLanguageVersion(
|
||||
entrypointFile,
|
||||
packageConfig.packageOf(entrypointFile.absolute.uri),
|
||||
);
|
||||
if (languageVersion.major >= nullSafeVersion.major && languageVersion.minor >= nullSafeVersion.minor) {
|
||||
platformDillArtifact = Artifact.webPlatformSoundKernelDill;
|
||||
extraFrontEndOptions = <String>[
|
||||
...?buildInfo.extraFrontEndOptions,
|
||||
'--sound-null-safety',
|
||||
];
|
||||
nullSafetyMode = NullSafetyMode.sound;
|
||||
} else {
|
||||
platformDillArtifact = Artifact.webPlatformKernelDill;
|
||||
extraFrontEndOptions = <String>[
|
||||
...?buildInfo.extraFrontEndOptions,
|
||||
'--no-sound-null-safety',
|
||||
];
|
||||
nullSafetyMode = NullSafetyMode.unsound;
|
||||
if (!extraFrontEndOptions.contains('--sound-null-safety')) {
|
||||
extraFrontEndOptions.add('--sound-null-safety');
|
||||
}
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
|
||||
generator = ResidentCompiler(
|
||||
@ -202,7 +180,6 @@ class FlutterDevice {
|
||||
generator: generator,
|
||||
buildInfo: buildInfo,
|
||||
userIdentifier: userIdentifier,
|
||||
nullSafetyMode: nullSafetyMode,
|
||||
);
|
||||
}
|
||||
|
||||
@ -210,7 +187,6 @@ class FlutterDevice {
|
||||
final ResidentCompiler generator;
|
||||
final BuildInfo buildInfo;
|
||||
final String userIdentifier;
|
||||
final NullSafetyMode nullSafetyMode;
|
||||
|
||||
DevFSWriter devFSWriter;
|
||||
Stream<Uri> observatoryUris;
|
||||
|
@ -307,10 +307,6 @@ class HotRunner extends ResidentRunner {
|
||||
firstBuildTime = DateTime.now();
|
||||
|
||||
final List<Future<bool>> startupTasks = <Future<bool>>[];
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
globals.fs.file(debuggingOptions.buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
for (final FlutterDevice device in flutterDevices) {
|
||||
// Here we initialize the frontend_server concurrently with the platform
|
||||
// build, reducing overall initialization time. This is safe because the first
|
||||
@ -331,7 +327,7 @@ class HotRunner extends ResidentRunner {
|
||||
getDefaultApplicationKernelPath(
|
||||
trackWidgetCreation: debuggingOptions.buildInfo.trackWidgetCreation,
|
||||
),
|
||||
packageConfig: packageConfig,
|
||||
packageConfig: debuggingOptions.buildInfo.packageConfig,
|
||||
).then((CompilerOutput output) => output?.errorCount == 0)
|
||||
);
|
||||
}
|
||||
@ -386,7 +382,8 @@ class HotRunner extends ResidentRunner {
|
||||
urisToMonitor: flutterDevices[0].devFS.sources,
|
||||
packagesPath: packagesFilePath,
|
||||
asyncScanning: hotRunnerConfig.asyncScanning,
|
||||
packageConfig: flutterDevices[0].devFS.lastPackageConfig,
|
||||
packageConfig: flutterDevices[0].devFS.lastPackageConfig
|
||||
?? debuggingOptions.buildInfo.packageConfig,
|
||||
);
|
||||
final File entrypointFile = globals.fs.file(mainPath);
|
||||
if (!entrypointFile.existsSync()) {
|
||||
@ -1211,7 +1208,7 @@ class ProjectFileInvalidator {
|
||||
// Initial load.
|
||||
assert(urisToMonitor.isEmpty);
|
||||
return InvalidationResult(
|
||||
packageConfig: await _createPackageConfig(packagesPath),
|
||||
packageConfig: packageConfig,
|
||||
uris: <Uri>[]
|
||||
);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import 'package:args/args.dart';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../base/common.dart';
|
||||
@ -21,6 +22,8 @@ import '../build_system/targets/icon_tree_shaker.dart' show kIconTreeShakerEnabl
|
||||
import '../bundle.dart' as bundle;
|
||||
import '../cache.dart';
|
||||
import '../dart/generate_synthetic_packages.dart';
|
||||
import '../dart/language_version.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../dart/pub.dart';
|
||||
import '../device.dart';
|
||||
import '../features.dart';
|
||||
@ -758,6 +761,11 @@ abstract class FlutterCommand extends Command<void> {
|
||||
? stringArg('build-number')
|
||||
: null;
|
||||
|
||||
final File packagesFile = globals.fs.file(
|
||||
globalResults['packages'] as String ?? globals.fs.path.absolute('.dart_tool', 'package_config.json'));
|
||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||
packagesFile, logger: globals.logger, throwOnError: false);
|
||||
|
||||
final List<String> experiments =
|
||||
argParser.options.containsKey(FlutterOptions.kEnableExperiment)
|
||||
? stringsArg(FlutterOptions.kEnableExperiment).toList()
|
||||
@ -789,12 +797,28 @@ abstract class FlutterCommand extends Command<void> {
|
||||
codeSizeDirectory = directory.path;
|
||||
}
|
||||
|
||||
NullSafetyMode nullSafetyMode = NullSafetyMode.unsound;
|
||||
NullSafetyMode nullSafetyMode = NullSafetyMode.sound;
|
||||
if (argParser.options.containsKey(FlutterOptions.kNullSafety)) {
|
||||
// Explicitly check for `true` and `false` so that `null` results in not
|
||||
// passing a flag. This will use the automatically detected null-safety
|
||||
// value based on the entrypoint
|
||||
if (!argResults.wasParsed(FlutterOptions.kNullSafety)) {
|
||||
// passing a flag. Examine the entrypoint file to determine if it
|
||||
// is opted in or out.
|
||||
final bool wasNullSafetyFlagParsed = argResults.wasParsed(FlutterOptions.kNullSafety);
|
||||
if (!wasNullSafetyFlagParsed && argParser.options.containsKey('target')) {
|
||||
final File entrypointFile = globals.fs.file(targetFile);
|
||||
final LanguageVersion languageVersion = determineLanguageVersion(
|
||||
entrypointFile,
|
||||
packageConfig.packageOf(entrypointFile.absolute.uri),
|
||||
);
|
||||
// Extra frontend options are only provided if explicitly
|
||||
// requested.
|
||||
if (languageVersion.major >= nullSafeVersion.major && languageVersion.minor >= nullSafeVersion.minor) {
|
||||
nullSafetyMode = NullSafetyMode.sound;
|
||||
} else {
|
||||
nullSafetyMode = NullSafetyMode.unsound;
|
||||
}
|
||||
} else if (!wasNullSafetyFlagParsed) {
|
||||
// This mode is only used for commands which do not build a single target like
|
||||
// 'flutter test'.
|
||||
nullSafetyMode = NullSafetyMode.autodetect;
|
||||
} else if (boolArg(FlutterOptions.kNullSafety)) {
|
||||
nullSafetyMode = NullSafetyMode.sound;
|
||||
@ -886,6 +910,7 @@ abstract class FlutterCommand extends Command<void> {
|
||||
nullSafetyMode: nullSafetyMode,
|
||||
codeSizeDirectory: codeSizeDirectory,
|
||||
androidGradleDaemon: androidGradleDaemon,
|
||||
packageConfig: packageConfig,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ import '../build_info.dart';
|
||||
import '../compile.dart';
|
||||
import '../convert.dart';
|
||||
import '../dart/language_version.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../test/test_wrapper.dart';
|
||||
@ -374,10 +373,7 @@ class FlutterPlatform extends PlatformPlugin {
|
||||
StreamChannel<dynamic> controller,
|
||||
int ourTestCount,
|
||||
) async {
|
||||
_packageConfig ??= await loadPackageConfigWithLogging(
|
||||
globals.fs.file(buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
_packageConfig ??= buildInfo.packageConfig;
|
||||
globals.printTrace('test $ourTestCount: starting test $testPath');
|
||||
|
||||
_AsyncError outOfBandError; // error that we couldn't send to the harness that we need to send via our future
|
||||
|
@ -42,6 +42,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
FlutterProject flutterProject,
|
||||
String shellPath,
|
||||
this.updateGoldens,
|
||||
@required BuildInfo buildInfo,
|
||||
}) {
|
||||
final shelf.Cascade cascade = shelf.Cascade()
|
||||
.add(_webSocketHandler.handler)
|
||||
@ -67,7 +68,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
|
||||
_testGoldenComparator = TestGoldenComparator(
|
||||
shellPath,
|
||||
() => TestCompiler(BuildInfo.debug, flutterProject),
|
||||
() => TestCompiler(buildInfo, flutterProject),
|
||||
);
|
||||
}
|
||||
|
||||
@ -76,6 +77,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
String shellPath,
|
||||
bool updateGoldens = false,
|
||||
bool pauseAfterLoad = false,
|
||||
@required BuildInfo buildInfo,
|
||||
}) async {
|
||||
final shelf_io.IOServer server =
|
||||
shelf_io.IOServer(await HttpMultiServer.loopback(0));
|
||||
@ -86,6 +88,7 @@ class FlutterWebPlatform extends PlatformPlugin {
|
||||
flutterProject: flutterProject,
|
||||
shellPath: shellPath,
|
||||
updateGoldens: updateGoldens,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,7 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
|
||||
shellPath: shellPath,
|
||||
flutterProject: flutterProject,
|
||||
pauseAfterLoad: startPaused,
|
||||
buildInfo: buildInfo,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
@ -12,7 +12,6 @@ import '../base/file_system.dart';
|
||||
import '../build_info.dart';
|
||||
import '../bundle.dart';
|
||||
import '../compile.dart';
|
||||
import '../dart/package_map.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
|
||||
@ -128,10 +127,7 @@ class TestCompiler {
|
||||
return;
|
||||
}
|
||||
if (_packageConfig == null) {
|
||||
_packageConfig ??= await loadPackageConfigWithLogging(
|
||||
globals.fs.file(buildInfo.packagesPath),
|
||||
logger: globals.logger,
|
||||
);
|
||||
_packageConfig ??= buildInfo.packageConfig;
|
||||
// Compilation will fail if there is no flutter_test dependency, since
|
||||
// this library is imported by the generated entrypoint script.
|
||||
if (_packageConfig['test_api'] == null) {
|
||||
|
@ -143,7 +143,8 @@ void main() {
|
||||
packageConfig: packageConfig,
|
||||
);
|
||||
|
||||
expect(invalidationResult.packageConfig, isNot(packageConfig));
|
||||
// Initial package config is re-used.
|
||||
expect(invalidationResult.packageConfig, packageConfig);
|
||||
|
||||
fileSystem.file('.packages')
|
||||
.writeAsStringSync('foo:lib/\n');
|
||||
|
@ -2501,7 +2501,7 @@ void main() {
|
||||
)).generator as DefaultResidentCompiler;
|
||||
|
||||
expect(residentCompiler.initializeFromDill,
|
||||
globals.fs.path.join(getBuildDirectory(), 'cache.dill'));
|
||||
globals.fs.path.join(getBuildDirectory(), 'fbbe6a61fb7a1de317d381f8df4814e5.cache.dill'));
|
||||
expect(residentCompiler.librariesSpec,
|
||||
globals.fs.file(globals.artifacts.getArtifactPath(Artifact.flutterWebLibrariesJson))
|
||||
.uri.toString());
|
||||
|
@ -12,6 +12,7 @@ import 'package:flutter_tools/src/compile.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
import 'package:flutter_tools/src/test/test_compiler.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:package_config/package_config_types.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
@ -22,6 +23,15 @@ final Platform linuxPlatform = FakePlatform(
|
||||
environment: <String, String>{},
|
||||
);
|
||||
|
||||
final BuildInfo debugBuild = BuildInfo(
|
||||
BuildMode.debug,
|
||||
'',
|
||||
treeShakeIcons: false,
|
||||
packageConfig: PackageConfig(<Package>[
|
||||
Package('test_api', Uri.parse('file:///test_api/')),
|
||||
])
|
||||
);
|
||||
|
||||
void main() {
|
||||
MockResidentCompiler residentCompiler;
|
||||
FileSystem fileSystem;
|
||||
@ -29,17 +39,13 @@ void main() {
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').writeAsStringSync('flutter_test:flutter_test/');
|
||||
fileSystem.file('test/foo.dart').createSync(recursive: true);
|
||||
fileSystem.file('.packages')
|
||||
..createSync()
|
||||
..writeAsStringSync('test_api:test_api/\n');
|
||||
residentCompiler = MockResidentCompiler();
|
||||
});
|
||||
|
||||
testUsingContext('TestCompiler reports a dill file when compile is successful', () async {
|
||||
final FakeTestCompiler testCompiler = FakeTestCompiler(
|
||||
BuildInfo.debug,
|
||||
debugBuild,
|
||||
FlutterProject.current(),
|
||||
residentCompiler,
|
||||
);
|
||||
@ -64,7 +70,7 @@ void main() {
|
||||
|
||||
testUsingContext('TestCompiler reports null when a compile fails', () async {
|
||||
final FakeTestCompiler testCompiler = FakeTestCompiler(
|
||||
BuildInfo.debug,
|
||||
debugBuild,
|
||||
FlutterProject.current(),
|
||||
residentCompiler,
|
||||
);
|
||||
@ -90,7 +96,7 @@ void main() {
|
||||
|
||||
testUsingContext('TestCompiler disposing test compiler shuts down backing compiler', () async {
|
||||
final FakeTestCompiler testCompiler = FakeTestCompiler(
|
||||
BuildInfo.debug,
|
||||
debugBuild,
|
||||
FlutterProject.current(),
|
||||
residentCompiler,
|
||||
);
|
||||
@ -115,7 +121,6 @@ void main() {
|
||||
FlutterProject.current(),
|
||||
residentCompiler,
|
||||
);
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
|
||||
expect(await testCompiler.compile(Uri.parse('test/foo.dart')), null);
|
||||
expect(testLogger.errorText, contains('Error: cannot run without a dependency on '
|
||||
|
@ -591,14 +591,12 @@ void main() {
|
||||
}));
|
||||
|
||||
test('Can start web server with specified assets', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
|
||||
..createSync(recursive: true);
|
||||
outputFile.parent.childFile('a.sources').writeAsStringSync('');
|
||||
outputFile.parent.childFile('a.json').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.map').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.metadata').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
final ResidentCompiler residentCompiler = MockResidentCompiler();
|
||||
when(residentCompiler.recompile(
|
||||
@ -708,14 +706,12 @@ void main() {
|
||||
}));
|
||||
|
||||
test('Can start web server with specified assets in sound null safety mode', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
|
||||
..createSync(recursive: true);
|
||||
outputFile.parent.childFile('a.sources').writeAsStringSync('');
|
||||
outputFile.parent.childFile('a.json').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.map').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.metadata').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
final ResidentCompiler residentCompiler = MockResidentCompiler();
|
||||
when(residentCompiler.recompile(
|
||||
@ -739,14 +735,14 @@ void main() {
|
||||
BuildMode.debug,
|
||||
'',
|
||||
treeShakeIcons: false,
|
||||
nullSafetyMode: NullSafetyMode.autodetect,
|
||||
nullSafetyMode: NullSafetyMode.sound,
|
||||
),
|
||||
enableDwds: false,
|
||||
entrypoint: Uri.base,
|
||||
testMode: true,
|
||||
expressionCompiler: null,
|
||||
chromiumLauncher: null,
|
||||
nullSafetyMode: NullSafetyMode.autodetect,
|
||||
nullSafetyMode: NullSafetyMode.sound,
|
||||
);
|
||||
webDevFS.requireJS.createSync(recursive: true);
|
||||
webDevFS.stackTraceMapper.createSync(recursive: true);
|
||||
@ -759,13 +755,13 @@ void main() {
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('GENERATED');
|
||||
final String webPrecompiledSdk = globals.artifacts
|
||||
.getArtifactPath(Artifact.webPrecompiledSdk);
|
||||
.getArtifactPath(Artifact.webPrecompiledSoundSdk);
|
||||
final String webPrecompiledSdkSourcemaps = globals.artifacts
|
||||
.getArtifactPath(Artifact.webPrecompiledSdkSourcemaps);
|
||||
.getArtifactPath(Artifact.webPrecompiledSoundSdkSourcemaps);
|
||||
final String webPrecompiledCanvaskitSdk = globals.artifacts
|
||||
.getArtifactPath(Artifact.webPrecompiledCanvaskitSdk);
|
||||
.getArtifactPath(Artifact.webPrecompiledCanvaskitSoundSdk);
|
||||
final String webPrecompiledCanvaskitSdkSourcemaps = globals.artifacts
|
||||
.getArtifactPath(Artifact.webPrecompiledCanvaskitSdkSourcemaps);
|
||||
.getArtifactPath(Artifact.webPrecompiledCanvaskitSoundSdkSourcemaps);
|
||||
globals.fs.file(webPrecompiledSdk)
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('HELLO');
|
||||
@ -823,13 +819,11 @@ void main() {
|
||||
}));
|
||||
|
||||
test('Can start web server with hostname any', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
|
||||
..createSync(recursive: true);
|
||||
outputFile.parent.childFile('a.sources').writeAsStringSync('');
|
||||
outputFile.parent.childFile('a.json').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.map').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
final ResidentCompiler residentCompiler = MockResidentCompiler();
|
||||
when(residentCompiler.recompile(
|
||||
@ -867,13 +861,11 @@ void main() {
|
||||
}));
|
||||
|
||||
test('Can start web server with canvaskit enabled', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
|
||||
..createSync(recursive: true);
|
||||
outputFile.parent.childFile('a.sources').writeAsStringSync('');
|
||||
outputFile.parent.childFile('a.json').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.map').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
final ResidentCompiler residentCompiler = MockResidentCompiler();
|
||||
when(residentCompiler.recompile(
|
||||
@ -919,13 +911,11 @@ void main() {
|
||||
}));
|
||||
|
||||
test('Can start web server with auto detect enabled', () => testbed.run(() async {
|
||||
globals.fs.file('.packages').writeAsStringSync('\n');
|
||||
final File outputFile = globals.fs.file(globals.fs.path.join('lib', 'main.dart'))
|
||||
..createSync(recursive: true);
|
||||
outputFile.parent.childFile('a.sources').writeAsStringSync('');
|
||||
outputFile.parent.childFile('a.json').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('a.map').writeAsStringSync('{}');
|
||||
outputFile.parent.childFile('.packages').writeAsStringSync('\n');
|
||||
|
||||
final ResidentCompiler residentCompiler = MockResidentCompiler();
|
||||
when(residentCompiler.recompile(
|
||||
|
Loading…
Reference in New Issue
Block a user