Include .track in file names for cached dill files for builds with --track-widget-creation (#23299)
Ensure that cached dill files for builds with --track-widget-creation always have .track. in the file name to avoid mixing transformed and untransformed kernel files.
This commit is contained in:
parent
93573de216
commit
f5f70f0c99
@ -9,6 +9,7 @@ import 'package:meta/meta.dart';
|
|||||||
import '../android/android_sdk.dart';
|
import '../android/android_sdk.dart';
|
||||||
import '../artifacts.dart';
|
import '../artifacts.dart';
|
||||||
import '../build_info.dart';
|
import '../build_info.dart';
|
||||||
|
import '../bundle.dart';
|
||||||
import '../compile.dart';
|
import '../compile.dart';
|
||||||
import '../dart/package_map.dart';
|
import '../dart/package_map.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
@ -293,6 +294,7 @@ class AOTSnapshotter {
|
|||||||
@required String mainPath,
|
@required String mainPath,
|
||||||
@required String packagesPath,
|
@required String packagesPath,
|
||||||
@required String outputPath,
|
@required String outputPath,
|
||||||
|
@required bool trackWidgetCreation,
|
||||||
List<String> extraFrontEndOptions = const <String>[],
|
List<String> extraFrontEndOptions = const <String>[],
|
||||||
}) async {
|
}) async {
|
||||||
final Directory outputDir = fs.directory(outputPath);
|
final Directory outputDir = fs.directory(outputPath);
|
||||||
@ -308,12 +310,15 @@ class AOTSnapshotter {
|
|||||||
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
|
sdkRoot: artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
packagesPath: packagesPath,
|
packagesPath: packagesPath,
|
||||||
outputFilePath: fs.path.join(outputPath, 'app.dill'),
|
outputFilePath: getKernelPathForTransformerOptions(
|
||||||
|
fs.path.join(outputPath, 'app.dill'),
|
||||||
|
trackWidgetCreation: trackWidgetCreation,
|
||||||
|
),
|
||||||
depFilePath: depfilePath,
|
depFilePath: depfilePath,
|
||||||
extraFrontEndOptions: extraFrontEndOptions,
|
extraFrontEndOptions: extraFrontEndOptions,
|
||||||
linkPlatformKernelIn: true,
|
linkPlatformKernelIn: true,
|
||||||
aot: true,
|
aot: true,
|
||||||
trackWidgetCreation: false,
|
trackWidgetCreation: trackWidgetCreation,
|
||||||
targetProductVm: buildMode == BuildMode.release,
|
targetProductVm: buildMode == BuildMode.release,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
import 'artifacts.dart';
|
import 'artifacts.dart';
|
||||||
import 'asset.dart';
|
import 'asset.dart';
|
||||||
import 'base/build.dart';
|
import 'base/build.dart';
|
||||||
@ -19,7 +21,24 @@ const String defaultMainPath = 'lib/main.dart';
|
|||||||
const String defaultAssetBasePath = '.';
|
const String defaultAssetBasePath = '.';
|
||||||
const String defaultManifestPath = 'pubspec.yaml';
|
const String defaultManifestPath = 'pubspec.yaml';
|
||||||
String get defaultDepfilePath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
|
String get defaultDepfilePath => fs.path.join(getBuildDirectory(), 'snapshot_blob.bin.d');
|
||||||
String get defaultApplicationKernelPath => fs.path.join(getBuildDirectory(), 'app.dill');
|
|
||||||
|
String getDefaultApplicationKernelPath({@required bool trackWidgetCreation}) {
|
||||||
|
return getKernelPathForTransformerOptions(
|
||||||
|
fs.path.join(getBuildDirectory(), 'app.dill'),
|
||||||
|
trackWidgetCreation: trackWidgetCreation,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getKernelPathForTransformerOptions(
|
||||||
|
String path, {
|
||||||
|
@required bool trackWidgetCreation,
|
||||||
|
}) {
|
||||||
|
if (trackWidgetCreation) {
|
||||||
|
path += '.track.dill';
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
const String defaultPrivateKeyPath = 'privatekey.der';
|
const String defaultPrivateKeyPath = 'privatekey.der';
|
||||||
|
|
||||||
const String _kKernelKey = 'kernel_blob.bin';
|
const String _kKernelKey = 'kernel_blob.bin';
|
||||||
@ -50,7 +69,7 @@ Future<void> build({
|
|||||||
depfilePath ??= defaultDepfilePath;
|
depfilePath ??= defaultDepfilePath;
|
||||||
assetDirPath ??= getAssetBuildDirectory();
|
assetDirPath ??= getAssetBuildDirectory();
|
||||||
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
|
packagesPath ??= fs.path.absolute(PackageMap.globalPackagesPath);
|
||||||
applicationKernelFilePath ??= defaultApplicationKernelPath;
|
applicationKernelFilePath ??= getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation);
|
||||||
|
|
||||||
DevFSContent kernelContent;
|
DevFSContent kernelContent;
|
||||||
if (!precompiledSnapshot) {
|
if (!precompiledSnapshot) {
|
||||||
|
@ -85,6 +85,7 @@ class BuildAotCommand extends BuildSubCommand {
|
|||||||
buildMode: buildMode,
|
buildMode: buildMode,
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
packagesPath: PackageMap.globalPackagesPath,
|
packagesPath: PackageMap.globalPackagesPath,
|
||||||
|
trackWidgetCreation: false,
|
||||||
outputPath: outputPath,
|
outputPath: outputPath,
|
||||||
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
|
extraFrontEndOptions: argResults[FlutterOptions.kExtraFrontEndOptions],
|
||||||
);
|
);
|
||||||
|
@ -23,7 +23,6 @@ class BuildBundleCommand extends BuildSubCommand {
|
|||||||
..addOption('manifest', defaultsTo: defaultManifestPath)
|
..addOption('manifest', defaultsTo: defaultManifestPath)
|
||||||
..addOption('private-key', defaultsTo: defaultPrivateKeyPath)
|
..addOption('private-key', defaultsTo: defaultPrivateKeyPath)
|
||||||
..addOption('depfile', defaultsTo: defaultDepfilePath)
|
..addOption('depfile', defaultsTo: defaultDepfilePath)
|
||||||
..addOption('kernel-file', defaultsTo: defaultApplicationKernelPath)
|
|
||||||
..addOption('target-platform',
|
..addOption('target-platform',
|
||||||
defaultsTo: 'android-arm',
|
defaultsTo: 'android-arm',
|
||||||
allowed: <String>['android-arm', 'android-arm64', 'ios']
|
allowed: <String>['android-arm', 'android-arm64', 'ios']
|
||||||
@ -92,7 +91,6 @@ class BuildBundleCommand extends BuildSubCommand {
|
|||||||
buildMode: buildMode,
|
buildMode: buildMode,
|
||||||
mainPath: targetFile,
|
mainPath: targetFile,
|
||||||
manifestPath: argResults['manifest'],
|
manifestPath: argResults['manifest'],
|
||||||
applicationKernelFilePath: argResults['kernel-file'],
|
|
||||||
depfilePath: argResults['depfile'],
|
depfilePath: argResults['depfile'],
|
||||||
privateKeyPath: argResults['private-key'],
|
privateKeyPath: argResults['private-key'],
|
||||||
assetDirPath: argResults['asset-dir'],
|
assetDirPath: argResults['asset-dir'],
|
||||||
|
@ -165,7 +165,8 @@ class FuchsiaReloadCommand extends FlutterCommand {
|
|||||||
debuggingOptions: DebuggingOptions.enabled(getBuildInfo()),
|
debuggingOptions: DebuggingOptions.enabled(getBuildInfo()),
|
||||||
target: _target,
|
target: _target,
|
||||||
projectRootPath: _fuchsiaProjectPath,
|
projectRootPath: _fuchsiaProjectPath,
|
||||||
packagesFilePath: _dotPackagesPath);
|
packagesFilePath: _dotPackagesPath,
|
||||||
|
);
|
||||||
printStatus('Connecting to $_modName');
|
printStatus('Connecting to $_modName');
|
||||||
await hotRunner.attach();
|
await hotRunner.attach();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
import 'package:usage/uuid/uuid.dart';
|
import 'package:usage/uuid/uuid.dart';
|
||||||
|
|
||||||
import 'artifacts.dart';
|
import 'artifacts.dart';
|
||||||
@ -123,7 +124,7 @@ class KernelCompiler {
|
|||||||
String depFilePath,
|
String depFilePath,
|
||||||
bool linkPlatformKernelIn = false,
|
bool linkPlatformKernelIn = false,
|
||||||
bool aot = false,
|
bool aot = false,
|
||||||
bool trackWidgetCreation = false,
|
@required bool trackWidgetCreation,
|
||||||
List<String> extraFrontEndOptions,
|
List<String> extraFrontEndOptions,
|
||||||
String incrementalCompilerByteStorePath,
|
String incrementalCompilerByteStorePath,
|
||||||
String packagesPath,
|
String packagesPath,
|
||||||
@ -331,7 +332,8 @@ class ResidentCompiler {
|
|||||||
/// Binary file name is returned if compilation was successful, otherwise
|
/// Binary file name is returned if compilation was successful, otherwise
|
||||||
/// null is returned.
|
/// null is returned.
|
||||||
Future<CompilerOutput> recompile(String mainPath, List<String> invalidatedFiles,
|
Future<CompilerOutput> recompile(String mainPath, List<String> invalidatedFiles,
|
||||||
{String outputPath, String packagesFilePath}) async {
|
{@required String outputPath, String packagesFilePath}) async {
|
||||||
|
assert (outputPath != null);
|
||||||
if (!_controller.hasListener) {
|
if (!_controller.hasListener) {
|
||||||
_controller.stream.listen(_handleCompilationRequest);
|
_controller.stream.listen(_handleCompilationRequest);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import 'base/context.dart';
|
|||||||
import 'base/file_system.dart';
|
import 'base/file_system.dart';
|
||||||
import 'base/io.dart';
|
import 'base/io.dart';
|
||||||
import 'build_info.dart';
|
import 'build_info.dart';
|
||||||
|
import 'bundle.dart';
|
||||||
import 'compile.dart';
|
import 'compile.dart';
|
||||||
import 'dart/package_map.dart';
|
import 'dart/package_map.dart';
|
||||||
import 'globals.dart';
|
import 'globals.dart';
|
||||||
@ -431,10 +432,13 @@ class DevFS {
|
|||||||
Set<String> fileFilter,
|
Set<String> fileFilter,
|
||||||
@required ResidentCompiler generator,
|
@required ResidentCompiler generator,
|
||||||
String dillOutputPath,
|
String dillOutputPath,
|
||||||
|
@required bool trackWidgetCreation,
|
||||||
bool fullRestart = false,
|
bool fullRestart = false,
|
||||||
String projectRootPath,
|
String projectRootPath,
|
||||||
@required String pathToReload,
|
@required String pathToReload,
|
||||||
}) async {
|
}) async {
|
||||||
|
assert(trackWidgetCreation != null);
|
||||||
|
assert(generator != null);
|
||||||
// Mark all entries as possibly deleted.
|
// Mark all entries as possibly deleted.
|
||||||
for (DevFSContent content in _entries.values) {
|
for (DevFSContent content in _entries.values) {
|
||||||
content._exists = false;
|
content._exists = false;
|
||||||
@ -526,7 +530,7 @@ class DevFS {
|
|||||||
final CompilerOutput compilerOutput = await generator.recompile(
|
final CompilerOutput compilerOutput = await generator.recompile(
|
||||||
mainPath,
|
mainPath,
|
||||||
invalidatedFiles,
|
invalidatedFiles,
|
||||||
outputPath: dillOutputPath ?? fs.path.join(getBuildDirectory(), 'app.dill'),
|
outputPath: dillOutputPath ?? getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation),
|
||||||
packagesFilePath : _packagesFilePath,
|
packagesFilePath : _packagesFilePath,
|
||||||
);
|
);
|
||||||
// Don't send full kernel file that would overwrite what VM already
|
// Don't send full kernel file that would overwrite what VM already
|
||||||
|
@ -30,13 +30,14 @@ import 'vmservice.dart';
|
|||||||
|
|
||||||
class FlutterDevice {
|
class FlutterDevice {
|
||||||
FlutterDevice(this.device, {
|
FlutterDevice(this.device, {
|
||||||
@required bool trackWidgetCreation,
|
@required this.trackWidgetCreation,
|
||||||
this.dillOutputPath,
|
this.dillOutputPath,
|
||||||
this.fileSystemRoots,
|
this.fileSystemRoots,
|
||||||
this.fileSystemScheme,
|
this.fileSystemScheme,
|
||||||
this.viewFilter,
|
this.viewFilter,
|
||||||
ResidentCompiler generator,
|
ResidentCompiler generator,
|
||||||
}) : generator = generator ?? ResidentCompiler(
|
}) : assert(trackWidgetCreation != null),
|
||||||
|
generator = generator ?? ResidentCompiler(
|
||||||
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
|
artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath),
|
||||||
trackWidgetCreation: trackWidgetCreation,
|
trackWidgetCreation: trackWidgetCreation,
|
||||||
fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme
|
fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme
|
||||||
@ -53,6 +54,7 @@ class FlutterDevice {
|
|||||||
String fileSystemScheme;
|
String fileSystemScheme;
|
||||||
StreamSubscription<String> _loggingSubscription;
|
StreamSubscription<String> _loggingSubscription;
|
||||||
final String viewFilter;
|
final String viewFilter;
|
||||||
|
final bool trackWidgetCreation;
|
||||||
|
|
||||||
/// If the [reloadSources] parameter is not null the 'reloadSources' service
|
/// If the [reloadSources] parameter is not null the 'reloadSources' service
|
||||||
/// will be registered.
|
/// will be registered.
|
||||||
@ -390,6 +392,7 @@ class FlutterDevice {
|
|||||||
generator: generator,
|
generator: generator,
|
||||||
fullRestart: fullRestart,
|
fullRestart: fullRestart,
|
||||||
dillOutputPath: dillOutputPath,
|
dillOutputPath: dillOutputPath,
|
||||||
|
trackWidgetCreation: trackWidgetCreation,
|
||||||
projectRootPath: projectRootPath,
|
projectRootPath: projectRootPath,
|
||||||
pathToReload: pathToReload
|
pathToReload: pathToReload
|
||||||
);
|
);
|
||||||
@ -443,6 +446,7 @@ abstract class ResidentRunner {
|
|||||||
String _mainPath;
|
String _mainPath;
|
||||||
String get mainPath => _mainPath;
|
String get mainPath => _mainPath;
|
||||||
String getReloadPath({bool fullRestart}) => mainPath + (fullRestart ? '' : '.incremental') + '.dill';
|
String getReloadPath({bool fullRestart}) => mainPath + (fullRestart ? '' : '.incremental') + '.dill';
|
||||||
|
|
||||||
AssetBundle _assetBundle;
|
AssetBundle _assetBundle;
|
||||||
AssetBundle get assetBundle => _assetBundle;
|
AssetBundle get assetBundle => _assetBundle;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import '../base/io.dart';
|
|||||||
import '../base/process_manager.dart';
|
import '../base/process_manager.dart';
|
||||||
import '../base/terminal.dart';
|
import '../base/terminal.dart';
|
||||||
import '../build_info.dart';
|
import '../build_info.dart';
|
||||||
|
import '../bundle.dart';
|
||||||
import '../compile.dart';
|
import '../compile.dart';
|
||||||
import '../dart/package_map.dart';
|
import '../dart/package_map.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
@ -230,7 +231,10 @@ class _Compiler {
|
|||||||
printError('$message');
|
printError('$message');
|
||||||
}
|
}
|
||||||
|
|
||||||
final String testFilePath = fs.path.join(fs.path.fromUri(projectRootDirectory), getBuildDirectory(), 'testfile.dill');
|
final String testFilePath = getKernelPathForTransformerOptions(
|
||||||
|
fs.path.join(fs.path.fromUri(projectRootDirectory), getBuildDirectory(), 'testfile.dill'),
|
||||||
|
trackWidgetCreation: trackWidgetCreation,
|
||||||
|
);
|
||||||
|
|
||||||
ResidentCompiler createCompiler() {
|
ResidentCompiler createCompiler() {
|
||||||
return ResidentCompiler(
|
return ResidentCompiler(
|
||||||
|
@ -127,8 +127,10 @@ class FlutterTesterDevice extends Device {
|
|||||||
|
|
||||||
// Build assets and perform initial compilation.
|
// Build assets and perform initial compilation.
|
||||||
final String assetDirPath = getAssetBuildDirectory();
|
final String assetDirPath = getAssetBuildDirectory();
|
||||||
final String applicationKernelFilePath =
|
final String applicationKernelFilePath = bundle.getKernelPathForTransformerOptions(
|
||||||
fs.path.join(getBuildDirectory(), 'flutter-tester-app.dill');
|
fs.path.join(getBuildDirectory(), 'flutter-tester-app.dill'),
|
||||||
|
trackWidgetCreation: buildInfo.trackWidgetCreation,
|
||||||
|
);
|
||||||
await bundle.build(
|
await bundle.build(
|
||||||
mainPath: mainPath,
|
mainPath: mainPath,
|
||||||
assetDirPath: assetDirPath,
|
assetDirPath: assetDirPath,
|
||||||
@ -138,10 +140,7 @@ class FlutterTesterDevice extends Device {
|
|||||||
);
|
);
|
||||||
command.add('--flutter-assets-dir=$assetDirPath');
|
command.add('--flutter-assets-dir=$assetDirPath');
|
||||||
|
|
||||||
// TODO(scheglov): Either remove the check, or make it fail earlier.
|
command.add(applicationKernelFilePath);
|
||||||
if (applicationKernelFilePath != null) {
|
|
||||||
command.add(applicationKernelFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
printTrace(command.join(' '));
|
printTrace(command.join(' '));
|
||||||
|
@ -48,7 +48,8 @@ void main() {
|
|||||||
))
|
))
|
||||||
));
|
));
|
||||||
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
||||||
mainPath: '/path/to/main.dart'
|
mainPath: '/path/to/main.dart',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
||||||
expect(logger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
|
expect(logger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
|
||||||
@ -70,7 +71,8 @@ void main() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
||||||
mainPath: '/path/to/main.dart'
|
mainPath: '/path/to/main.dart',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
||||||
expect(logger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
|
expect(logger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
|
||||||
@ -93,8 +95,10 @@ void main() {
|
|||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
final CompilerOutput output = await kernelCompiler.compile(
|
||||||
mainPath: '/path/to/main.dart'
|
sdkRoot: '/path/to/sdkroot',
|
||||||
|
mainPath: '/path/to/main.dart',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
||||||
expect(logger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
|
expect(logger.errorText, equals('\nCompiler message:\nline1\nline2\n'));
|
||||||
@ -149,7 +153,9 @@ void main() {
|
|||||||
));
|
));
|
||||||
|
|
||||||
final CompilerOutput output = await generator.recompile(
|
final CompilerOutput output = await generator.recompile(
|
||||||
'/path/to/main.dart', null /* invalidatedFiles */
|
'/path/to/main.dart',
|
||||||
|
null /* invalidatedFiles */,
|
||||||
|
outputPath: '/build/',
|
||||||
);
|
);
|
||||||
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||||
verifyNoMoreInteractions(mockFrontendServerStdIn);
|
verifyNoMoreInteractions(mockFrontendServerStdIn);
|
||||||
@ -167,7 +173,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final CompilerOutput output = await generator.recompile(
|
final CompilerOutput output = await generator.recompile(
|
||||||
'/path/to/main.dart', null /* invalidatedFiles */
|
'/path/to/main.dart',
|
||||||
|
null, /* invalidatedFiles */
|
||||||
|
outputPath: '/build/',
|
||||||
);
|
);
|
||||||
expect(output, equals(null));
|
expect(output, equals(null));
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
@ -183,7 +191,11 @@ void main() {
|
|||||||
when(mockFrontendServer.stdout)
|
when(mockFrontendServer.stdout)
|
||||||
.thenAnswer((Invocation invocation) => streamController.stream);
|
.thenAnswer((Invocation invocation) => streamController.stream);
|
||||||
streamController.add(utf8.encode('result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n'));
|
streamController.add(utf8.encode('result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n'));
|
||||||
await generator.recompile('/path/to/main.dart', null /* invalidatedFiles */);
|
await generator.recompile(
|
||||||
|
'/path/to/main.dart',
|
||||||
|
null, /* invalidatedFiles */
|
||||||
|
outputPath: '/build/',
|
||||||
|
);
|
||||||
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||||
|
|
||||||
await _recompile(streamController, generator, mockFrontendServerStdIn,
|
await _recompile(streamController, generator, mockFrontendServerStdIn,
|
||||||
@ -210,7 +222,7 @@ void main() {
|
|||||||
streamController.add(utf8.encode(
|
streamController.add(utf8.encode(
|
||||||
'result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n'
|
'result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n'
|
||||||
));
|
));
|
||||||
await generator.recompile('/path/to/main.dart', null /* invalidatedFiles */);
|
await generator.recompile('/path/to/main.dart', null /* invalidatedFiles */, outputPath: '/build/');
|
||||||
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
expect(mockFrontendServerStdIn.getAndClear(), 'compile /path/to/main.dart\n');
|
||||||
|
|
||||||
await _recompile(streamController, generator, mockFrontendServerStdIn,
|
await _recompile(streamController, generator, mockFrontendServerStdIn,
|
||||||
@ -292,7 +304,9 @@ void main() {
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
await generator.recompile(
|
await generator.recompile(
|
||||||
'/path/to/main.dart', null /* invalidatedFiles */
|
'/path/to/main.dart',
|
||||||
|
null, /* invalidatedFiles */
|
||||||
|
outputPath: '/build/',
|
||||||
).then((CompilerOutput output) {
|
).then((CompilerOutput output) {
|
||||||
expect(mockFrontendServerStdIn.getAndClear(),
|
expect(mockFrontendServerStdIn.getAndClear(),
|
||||||
'compile /path/to/main.dart\n');
|
'compile /path/to/main.dart\n');
|
||||||
@ -339,7 +353,9 @@ void main() {
|
|||||||
|
|
||||||
// The test manages timing via completers.
|
// The test manages timing via completers.
|
||||||
generator.recompile( // ignore: unawaited_futures
|
generator.recompile( // ignore: unawaited_futures
|
||||||
'/path/to/main.dart', null /* invalidatedFiles */
|
'/path/to/main.dart',
|
||||||
|
null, /* invalidatedFiles */
|
||||||
|
outputPath: '/build/',
|
||||||
).then((CompilerOutput outputCompile) {
|
).then((CompilerOutput outputCompile) {
|
||||||
expect(logger.errorText,
|
expect(logger.errorText,
|
||||||
equals('\nCompiler message:\nline1\nline2\n'));
|
equals('\nCompiler message:\nline1\nline2\n'));
|
||||||
@ -394,7 +410,11 @@ Future<void> _recompile(StreamController<List<int>> streamController,
|
|||||||
scheduleMicrotask(() {
|
scheduleMicrotask(() {
|
||||||
streamController.add(utf8.encode(mockCompilerOutput));
|
streamController.add(utf8.encode(mockCompilerOutput));
|
||||||
});
|
});
|
||||||
final CompilerOutput output = await generator.recompile(null /* mainPath */, <String>['/path/to/main.dart']);
|
final CompilerOutput output = await generator.recompile(
|
||||||
|
null /* mainPath */,
|
||||||
|
<String>['/path/to/main.dart'],
|
||||||
|
outputPath: '/build/',
|
||||||
|
);
|
||||||
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
|
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
|
||||||
final String commands = mockFrontendServerStdIn.getAndClear();
|
final String commands = mockFrontendServerStdIn.getAndClear();
|
||||||
final RegExp re = RegExp('^recompile (.*)\\n/path/to/main.dart\\n(.*)\\n\$');
|
final RegExp re = RegExp('^recompile (.*)\\n/path/to/main.dart\\n(.*)\\n\$');
|
||||||
|
@ -119,13 +119,25 @@ void main() {
|
|||||||
devFSOperations.expectMessages(<String>['create test']);
|
devFSOperations.expectMessages(<String>['create test']);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
|
|
||||||
final int bytes = await devFS.update(
|
int bytes = await devFS.update(
|
||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
|
]);
|
||||||
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
|
|
||||||
|
bytes = await devFS.update(
|
||||||
|
mainPath: 'lib/foo.txt',
|
||||||
|
generator: residentCompiler,
|
||||||
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: true,
|
||||||
|
);
|
||||||
|
devFSOperations.expectMessages(<String>[
|
||||||
|
'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
|
|
||||||
@ -142,9 +154,10 @@ void main() {
|
|||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
@ -157,9 +170,10 @@ void main() {
|
|||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
@ -171,9 +185,10 @@ void main() {
|
|||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
@ -183,12 +198,41 @@ void main() {
|
|||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
|
|
||||||
|
// Set the last modified time to 5 seconds in the past.
|
||||||
|
updateFileModificationTime(file.path, DateTime.now(), -5);
|
||||||
|
bytes = await devFS.update(
|
||||||
|
mainPath: 'lib/foo.txt',
|
||||||
|
generator: residentCompiler,
|
||||||
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: true,
|
||||||
|
);
|
||||||
|
devFSOperations.expectMessages(<String>[
|
||||||
|
'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
|
||||||
|
]);
|
||||||
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
|
expect(bytes, 22);
|
||||||
|
|
||||||
|
await file.writeAsBytes(<int>[1, 2, 3, 4, 5, 6]);
|
||||||
|
bytes = await devFS.update(
|
||||||
|
mainPath: 'lib/foo.txt',
|
||||||
|
generator: residentCompiler,
|
||||||
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: true,
|
||||||
|
);
|
||||||
|
devFSOperations.expectMessages(<String>[
|
||||||
|
'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
|
||||||
|
]);
|
||||||
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
|
expect(bytes, 22);
|
||||||
|
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
});
|
});
|
||||||
@ -200,10 +244,11 @@ void main() {
|
|||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'deleteFile test lib/foo.txt',
|
'deleteFile test lib/foo.txt',
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
@ -213,16 +258,30 @@ void main() {
|
|||||||
|
|
||||||
testUsingContext('add new package', () async {
|
testUsingContext('add new package', () async {
|
||||||
await _createPackage(fs, 'newpkg', 'anotherfile.txt');
|
await _createPackage(fs, 'newpkg', 'anotherfile.txt');
|
||||||
final int bytes = await devFS.update(
|
int bytes = await devFS.update(
|
||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
|
|
||||||
|
bytes = await devFS.update(
|
||||||
|
mainPath: 'lib/foo.txt',
|
||||||
|
generator: residentCompiler,
|
||||||
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: true,
|
||||||
|
);
|
||||||
|
devFSOperations.expectMessages(<String>[
|
||||||
|
'writeFile test lib/foo.txt.dill build/app.dill.track.dill',
|
||||||
|
]);
|
||||||
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
|
expect(bytes, 22);
|
||||||
|
|
||||||
}, overrides: <Type, Generator>{
|
}, overrides: <Type, Generator>{
|
||||||
FileSystem: () => fs,
|
FileSystem: () => fs,
|
||||||
});
|
});
|
||||||
@ -248,9 +307,10 @@ void main() {
|
|||||||
fileFilter: fileFilter,
|
fileFilter: fileFilter,
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, isEmpty);
|
expect(devFS.assetPathsToEvict, isEmpty);
|
||||||
expect(bytes, 22);
|
expect(bytes, 22);
|
||||||
@ -266,10 +326,11 @@ void main() {
|
|||||||
bundleDirty: true,
|
bundleDirty: true,
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
|
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['a.txt']));
|
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['a.txt']));
|
||||||
devFS.assetPathsToEvict.clear();
|
devFS.assetPathsToEvict.clear();
|
||||||
@ -286,12 +347,13 @@ void main() {
|
|||||||
bundleDirty: true,
|
bundleDirty: true,
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
// Expect entire asset bundle written because bundleDirty is true
|
// Expect entire asset bundle written because bundleDirty is true
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
|
'writeFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
|
||||||
'writeFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
|
'writeFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
|
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
|
||||||
'a.txt', 'b.txt']));
|
'a.txt', 'b.txt']));
|
||||||
@ -308,10 +370,11 @@ void main() {
|
|||||||
bundle: assetBundle,
|
bundle: assetBundle,
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'writeFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
|
'writeFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
|
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
|
||||||
'c.txt']));
|
'c.txt']));
|
||||||
@ -328,10 +391,11 @@ void main() {
|
|||||||
bundle: assetBundle,
|
bundle: assetBundle,
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'deleteFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
|
'deleteFile test ${_inAssetBuildDirectory(fs, 'c.txt')}',
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['c.txt']));
|
expect(devFS.assetPathsToEvict, unorderedMatches(<String>['c.txt']));
|
||||||
devFS.assetPathsToEvict.clear();
|
devFS.assetPathsToEvict.clear();
|
||||||
@ -348,11 +412,12 @@ void main() {
|
|||||||
bundleDirty: true,
|
bundleDirty: true,
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
devFSOperations.expectMessages(<String>[
|
devFSOperations.expectMessages(<String>[
|
||||||
'deleteFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
|
'deleteFile test ${_inAssetBuildDirectory(fs, 'a.txt')}',
|
||||||
'deleteFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
|
'deleteFile test ${_inAssetBuildDirectory(fs, 'b.txt')}',
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill build/app.dill',
|
||||||
]);
|
]);
|
||||||
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
|
expect(devFS.assetPathsToEvict, unorderedMatches(<String>[
|
||||||
'a.txt', 'b.txt'
|
'a.txt', 'b.txt'
|
||||||
@ -405,6 +470,7 @@ void main() {
|
|||||||
mainPath: 'lib/foo.txt',
|
mainPath: 'lib/foo.txt',
|
||||||
generator: residentCompiler,
|
generator: residentCompiler,
|
||||||
pathToReload: 'lib/foo.txt.dill',
|
pathToReload: 'lib/foo.txt.dill',
|
||||||
|
trackWidgetCreation: false,
|
||||||
);
|
);
|
||||||
vmService.expectMessages(<String>[
|
vmService.expectMessages(<String>[
|
||||||
'writeFile test lib/foo.txt.dill',
|
'writeFile test lib/foo.txt.dill',
|
||||||
|
@ -427,7 +427,11 @@ class MockDevFSOperations extends BasicMock implements DevFSOperations {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<dynamic> writeFile(String fsName, Uri deviceUri, DevFSContent content) async {
|
Future<dynamic> writeFile(String fsName, Uri deviceUri, DevFSContent content) async {
|
||||||
messages.add('writeFile $fsName $deviceUri');
|
String message = 'writeFile $fsName $deviceUri';
|
||||||
|
if (content is DevFSFileContent) {
|
||||||
|
message += ' ${content.file.path}';
|
||||||
|
}
|
||||||
|
messages.add(message);
|
||||||
devicePathToContent[deviceUri] = content;
|
devicePathToContent[deviceUri] = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user