Upgrade to the most recent test package. (#11526)

Also, add tests to verify that our coverage is actually being tested!
This commit is contained in:
Ian Hickson
2017-08-04 16:33:38 -07:00
committed by GitHub
parent 1e53d3206b
commit db88414131
8 changed files with 68 additions and 19 deletions

View File

@@ -21,6 +21,6 @@ dependencies:
sdk: flutter
dev_dependencies:
test: 0.12.21
test: any # pinned by flutter_test
mockito: ^2.0.2
quiver: ^0.24.0

View File

@@ -3,8 +3,11 @@ version: 0.0.11-dev
dependencies:
# The flutter tools depend on very specific internal implementation
# details of the 'test' package, which change between versions, so
# here we pin it precisely to avoid version skew across our packages.
test: 0.12.21
# here we pin it precisely to avoid version skew across our
# packages. When changing this, also update the pubspec.yaml files
# for the flutter_tools and devicelab packages. All other packages
# should depend on this one to transitively get the pinned version.
test: 0.12.24+2
# We use FakeAsync and other testing utilities.
quiver: ^0.24.0

View File

@@ -35,8 +35,11 @@ dependencies:
# We depend on very specific internal implementation details of the
# 'test' package, which change between versions, so here we pin it
# precisely.
test: 0.12.21
# precisely. When changing this, also update the pubspec.yaml files
# for the flutter_test and devicelab packages. All other packages
# should depend on flutter_test to transitively get the pinned
# version.
test: 0.12.24+2
# Version from the vended Dart SDK as defined in `dependency_overrides`.
analyzer: any

View File

@@ -47,18 +47,33 @@ void main() {
testUsingContext('run a test when its name matches a regexp', () async {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArgs: const <String>["--name", "inc.*de"]);
if (!result.stdout.contains("+1: All tests passed"))
fail("unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n");
extraArgs: const <String>['--name', 'inc.*de']);
if (!result.stdout.contains('+1: All tests passed'))
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
expect(result.exitCode, 0);
});
testUsingContext('run a test when its name contains a string', () async {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArgs: const <String>["--plain-name", "include"]);
if (!result.stdout.contains("+1: All tests passed"))
fail("unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n");
extraArgs: const <String>['--plain-name', 'include']);
if (!result.stdout.contains('+1: All tests passed'))
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
expect(result.exitCode, 0);
});
testUsingContext('test runs to completion', () async {
Cache.flutterRoot = '../..';
final ProcessResult result = await _runFlutterTest('trivial', automatedTestsDirectory, flutterTestDirectory,
extraArgs: const <String>['--verbose']);
if ((!result.stdout.contains('+1: All tests passed')) ||
(!result.stdout.contains('test 0: starting shell process')) ||
(!result.stdout.contains('test 0: deleting temporary directory')) ||
(!result.stdout.contains('test 0: finished')) ||
(!result.stdout.contains('test package returned with exit code 0')))
fail('unexpected output from test:\n\n${result.stdout}\n-- end stdout --\n\n');
if (result.stderr.isNotEmpty)
fail('unexpected error output from test:\n\n${result.stderr}\n-- end stderr --\n\n');
expect(result.exitCode, 0);
});
@@ -69,7 +84,7 @@ Future<Null> _testFile(String testName, String workingDirectory, String testDire
final String fullTestExpectation = fs.path.join(testDirectory, '${testName}_expectation.txt');
final File expectationFile = fs.file(fullTestExpectation);
if (!expectationFile.existsSync())
fail("missing expectation file: $expectationFile");
fail('missing expectation file: $expectationFile');
while (_testExclusionLock != null)
await _testExclusionLock;
@@ -116,13 +131,17 @@ Future<Null> _testFile(String testName, String workingDirectory, String testDire
expect(exec.stderr, '');
}
Future<ProcessResult> _runFlutterTest(String testName, String workingDirectory, String testDirectory,
{List<String> extraArgs = const <String>[]}) async {
Future<ProcessResult> _runFlutterTest(
String testName,
String workingDirectory,
String testDirectory, {
List<String> extraArgs: const <String>[],
}) async {
final String testFilePath = fs.path.join(testDirectory, '${testName}_test.dart');
final File testFile = fs.file(testFilePath);
if (!testFile.existsSync())
fail("missing test file: $testFile");
fail('missing test file: $testFile');
final List<String> args = <String>[
fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')),