Reland "Expose build mode in environment of asset transformer processes" (#144958)
Relands https://github.com/flutter/flutter/pull/144752, which had to be reverted because the branch was stale. The original branch branched off `master` before https://github.com/flutter/flutter/pull/144734 landed. That PR introduced a new `AssetTransformer` call site.
This PR branch is identical to the original but with a new commit that addresses the new call site, [update new call sites](6bb5296a61).
This commit is contained in:
@@ -610,7 +610,8 @@ flutter:
|
||||
fileSystem: globals.fs,
|
||||
artifacts: globals.artifacts!,
|
||||
logger: testLogger,
|
||||
projectDir: globals.fs.currentDirectory
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
expect(testLogger.warningText, contains('Expected Error Text'));
|
||||
@@ -737,6 +738,7 @@ flutter:
|
||||
artifacts: globals.artifacts!,
|
||||
logger: testLogger,
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
@@ -789,6 +791,7 @@ flutter:
|
||||
artifacts: globals.artifacts!,
|
||||
logger: testLogger,
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
}, overrides: <Type, Generator>{
|
||||
@@ -876,6 +879,7 @@ flutter:
|
||||
artifacts: globals.artifacts!,
|
||||
logger: testLogger,
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
expect((globals.processManager as FakeProcessManager).hasRemainingExpectations, false);
|
||||
}, overrides: <Type, Generator>{
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/build_system/tools/asset_transformer.dart';
|
||||
import 'package:flutter_tools/src/flutter_manifest.dart';
|
||||
|
||||
@@ -53,6 +54,7 @@ void main() {
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
dartBinaryPath: artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
final AssetTransformationFailure? transformationFailure = await transformer.transformAsset(
|
||||
@@ -112,6 +114,7 @@ void main() {
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
dartBinaryPath: dartBinaryPath,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
final AssetTransformationFailure? failure = await transformer.transformAsset(
|
||||
@@ -171,6 +174,7 @@ Something went wrong''');
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
dartBinaryPath: dartBinaryPath,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
final AssetTransformationFailure? failure = await transformer.transformAsset(
|
||||
@@ -265,6 +269,7 @@ Transformation failed, but I forgot to exit with a non-zero code.'''
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
dartBinaryPath: dartBinaryPath,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
final AssetTransformationFailure? failure = await transformer.transformAsset(
|
||||
@@ -331,7 +336,10 @@ Transformation failed, but I forgot to exit with a non-zero code.'''
|
||||
onRun: (List<String> args) {
|
||||
// Do nothing.
|
||||
},
|
||||
stderr: 'Transformation failed, but I forgot to exit with a non-zero code.'
|
||||
stderr: 'Transformation failed, but I forgot to exit with a non-zero code.',
|
||||
environment: const <String, String>{
|
||||
'FLUTTER_BUILD_MODE': 'debug',
|
||||
},
|
||||
),
|
||||
]);
|
||||
|
||||
@@ -339,6 +347,7 @@ Transformation failed, but I forgot to exit with a non-zero code.'''
|
||||
processManager: processManager,
|
||||
fileSystem: fileSystem,
|
||||
dartBinaryPath: dartBinaryPath,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
final AssetTransformationFailure? failure = await transformer.transformAsset(
|
||||
|
||||
@@ -38,7 +38,9 @@ void main() {
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
platform: FakePlatform(),
|
||||
defines: <String, String>{},
|
||||
defines: <String, String>{
|
||||
kBuildMode: BuildMode.debug.cliName,
|
||||
},
|
||||
);
|
||||
fileSystem.file(environment.buildDir.childFile('app.dill')).createSync(recursive: true);
|
||||
fileSystem.file('packages/flutter_tools/lib/src/build_system/targets/assets.dart')
|
||||
@@ -178,7 +180,9 @@ flutter:
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
platform: globals.platform,
|
||||
defines: <String, String>{},
|
||||
defines: <String, String>{
|
||||
kBuildMode: BuildMode.debug.cliName,
|
||||
},
|
||||
);
|
||||
|
||||
await fileSystem.file('.packages').create();
|
||||
@@ -262,7 +266,9 @@ flutter:
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
platform: globals.platform,
|
||||
defines: <String, String>{},
|
||||
defines: <String, String>{
|
||||
kBuildMode: BuildMode.debug.cliName,
|
||||
},
|
||||
);
|
||||
|
||||
await fileSystem.file('.packages').create();
|
||||
|
||||
@@ -68,6 +68,7 @@ void main() {
|
||||
outputDir: globals.fs.currentDirectory.childDirectory('bar'),
|
||||
defines: <String, String>{
|
||||
kTargetFile: globals.fs.path.join('foo', 'lib', 'main.dart'),
|
||||
kBuildMode: BuildMode.debug.cliName,
|
||||
},
|
||||
artifacts: Artifacts.test(),
|
||||
processManager: processManager,
|
||||
|
||||
@@ -119,6 +119,7 @@ void main() {
|
||||
artifacts: artifacts,
|
||||
logger: BufferLogger.test(),
|
||||
projectDir: fileSystem.currentDirectory,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
final File outputAssetFile = fileSystem.file('build/flutter_assets/my-asset.txt');
|
||||
|
||||
@@ -135,6 +135,7 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
expect(() async => devFS.create(), throwsA(isA<DevFSException>()));
|
||||
});
|
||||
@@ -160,6 +161,7 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
expect(await devFS.create(), isNotNull);
|
||||
@@ -210,6 +212,7 @@ void main() {
|
||||
uploadRetryThrottle: Duration.zero,
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
await devFS.create();
|
||||
|
||||
@@ -245,6 +248,7 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -287,6 +291,7 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -331,6 +336,7 @@ void main() {
|
||||
httpClient: HttpClient(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -382,6 +388,7 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -461,6 +468,7 @@ void main() {
|
||||
}),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -507,6 +515,7 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -612,7 +621,8 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
config: Config.test(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -670,7 +680,8 @@ void main() {
|
||||
httpClient: FakeHttpClient.any(),
|
||||
config: Config.test(),
|
||||
processManager: FakeProcessManager.empty(),
|
||||
artifacts: Artifacts.test(),
|
||||
artifacts: Artifacts.test(),
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -763,6 +774,7 @@ void main() {
|
||||
config: Config.test(),
|
||||
processManager: processManager,
|
||||
artifacts: artifacts,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
@@ -843,6 +855,7 @@ void main() {
|
||||
config: Config.test(),
|
||||
processManager: processManager,
|
||||
artifacts: artifacts,
|
||||
buildMode: BuildMode.debug,
|
||||
);
|
||||
|
||||
await devFS.create();
|
||||
|
||||
Reference in New Issue
Block a user