Commit db884141 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

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

Also, add tests to verify that our coverage is actually being tested!
parent 1e53d320
The files in this directory are used as part of tests in the
`flutter_tools` package. They are here because here these tests need a
`flutter_tools` package. Some are here because here these tests need a
`pubspec.yaml` that references the flutter framework (which is
intentionally not true of the `flutter_tools` package).
intentionally not true of the `flutter_tools` package). Others are
here mostly out of peer pressure.
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:test/test.dart';
void main() {
test('trivial', () { });
}
......@@ -145,9 +145,23 @@ Future<Null> _runCoverage() async {
return;
}
final File coverageFile = new File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info'));
if (!coverageFile.existsSync()) {
print('${red}Coverage file not found.$reset');
print('Expected to find: ${coverageFile.absolute}');
print('This file is normally obtained by running `flutter update-packages`.');
exit(1);
}
coverageFile.deleteSync();
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter'),
options: const <String>['--coverage'],
);
if (!coverageFile.existsSync()) {
print('${red}Coverage file not found.$reset');
print('Expected to find: ${coverageFile.absolute}');
print('This file should have been generated by the `flutter test --coverage` script, but was not.');
exit(1);
}
print('${bold}DONE: Coverage collection successful.$reset');
}
......
......@@ -20,4 +20,4 @@ dependencies:
dev_dependencies:
# See packages/flutter_test/pubspec.yaml for why we're pinning this version.
test: 0.12.21
test: 0.12.24+2
......@@ -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
......@@ -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
......
......@@ -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
......
......@@ -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')),
......
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