2019-11-27 23:04:02 +00:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
2019-09-25 20:55:29 +00:00
|
|
|
// 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/build_system/build_system.dart';
|
|
|
|
import 'package:flutter_tools/src/bundle.dart';
|
|
|
|
import 'package:flutter_tools/src/project.dart';
|
2020-01-06 19:04:20 +00:00
|
|
|
import 'package:flutter_tools/src/globals.dart' as globals;
|
2019-09-25 20:55:29 +00:00
|
|
|
import 'package:mockito/mockito.dart';
|
|
|
|
|
|
|
|
import '../src/common.dart';
|
|
|
|
import '../src/testbed.dart';
|
|
|
|
|
|
|
|
// Tests for the temporary flutter assemble/bundle shim.
|
|
|
|
void main() {
|
|
|
|
Testbed testbed;
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
testbed = Testbed(overrides: <Type, Generator>{
|
|
|
|
BuildSystem: () => MockBuildSystem(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Copies assets to expected directory after building', () => testbed.run(() async {
|
|
|
|
when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async {
|
2019-11-24 05:54:43 +00:00
|
|
|
final Environment environment = invocation.positionalArguments[1] as Environment;
|
2019-09-25 20:55:29 +00:00
|
|
|
environment.outputDir.childFile('kernel_blob.bin').createSync(recursive: true);
|
|
|
|
environment.outputDir.childFile('isolate_snapshot_data').createSync();
|
|
|
|
environment.outputDir.childFile('vm_snapshot_data').createSync();
|
|
|
|
environment.outputDir.childFile('LICENSE').createSync(recursive: true);
|
|
|
|
return BuildResult(success: true);
|
|
|
|
});
|
|
|
|
await buildWithAssemble(
|
|
|
|
buildMode: BuildMode.debug,
|
|
|
|
flutterProject: FlutterProject.current(),
|
2020-01-06 19:04:20 +00:00
|
|
|
mainPath: globals.fs.path.join('lib', 'main.dart'),
|
2019-09-25 20:55:29 +00:00
|
|
|
outputDir: 'example',
|
|
|
|
targetPlatform: TargetPlatform.ios,
|
|
|
|
depfilePath: 'example.d',
|
2019-09-26 22:57:57 +00:00
|
|
|
precompiled: false,
|
2019-09-25 20:55:29 +00:00
|
|
|
);
|
2020-01-06 19:04:20 +00:00
|
|
|
expect(globals.fs.file(globals.fs.path.join('example', 'kernel_blob.bin')).existsSync(), true);
|
|
|
|
expect(globals.fs.file(globals.fs.path.join('example', 'LICENSE')).existsSync(), true);
|
|
|
|
expect(globals.fs.file(globals.fs.path.join('example.d')).existsSync(), false);
|
2019-09-25 20:55:29 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
test('Handles build system failure', () => testbed.run(() {
|
|
|
|
when(buildSystem.build(any, any)).thenAnswer((Invocation _) async {
|
|
|
|
return BuildResult(
|
|
|
|
success: false,
|
|
|
|
exceptions: <String, ExceptionMeasurement>{},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(() => buildWithAssemble(
|
|
|
|
buildMode: BuildMode.debug,
|
|
|
|
flutterProject: FlutterProject.current(),
|
|
|
|
mainPath: 'lib/main.dart',
|
|
|
|
outputDir: 'example',
|
|
|
|
targetPlatform: TargetPlatform.linux_x64,
|
|
|
|
depfilePath: 'example.d',
|
2019-09-26 22:57:57 +00:00
|
|
|
precompiled: false,
|
2020-01-27 22:36:02 +00:00
|
|
|
), throwsToolExit());
|
2019-09-25 20:55:29 +00:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
class MockBuildSystem extends Mock implements BuildSystem {}
|