Move flutter tests from packages/unit to packages/flutter/test

This commit is contained in:
Ian Hickson
2015-12-15 22:32:45 -08:00
parent 1d39db6959
commit 7151fdd054
109 changed files with 74 additions and 72 deletions

View File

@@ -6,6 +6,6 @@ homepage: https://github.com/flutter/flutter/tree/master/packages/cassowary
environment:
sdk: '>=1.0.0 <2.0.0'
dev_dependencies:
test: 0.12.6+1
test_runner: '<=0.2.16'
dart_coveralls: '<=0.3.0'
flutter_tools:
path: ../flutter_tools
test: any # constrained by the dependency in flutter_tools

View File

@@ -3,6 +3,7 @@ version: 0.0.21
author: Flutter Authors <flutter-dev@googlegroups.com>
description: A framework for writing Flutter applications
homepage: http://flutter.io
dependencies:
collection: '>=1.1.3 <2.0.0'
intl: '>=0.12.4+2 <0.13.0'
@@ -11,7 +12,9 @@ dependencies:
sky_services: 0.0.73
vector_math: '>=1.4.3 <2.0.0'
# To pin the transitive dependency through mojo_sdk.
# See the comment in flutter_tools' pubspec.yaml. We have to pin it
# here also because sky_services depends on mojo_sdk which depends
# on test.
test: 0.12.6+1
cassowary:
@@ -19,5 +22,9 @@ dependencies:
newton:
path: ../newton
dev_dependencies:
flutter_test:
path: ../flutter_test
environment:
sdk: '>=1.12.0 <2.0.0'

View File

@@ -62,42 +62,11 @@ class AnalyzeCommand extends FlutterCommand {
}
}
bool foundTest = false;
Directory flutterDir = new Directory(path.join(ArtifactStore.flutterRoot, 'packages/unit')); // See https://github.com/flutter/flutter/issues/50
// .../packages/unit/test/*/*_test.dart
Directory tests = new Directory(path.join(flutterDir.path, 'test'));
for (FileSystemEntity entry in tests.listSync()) {
if (entry is Directory) {
for (FileSystemEntity subentry in entry.listSync()) {
if (subentry is File && subentry.path.endsWith('_test.dart')) {
dartFiles.add(subentry.path);
foundTest = true;
}
}
}
}
// .../packages/unit/benchmark/*/*_bench.dart
Directory benchmarks = new Directory(path.join(flutterDir.path, 'benchmark'));
for (FileSystemEntity entry in benchmarks.listSync()) {
if (entry is Directory) {
for (FileSystemEntity subentry in entry.listSync()) {
if (subentry is File && subentry.path.endsWith('_bench.dart')) {
dartFiles.add(subentry.path);
foundTest = true;
}
}
}
}
if (foundTest)
pubSpecDirectories.add(flutterDir.path);
// .../packages/*/bin/*.dart
// .../packages/*/lib/main.dart
// .../packages/*/test/*_test.dart
// .../packages/*/test/*/*_test.dart
// .../packages/*/benchmark/*/*_bench.dart
Directory packages = new Directory(path.join(ArtifactStore.flutterRoot, 'packages'));
for (FileSystemEntity entry in packages.listSync()) {
if (entry is Directory) {
@@ -126,12 +95,29 @@ class AnalyzeCommand extends FlutterCommand {
for (FileSystemEntity subentry in entry.listSync()) {
if (subentry is File && subentry.path.endsWith('_test.dart')) {
dartFiles.add(subentry.path);
foundTest = true;
foundOne = true;
}
}
} else if (entry is File && entry.path.endsWith('_test.dart')) {
dartFiles.add(entry.path);
foundTest = true;
foundOne = true;
}
}
}
Directory benchmarkDirectory = new Directory(path.join(entry.path, 'benchmark'));
if (benchmarkDirectory.existsSync()) {
for (FileSystemEntity entry in benchmarkDirectory.listSync()) {
if (entry is Directory) {
for (FileSystemEntity subentry in entry.listSync()) {
if (subentry is File && subentry.path.endsWith('_bench.dart')) {
dartFiles.add(subentry.path);
foundOne = true;
}
}
} else if (entry is File && entry.path.endsWith('_bench.dart')) {
dartFiles.add(entry.path);
foundOne = true;
}
}
}

View File

@@ -16,14 +16,16 @@ import '../test/loader.dart' as loader;
class TestCommand extends FlutterCommand {
String get name => 'test';
String get description => 'Runs Flutter unit tests for the current project. At least one of --debug and --release must be set.';
String get description => 'Runs Flutter unit tests for the current project.';
bool get requiresProjectRoot => false;
String get projectRootValidationErrorMessage {
return 'Error: No pubspec.yaml file found.\n'
'If you wish to run the tests in the flutter repo, pass --flutter-repo before\n'
'any test paths. Otherwise, run this command from the root of your project.';
'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).';
}
Future<String> _getShellPath(BuildConfiguration config) async {
@@ -44,7 +46,7 @@ class TestCommand extends FlutterCommand {
}
TestCommand() {
argParser.addFlag('flutter-repo', help: 'Run tests from the Flutter repository instead of the current directory.', defaultsTo: false);
argParser.addFlag('flutter-repo', help: 'Run tests from the \'flutter\' package in the Flutter repository instead of the current directory.', defaultsTo: false);
}
Iterable<String> _findTests(Directory directory) {
@@ -54,7 +56,13 @@ class TestCommand extends FlutterCommand {
}
Directory get _flutterUnitTestDir {
return new Directory(path.join(ArtifactStore.flutterRoot, 'packages', 'unit', 'test'));
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.
return new Directory('test');
}
Future<int> _runTests(List<String> testArgs, Directory testDirectory) async {
@@ -76,11 +84,11 @@ class TestCommand extends FlutterCommand {
return 1;
// If we're running the flutter tests, we want to use the packages directory
// from the unit package in order to find the proper shell binary.
// from the flutter package in order to find the proper shell binary.
if (runFlutterTests && ArtifactStore.packageRoot == 'packages')
ArtifactStore.packageRoot = path.join(ArtifactStore.flutterRoot, 'packages', 'unit', 'packages');
ArtifactStore.packageRoot = path.join(ArtifactStore.flutterRoot, 'packages', 'flutter', 'packages');
Directory testDir = runFlutterTests ? _flutterUnitTestDir : Directory.current;
Directory testDir = runFlutterTests ? _flutterUnitTestDir : _currentPackageTestDir;
if (testArgs.isEmpty)
testArgs.addAll(_findTests(testDir));

Some files were not shown because too many files have changed in this diff Show More