Commit d2c6b0a6 authored by P.Y. Laligand's avatar P.Y. Laligand Committed by GitHub

Get rid of unnecessary flutter_root argument. (#9622)

parent 23b8e1f1
...@@ -28,12 +28,10 @@ import '../lib/src/usage.dart'; ...@@ -28,12 +28,10 @@ import '../lib/src/usage.dart';
const String _kOptionPackages = "packages"; const String _kOptionPackages = "packages";
const String _kOptionShell = "shell"; const String _kOptionShell = "shell";
const String _kOptionTestDirectory = "test-directory"; const String _kOptionTestDirectory = "test-directory";
const String _kOptionFlutterRoot = "flutter-root";
const List<String> _kRequiredOptions = const <String>[ const List<String> _kRequiredOptions = const <String>[
_kOptionPackages, _kOptionPackages,
_kOptionShell, _kOptionShell,
_kOptionTestDirectory, _kOptionTestDirectory,
_kOptionFlutterRoot,
]; ];
Future<Null> main(List<String> args) async { Future<Null> main(List<String> args) async {
...@@ -65,40 +63,41 @@ Future<Null> run(List<String> args) async { ...@@ -65,40 +63,41 @@ Future<Null> run(List<String> args) async {
final ArgParser parser = new ArgParser() final ArgParser parser = new ArgParser()
..addOption(_kOptionPackages, help: 'The .packages file') ..addOption(_kOptionPackages, help: 'The .packages file')
..addOption(_kOptionShell, help: 'The Flutter shell binary') ..addOption(_kOptionShell, help: 'The Flutter shell binary')
..addOption(_kOptionTestDirectory, help: 'Directory containing the tests') ..addOption(_kOptionTestDirectory, help: 'Directory containing the tests');
..addOption(_kOptionFlutterRoot, help: 'Flutter root');
final ArgResults argResults = parser.parse(args); final ArgResults argResults = parser.parse(args);
if (_kRequiredOptions if (_kRequiredOptions
.any((String option) => !argResults.options.contains(option))) { .any((String option) => !argResults.options.contains(option))) {
printError('Missing option! All options must be specified.'); printError('Missing option! All options must be specified.');
exit(1); exit(1);
} }
// TODO(pylaligand): use a temp directory instead. final Directory tempDirectory =
Cache.flutterRoot = argResults[_kOptionFlutterRoot]; fs.systemTempDirectory.createTempSync('fuchsia_tester');
final Directory testDirectory = try {
fs.directory(argResults[_kOptionTestDirectory]); Cache.flutterRoot = tempDirectory.path;
final Iterable<String> tests = _findTests(testDirectory); final Directory testDirectory =
fs.directory(argResults[_kOptionTestDirectory]);
final Iterable<String> tests = _findTests(testDirectory);
final List<String> testArgs = <String>[]; final List<String> testArgs = <String>[];
testArgs.add('--'); testArgs.add('--');
testArgs.addAll(tests); testArgs.addAll(tests);
final String shellPath = argResults[_kOptionShell]; final String shellPath = argResults[_kOptionShell];
if (!fs.isFileSync(shellPath)) { if (!fs.isFileSync(shellPath)) {
throwToolExit('Cannot find Flutter shell at $shellPath'); throwToolExit('Cannot find Flutter shell at $shellPath');
} }
loader.installHook( loader.installHook(
shellPath: shellPath, shellPath: shellPath,
debuggerMode: false, debuggerMode: false,
); );
PackageMap.globalPackagesPath =
fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages]));
fs.currentDirectory = testDirectory;
await test.main(testArgs); PackageMap.globalPackagesPath =
fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages]));
fs.currentDirectory = testDirectory;
if (exitCode != 0) { await test.main(testArgs);
exit(exitCode); exit(exitCode);
} finally {
tempDirectory.deleteSync(recursive: true);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment