Pass build mode-specific bytecode generation options to frontend_server. (#42471)

Fixes various Flutter framework test failures when bytecode is enabled.
This commit is contained in:
Ryan Macnak
2019-10-14 15:26:14 -07:00
committed by GitHub
parent 163be41d80
commit b7773da37b
21 changed files with 91 additions and 60 deletions

View File

@@ -128,13 +128,12 @@ flutter_tools:lib/''');
targetModel: anyNamed('targetModel'),
linkPlatformKernelIn: anyNamed('linkPlatformKernelIn'),
aot: anyNamed('aot'),
enableAsserts: anyNamed('enableAsserts'),
buildMode: anyNamed('buildMode'),
trackWidgetCreation: anyNamed('trackWidgetCreation'),
extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
packagesPath: anyNamed('packagesPath'),
fileSystemRoots: anyNamed('fileSystemRoots'),
fileSystemScheme: anyNamed('fileSystemScheme'),
targetProductVm: anyNamed('targetProductVm'),
platformDill: anyNamed('platformDill'),
initializeFromDill: anyNamed('initializeFromDill'),
)).thenAnswer((Invocation invocation) async {
@@ -153,10 +152,9 @@ flutter_tools:lib/''');
when(mockKernelCompiler.compile(
sdkRoot: anyNamed('sdkRoot'),
aot: anyNamed('aot'),
enableAsserts: anyNamed('enableAsserts'),
buildMode: anyNamed('buildMode'),
trackWidgetCreation: false,
targetModel: anyNamed('targetModel'),
targetProductVm: anyNamed('targetProductVm'),
outputFilePath: anyNamed('outputFilePath'),
depFilePath: anyNamed('depFilePath'),
packagesPath: anyNamed('packagesPath'),
@@ -178,10 +176,9 @@ flutter_tools:lib/''');
when(mockKernelCompiler.compile(
sdkRoot: anyNamed('sdkRoot'),
aot: anyNamed('aot'),
enableAsserts: anyNamed('enableAsserts'),
buildMode: anyNamed('buildMode'),
trackWidgetCreation: true,
targetModel: anyNamed('targetModel'),
targetProductVm: anyNamed('targetProductVm'),
outputFilePath: anyNamed('outputFilePath'),
depFilePath: anyNamed('depFilePath'),
packagesPath: anyNamed('packagesPath'),
@@ -391,14 +388,13 @@ class FakeKernelCompiler implements KernelCompiler {
TargetModel targetModel = TargetModel.flutter,
bool linkPlatformKernelIn = false,
bool aot = false,
bool enableAsserts = false,
BuildMode buildMode,
bool causalAsyncStacks = true,
bool trackWidgetCreation,
List<String> extraFrontEndOptions,
String packagesPath,
List<String> fileSystemRoots,
String fileSystemScheme,
bool targetProductVm = false,
String platformDill,
String initializeFromDill,
}) async {

View File

@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
@@ -52,7 +53,7 @@ void main() {
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart',
enableAsserts: true,
buildMode: BuildMode.debug,
trackWidgetCreation: false,
);
@@ -76,7 +77,7 @@ void main() {
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart',
enableAsserts: true,
buildMode: BuildMode.debug,
trackWidgetCreation: false,
);
@@ -103,7 +104,7 @@ void main() {
final CompilerOutput output = await kernelCompiler.compile(
sdkRoot: '/path/to/sdkroot',
mainPath: '/path/to/main.dart',
enableAsserts: true,
buildMode: BuildMode.debug,
trackWidgetCreation: false,
);
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);

View File

@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
@@ -28,7 +29,7 @@ void main() {
StreamController<String> stdErrStreamController;
setUp(() {
generator = ResidentCompiler('sdkroot');
generator = ResidentCompiler('sdkroot', buildMode: BuildMode.debug);
mockProcessManager = MockProcessManager();
mockFrontendServer = MockProcess();
mockFrontendServerStdIn = MockStdIn();

View File

@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/globals.dart';
@@ -29,7 +30,7 @@ void main() {
StreamController<String> stdErrStreamController;
setUp(() {
generator = ResidentCompiler('sdkroot');
generator = ResidentCompiler('sdkroot', buildMode: BuildMode.debug);
mockProcessManager = MockProcessManager();
mockFrontendServer = MockProcess();
mockFrontendServerStdIn = MockStdIn();

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/platform.dart';
@@ -18,13 +19,13 @@ import '../src/context.dart';
void main() {
group('FlutterPlatform', () {
testUsingContext('ensureConfiguration throws an error if an explicitObservatoryPort is specified and more than one test file', () async {
final FlutterPlatform flutterPlatform = FlutterPlatform(shellPath: '/', explicitObservatoryPort: 1234);
final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', explicitObservatoryPort: 1234);
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>()));
});
testUsingContext('ensureConfiguration throws an error if a precompiled entrypoint is specified and more that one test file', () {
final FlutterPlatform flutterPlatform = FlutterPlatform(shellPath: '/', precompiledDillPath: 'example.dill');
final FlutterPlatform flutterPlatform = FlutterPlatform(buildMode: BuildMode.debug, shellPath: '/', precompiledDillPath: 'example.dill');
flutterPlatform.loadChannel('test1.dart', MockSuitePlatform());
expect(() => flutterPlatform.loadChannel('test2.dart', MockSuitePlatform()), throwsA(isA<ToolExit>()));
});
@@ -86,12 +87,14 @@ void main() {
testUsingContext('installHook creates a FlutterPlatform', () {
expect(() => installHook(
buildMode: BuildMode.debug,
shellPath: 'abc',
enableObservatory: false,
startPaused: true,
), throwsA(isA<AssertionError>()));
expect(() => installHook(
buildMode: BuildMode.debug,
shellPath: 'abc',
enableObservatory: false,
startPaused: false,
@@ -109,7 +112,7 @@ void main() {
port: 100,
precompiledDillPath: 'def',
precompiledDillFiles: expectedPrecompiledDillFiles,
enableAsserts: true,
buildMode: BuildMode.debug,
trackWidgetCreation: true,
updateGoldens: true,
buildTestAssets: true,
@@ -131,7 +134,7 @@ void main() {
expect(flutterPlatform.explicitObservatoryPort, equals(200));
expect(flutterPlatform.precompiledDillPath, equals('def'));
expect(flutterPlatform.precompiledDillFiles, expectedPrecompiledDillFiles);
expect(flutterPlatform.enableAsserts, equals(true));
expect(flutterPlatform.buildMode, equals(BuildMode.debug));
expect(flutterPlatform.trackWidgetCreation, equals(true));
expect(flutterPlatform.updateGoldens, equals(true));
expect(flutterPlatform.buildTestAssets, equals(true));
@@ -153,6 +156,7 @@ class MockHttpServer extends Mock implements HttpServer {}
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
class TestFlutterPlatform extends FlutterPlatform {
TestFlutterPlatform() : super(
buildMode: BuildMode.debug,
shellPath: '/',
precompiledDillPath: 'example.dill',
host: InternetAddress.loopbackIPv6,

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/compile.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/test/test_compiler.dart';
@@ -25,7 +26,7 @@ void main() {
fs.file('test/foo.dart').createSync(recursive: true);
residentCompiler = MockResidentCompiler();
testCompiler = FakeTestCompiler(
true,
BuildMode.debug,
false,
FlutterProject.current(),
residentCompiler,
@@ -76,11 +77,11 @@ void main() {
/// Override the creation of the Resident Compiler to simplify testing.
class FakeTestCompiler extends TestCompiler {
FakeTestCompiler(
bool enableAsserts,
BuildMode buildMode,
bool trackWidgetCreation,
FlutterProject flutterProject,
this.residentCompiler,
) : super(enableAsserts, trackWidgetCreation, flutterProject);
) : super(buildMode, trackWidgetCreation, flutterProject);
final MockResidentCompiler residentCompiler;

View File

@@ -134,7 +134,10 @@ void main() {
mockArtifacts = MockArtifacts();
final String artifactPath = fs.path.join(flutterRoot, 'artifact');
fs.file(artifactPath).createSync(recursive: true);
when(mockArtifacts.getArtifactPath(any)).thenReturn(artifactPath);
when(mockArtifacts.getArtifactPath(
any,
mode: anyNamed('mode')
)).thenReturn(artifactPath);
mockKernelCompiler = MockKernelCompiler();
});
@@ -170,7 +173,7 @@ Hello!
mainPath: anyNamed('mainPath'),
outputFilePath: anyNamed('outputFilePath'),
depFilePath: anyNamed('depFilePath'),
enableAsserts: anyNamed('enableAsserts'),
buildMode: BuildMode.debug,
trackWidgetCreation: anyNamed('trackWidgetCreation'),
extraFrontEndOptions: anyNamed('extraFrontEndOptions'),
fileSystemRoots: anyNamed('fileSystemRoots'),