[tools] remove --flutter-repo flag in flutter test (#3728)

This commit is contained in:
Yegor 2016-05-04 14:08:16 -07:00
parent 32bbbc6458
commit 39e741dfb7
2 changed files with 7 additions and 27 deletions

View file

@ -83,7 +83,6 @@ Flutter tests use [package:flutter_test](https://github.com/flutter/flutter/tree
* `cd packages/flutter_tools` * `cd packages/flutter_tools`
* `dart test/all.dart` * `dart test/all.dart`
`flutter test --flutter-repo` is a shortcut for those working on the flutter repository itself which runs all tests inside the `flutter` package regardless of the current working directory.
To run all the tests for the entire Flutter repository, the same way that Travis runs them, run `travis/test.sh`. To run all the tests for the entire Flutter repository, the same way that Travis runs them, run `travis/test.sh`.
If you've built [your own flutter engine](#working-on-the-engine-and-the-framework-at-the-same-time), you can pass `--engine-debug` or `--engine-release` to change what flutter shell `flutter test` uses. If you've built [your own flutter engine](#working-on-the-engine-and-the-framework-at-the-same-time), you can pass `--engine-debug` or `--engine-release` to change what flutter shell `flutter test` uses.

View file

@ -11,17 +11,11 @@ import 'package:test/src/executable.dart' as executable; // ignore: implementati
import '../artifacts.dart'; import '../artifacts.dart';
import '../build_configuration.dart'; import '../build_configuration.dart';
import '../globals.dart'; import '../globals.dart';
import '../package_map.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../test/flutter_platform.dart' as loader; import '../test/flutter_platform.dart' as loader;
class TestCommand extends FlutterCommand { class TestCommand extends FlutterCommand {
TestCommand() { TestCommand() {
argParser.addFlag(
'flutter-repo',
help: 'Run tests from the \'flutter\' package in the Flutter repository instead of the current directory.',
defaultsTo: false
);
usesPubOption(); usesPubOption();
} }
@ -31,20 +25,17 @@ class TestCommand extends FlutterCommand {
@override @override
String get description => 'Run Flutter unit tests for the current project (Linux only).'; String get description => 'Run Flutter unit tests for the current project (Linux only).';
@override
bool get shouldRunPub => !argResults['flutter-repo'] && super.shouldRunPub;
@override @override
bool get requiresProjectRoot => false; bool get requiresProjectRoot => false;
@override @override
Validator projectRootValidator = () { Validator projectRootValidator = () {
if (!FileSystemEntity.isFileSync('pubspec.yaml')) { if (!FileSystemEntity.isFileSync('pubspec.yaml')) {
printError('Error: No pubspec.yaml file found.\n' printError(
'If you wish to run the tests in the Flutter repository\'s \'flutter\' package,\n' 'Error: No pubspec.yaml file found in the current working directory.\n'
'pass --flutter-repo before any test paths. Otherwise, run this command from the\n' 'Run this command from the root of your project. Test files must be\n'
'root of your project. Test files must be called *_test.dart and must reside in\n' 'called *_test.dart and must reside in the package\'s \'test\'\n'
'the package\'s \'test\' directory (or one of its subdirectories).'); 'directory (or one of its subdirectories).');
return false; return false;
} }
return true; return true;
@ -74,10 +65,6 @@ class TestCommand extends FlutterCommand {
.map((FileSystemEntity entity) => path.absolute(entity.path)); .map((FileSystemEntity entity) => path.absolute(entity.path));
} }
Directory get _flutterUnitTestDir {
return new Directory(path.join(ArtifactStore.flutterRoot, 'packages', 'flutter', 'test'));
}
Directory get _currentPackageTestDir { Directory get _currentPackageTestDir {
// We don't scan the entire package, only the test/ subdirectory, so that // We don't scan the entire package, only the test/ subdirectory, so that
// files with names like like "hit_test.dart" don't get run. // files with names like like "hit_test.dart" don't get run.
@ -98,16 +85,10 @@ class TestCommand extends FlutterCommand {
Future<int> runInProject() async { Future<int> runInProject() async {
List<String> testArgs = argResults.rest.map((String testPath) => path.absolute(testPath)).toList(); List<String> testArgs = argResults.rest.map((String testPath) => path.absolute(testPath)).toList();
final bool runFlutterTests = argResults['flutter-repo']; if (!projectRootValidator())
if (!runFlutterTests && !projectRootValidator())
return 1; return 1;
// If we're running the flutter tests, we want to use the packages directory Directory testDir = _currentPackageTestDir;
// from the flutter package in order to find the proper shell binary.
if (runFlutterTests)
PackageMap.instance = new PackageMap(path.join(ArtifactStore.flutterRoot, 'packages', 'flutter', '.packages'));
Directory testDir = runFlutterTests ? _flutterUnitTestDir : _currentPackageTestDir;
if (testArgs.isEmpty) { if (testArgs.isEmpty) {
if (!testDir.existsSync()) { if (!testDir.existsSync()) {