Accommodate flutter test --preview-dart-2 on windows and linux (flutter/engine#4564)
* Support .packages option in frontend_server, bundle_path in main_mac. This is needed to be able to run in mode. * Remove byte store tests * Remove unused import * Fix formatting * Enable flutter test argument passing on win and linux. * Fix formatting
This commit is contained in:
committed by
GitHub
parent
03fd9da8d6
commit
a8e9231915
@@ -11,7 +11,6 @@ import 'package:args/args.dart';
|
||||
// that would replace api used below. This api was made private in
|
||||
// an effort to discourage further use.
|
||||
// ignore_for_file: implementation_imports
|
||||
import 'package:front_end/src/api_prototype/byte_store.dart';
|
||||
import 'package:front_end/src/api_prototype/compiler_options.dart';
|
||||
import 'package:front_end/src/api_prototype/incremental_kernel_generator.dart';
|
||||
|
||||
@@ -32,10 +31,6 @@ ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
|
||||
..addOption('sdk-root',
|
||||
help: 'Path to sdk root',
|
||||
defaultsTo: '../../out/android_debug/flutter_patched_sdk')
|
||||
..addOption('byte-store',
|
||||
help: 'Path to file byte store used to keep incremental compiler state.'
|
||||
' If omitted, then memory byte store is used.',
|
||||
defaultsTo: null)
|
||||
..addFlag('aot',
|
||||
help: 'Run compiler in AOT mode (enables whole-program transformations)',
|
||||
defaultsTo: false)
|
||||
@@ -48,7 +43,10 @@ ArgParser _argParser = new ArgParser(allowTrailingOptions: true)
|
||||
' Intended use is to satisfy different loading strategies implemented'
|
||||
' by gen_snapshot(which needs platform embedded) vs'
|
||||
' Flutter engine(which does not)',
|
||||
defaultsTo: true);
|
||||
defaultsTo: true)
|
||||
..addOption('packages',
|
||||
help: '.packages file to use for compilation',
|
||||
defaultsTo: '.packages');
|
||||
|
||||
String _usage = '''
|
||||
Usage: server [options] [input.dart]
|
||||
@@ -147,12 +145,9 @@ class _FrontendCompiler implements CompilerInterface {
|
||||
final String boundaryKey = new Uuid().generateV4();
|
||||
_outputStream.writeln('result $boundaryKey');
|
||||
final Uri sdkRoot = _ensureFolderPath(options['sdk-root']);
|
||||
final String byteStorePath = options['byte-store'];
|
||||
final CompilerOptions compilerOptions = new CompilerOptions()
|
||||
..byteStore = byteStorePath != null
|
||||
? new FileByteStore(byteStorePath)
|
||||
: new MemoryByteStore()
|
||||
..sdkRoot = sdkRoot
|
||||
..packagesFileUri = options['packages'] != null ? Uri.base.resolveUri(new Uri.file(options['packages'])) : null
|
||||
..strongMode = options['strong']
|
||||
..target = new FlutterTarget(new TargetFlags(strongMode: options['strong']))
|
||||
..reportMessages = true;
|
||||
|
||||
@@ -78,29 +78,6 @@ Future<int> main() async {
|
||||
expect(capturedArgs.single['strong'], equals(true));
|
||||
});
|
||||
|
||||
test('compile from command line with file byte store', () async {
|
||||
final List<String> args = <String>[
|
||||
'server.dart',
|
||||
'--sdk-root',
|
||||
'sdkroot',
|
||||
'--byte-store',
|
||||
'path/to/bytestore'
|
||||
];
|
||||
final int exitcode = await starter(args, compiler: compiler);
|
||||
expect(exitcode, equals(0));
|
||||
final List<ArgResults> capturedArgs =
|
||||
verify(
|
||||
compiler.compile(
|
||||
argThat(equals('server.dart')),
|
||||
captureAny,
|
||||
generator: any,
|
||||
)
|
||||
).captured;
|
||||
expect(capturedArgs.single['sdk-root'], equals('sdkroot'));
|
||||
expect(capturedArgs.single['byte-store'], equals('path/to/bytestore'));
|
||||
expect(capturedArgs.single['strong'], equals(false));
|
||||
});
|
||||
|
||||
test('compile from command line with link platform', () async {
|
||||
final List<String> args = <String>[
|
||||
'server.dart',
|
||||
@@ -124,14 +101,12 @@ Future<int> main() async {
|
||||
});
|
||||
});
|
||||
|
||||
group('interactive file store compile with mocked compiler', () {
|
||||
group('interactive compile with mocked compiler', () {
|
||||
final CompilerInterface compiler = new _MockedCompiler();
|
||||
|
||||
final List<String> args = <String>[
|
||||
'--sdk-root',
|
||||
'sdkroot',
|
||||
'--byte-store',
|
||||
'path/to/bytestore',
|
||||
];
|
||||
|
||||
test('compile one file', () async {
|
||||
@@ -143,8 +118,6 @@ Future<int> main() async {
|
||||
expect(invocation.positionalArguments[0], equals('server.dart'));
|
||||
expect(invocation.positionalArguments[1]['sdk-root'],
|
||||
equals('sdkroot'));
|
||||
expect(invocation.positionalArguments[1]['byte-store'],
|
||||
equals('path/to/bytestore'));
|
||||
expect(invocation.positionalArguments[1]['strong'], equals(false));
|
||||
compileCalled.sendPort.send(true);
|
||||
}
|
||||
|
||||
@@ -12,13 +12,30 @@
|
||||
#include "flutter/shell/platform/darwin/common/platform_mac.h"
|
||||
#include "flutter/shell/platform/darwin/desktop/flutter_application.h"
|
||||
#include "flutter/shell/testing/testing.h"
|
||||
#include "lib/fxl/command_line.h"
|
||||
#include "lib/fxl/logging.h"
|
||||
|
||||
static fxl::CommandLine InitializedCommandLine() {
|
||||
std::vector<std::string> args_vector;
|
||||
|
||||
for (NSString* arg in [NSProcessInfo processInfo].arguments) {
|
||||
args_vector.emplace_back(arg.UTF8String);
|
||||
}
|
||||
|
||||
return fxl::CommandLineFromIterators(args_vector.begin(), args_vector.end());
|
||||
}
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
[FlutterApplication sharedApplication];
|
||||
|
||||
shell::PlatformMacMain("", "", "");
|
||||
// Can't use shell::Shell::Shared().GetCommandLine() because it is initialized only
|
||||
// in shell::PlatformMacMain call below.
|
||||
auto command_line = InitializedCommandLine();
|
||||
|
||||
const auto& command_line = shell::Shell::Shared().GetCommandLine();
|
||||
std::string bundle_path = "";
|
||||
command_line.GetOptionValue(FlagForSwitch(shell::Switch::FlutterAssetsDir), &bundle_path);
|
||||
|
||||
shell::PlatformMacMain("", "", bundle_path);
|
||||
|
||||
// Print help.
|
||||
if (command_line.HasOption(shell::FlagForSwitch(shell::Switch::Help))) {
|
||||
|
||||
@@ -77,7 +77,13 @@ void RunNonInteractive(fxl::CommandLine initial_command_line,
|
||||
// one time initialization.
|
||||
fml::MessageLoop::EnsureInitializedForCurrentThread();
|
||||
|
||||
shell::Shell::InitStandalone(initial_command_line);
|
||||
std::string bundle_path = "";
|
||||
initial_command_line.GetOptionValue(
|
||||
FlagForSwitch(shell::Switch::FlutterAssetsDir), &bundle_path);
|
||||
|
||||
shell::Shell::InitStandalone(initial_command_line,
|
||||
/* icu_data_path= */ "",
|
||||
/* application_library_path= */ "", bundle_path);
|
||||
|
||||
// Note that this task observer must be added after the observer that drains
|
||||
// the microtask queue.
|
||||
|
||||
@@ -78,6 +78,14 @@ void RunNonInteractive(fxl::CommandLine initial_command_line,
|
||||
// one time initialization.
|
||||
fml::MessageLoop::EnsureInitializedForCurrentThread();
|
||||
|
||||
std::string bundle_path = "";
|
||||
initial_command_line.GetOptionValue(
|
||||
FlagForSwitch(shell::Switch::FlutterAssetsDir), &bundle_path);
|
||||
|
||||
shell::Shell::InitStandalone(initial_command_line,
|
||||
/* icu_data_path= */ "",
|
||||
/* application_library_path= */ "", bundle_path);
|
||||
|
||||
shell::Shell::InitStandalone(initial_command_line);
|
||||
|
||||
// Note that this task observer must be added after the observer that drains
|
||||
|
||||
Reference in New Issue
Block a user