From d2c6b0a6371a02fdee9aac3e85765d0a62b5063c Mon Sep 17 00:00:00 2001 From: "P.Y. Laligand" Date: Thu, 27 Apr 2017 09:10:48 -0700 Subject: [PATCH] Get rid of unnecessary flutter_root argument. (#9622) --- .../flutter_tools/bin/fuchsia_tester.dart | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/packages/flutter_tools/bin/fuchsia_tester.dart b/packages/flutter_tools/bin/fuchsia_tester.dart index 42577a94f1..fb4ef77597 100644 --- a/packages/flutter_tools/bin/fuchsia_tester.dart +++ b/packages/flutter_tools/bin/fuchsia_tester.dart @@ -28,12 +28,10 @@ import '../lib/src/usage.dart'; const String _kOptionPackages = "packages"; const String _kOptionShell = "shell"; const String _kOptionTestDirectory = "test-directory"; -const String _kOptionFlutterRoot = "flutter-root"; const List _kRequiredOptions = const [ _kOptionPackages, _kOptionShell, _kOptionTestDirectory, - _kOptionFlutterRoot, ]; Future main(List args) async { @@ -65,40 +63,41 @@ Future run(List args) async { final ArgParser parser = new ArgParser() ..addOption(_kOptionPackages, help: 'The .packages file') ..addOption(_kOptionShell, help: 'The Flutter shell binary') - ..addOption(_kOptionTestDirectory, help: 'Directory containing the tests') - ..addOption(_kOptionFlutterRoot, help: 'Flutter root'); + ..addOption(_kOptionTestDirectory, help: 'Directory containing the tests'); final ArgResults argResults = parser.parse(args); if (_kRequiredOptions .any((String option) => !argResults.options.contains(option))) { printError('Missing option! All options must be specified.'); exit(1); } - // TODO(pylaligand): use a temp directory instead. - Cache.flutterRoot = argResults[_kOptionFlutterRoot]; - final Directory testDirectory = - fs.directory(argResults[_kOptionTestDirectory]); - final Iterable tests = _findTests(testDirectory); + final Directory tempDirectory = + fs.systemTempDirectory.createTempSync('fuchsia_tester'); + try { + Cache.flutterRoot = tempDirectory.path; + final Directory testDirectory = + fs.directory(argResults[_kOptionTestDirectory]); + final Iterable tests = _findTests(testDirectory); - final List testArgs = []; - testArgs.add('--'); - testArgs.addAll(tests); + final List testArgs = []; + testArgs.add('--'); + testArgs.addAll(tests); - final String shellPath = argResults[_kOptionShell]; - if (!fs.isFileSync(shellPath)) { - throwToolExit('Cannot find Flutter shell at $shellPath'); - } - loader.installHook( - shellPath: shellPath, - debuggerMode: false, - ); + final String shellPath = argResults[_kOptionShell]; + if (!fs.isFileSync(shellPath)) { + throwToolExit('Cannot find Flutter shell at $shellPath'); + } + loader.installHook( + shellPath: shellPath, + debuggerMode: false, + ); - PackageMap.globalPackagesPath = - fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages])); - fs.currentDirectory = testDirectory; + PackageMap.globalPackagesPath = + fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages])); + fs.currentDirectory = testDirectory; - await test.main(testArgs); - - if (exitCode != 0) { + await test.main(testArgs); exit(exitCode); + } finally { + tempDirectory.deleteSync(recursive: true); } }