Commit 35f37403 authored by Gary Miguel's avatar Gary Miguel Committed by Todd Volkert

Revert "Revert "Use runTests in fuchsia tester. (#19178)" (#19321)" (#19327)

This reverts commit e22f9974.

Adding the exit(exitCode) fixes the hang.
Tested by running `fx run-host-tests` with a topaz checkout.
Verified the hang before, no hang after.
parent 579d2fba
...@@ -11,12 +11,12 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -11,12 +11,12 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/context_runner.dart'; import 'package:flutter_tools/src/context_runner.dart';
import 'package:flutter_tools/src/dart/package_map.dart'; import 'package:flutter_tools/src/dart/package_map.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/disabled_usage.dart'; import 'package:flutter_tools/src/disabled_usage.dart';
import 'package:flutter_tools/src/globals.dart'; import 'package:flutter_tools/src/globals.dart';
import 'package:flutter_tools/src/test/flutter_platform.dart' as loader; import 'package:flutter_tools/src/test/coverage_collector.dart';
import 'package:flutter_tools/src/test/runner.dart';
import 'package:flutter_tools/src/usage.dart'; import 'package:flutter_tools/src/usage.dart';
import 'package:test/src/executable.dart'
as test; // ignore: implementation_imports
// Note: this was largely inspired by lib/src/commands/test.dart. // Note: this was largely inspired by lib/src/commands/test.dart.
...@@ -28,9 +28,11 @@ const List<String> _kRequiredOptions = const <String>[ ...@@ -28,9 +28,11 @@ const List<String> _kRequiredOptions = const <String>[
_kOptionShell, _kOptionShell,
_kOptionTestDirectory, _kOptionTestDirectory,
]; ];
const String _kOptionCoverage = 'coverage';
const String _kOptionCoveragePath = 'coverage-path';
Future<Null> main(List<String> args) { void main(List<String> args) {
return runInContext<Null>(() => run(args), overrides: <Type, dynamic>{ runInContext<Null>(() => run(args), overrides: <Type, dynamic>{
Usage: new DisabledUsage(), Usage: new DisabledUsage(),
}); });
} }
...@@ -47,12 +49,20 @@ Future<Null> run(List<String> args) async { ...@@ -47,12 +49,20 @@ 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')
..addFlag(_kOptionCoverage,
defaultsTo: false,
negatable: false,
help: 'Whether to collect coverage information.',
)
..addOption(_kOptionCoveragePath,
defaultsTo: 'coverage/lcov.info',
help: 'Where to store coverage information (if coverage is enabled).',
);
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.'); throwToolExit('Missing option! All options must be specified.');
exit(1);
} }
final Directory tempDirectory = final Directory tempDirectory =
fs.systemTempDirectory.createTempSync('fuchsia_tester'); fs.systemTempDirectory.createTempSync('fuchsia_tester');
...@@ -70,17 +80,39 @@ Future<Null> run(List<String> args) async { ...@@ -70,17 +80,39 @@ Future<Null> run(List<String> args) async {
if (!fs.isFileSync(shellPath)) { if (!fs.isFileSync(shellPath)) {
throwToolExit('Cannot find Flutter shell at $shellPath'); throwToolExit('Cannot find Flutter shell at $shellPath');
} }
loader.installHook( // Put the tester shell where runTests expects it.
shellPath: shellPath, // TODO(tvolkert,garymm): Switch to a Fuchsia-specific Artifacts impl.
); final Link testerDestLink =
fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
testerDestLink.parent.createSync(recursive: true);
testerDestLink.createSync(shellPath);
PackageMap.globalPackagesPath = PackageMap.globalPackagesPath =
fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages])); fs.path.normalize(fs.path.absolute(argResults[_kOptionPackages]));
fs.currentDirectory = testDirectory;
await test.main(testArgs); CoverageCollector collector;
exit(exitCode); if (argResults['coverage']) {
collector = new CoverageCollector();
}
exitCode = await runTests(
tests,
workDir: testDirectory,
watcher: collector,
enableObservatory: collector != null,
);
if (collector != null) {
// collector expects currentDirectory to be the root of the dart
// package (i.e. contains lib/ and test/ sub-dirs).
fs.currentDirectory = testDirectory.parent;
if (!await
collector.collectCoverageData(argResults[_kOptionCoveragePath]))
throwToolExit('Failed to collect coverage data');
}
} finally { } finally {
tempDirectory.deleteSync(recursive: true); tempDirectory.deleteSync(recursive: true);
} }
// Not sure why this is needed, but main() doesn't seem to exit on its own.
exit(exitCode);
} }
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