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