Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AF-3695: Quit test task early if dartium or content-shell on Dart 2 #285

Merged
merged 3 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/src/dart_dev_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,15 @@ Future _run(List<String> args) async {

TaskConfig config = _cliConfigs[task];
await runAll(config.before);
CliResult result =
await _cliTasks[task].run(env.command, color: env['color']);
await runAll(config.after);
CliResult result;
try {
result = await _cliTasks[task].run(env.command, color: env['color']);
await runAll(config.after);
} on ArgumentError catch (e) {
reporter.error(e.message, shout: true);
exitCode = 1;
return;
}

reporter.log('');
if (result.successful) {
Expand Down
17 changes: 15 additions & 2 deletions lib/src/tasks/test/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,21 @@ TestTask test(
List<String> tests: const []}) {
final executable = 'pub';
final args = <String>[];
if (dartMajorVersion == 2 && hasImmediateDependency('build_test')) {
args.addAll(['run', 'build_runner', 'test', '--']);

if (dartMajorVersion == 2) {
var invalidPlatforms = new Set.from(['dartium', 'content-shell']);
var foundInvalidPlatforms =
invalidPlatforms.intersection(platforms.toSet());
if (foundInvalidPlatforms.isNotEmpty) {
throw new ArgumentError(
'Test platforms that are incompatible with Dart 2 detected: $foundInvalidPlatforms');
}

if (hasImmediateDependency('build_test')) {
args.addAll(['run', 'build_runner', 'test', '--']);
} else {
args.addAll(['run', 'test']);
}
} else {
args.addAll(['run', 'test']);
}
Expand Down
27 changes: 26 additions & 1 deletion test/integration/test_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ Future<int> runTests(String projectPath,
String testName: '',
bool runCustomPubServe: false,
int pubServePort: 56090,
String webCompiler}) async {
String webCompiler,
String platform}) async {
await Process.run('pub', ['get'], workingDirectory: projectPath);

final args = <String>['run', 'dart_dev', 'test', '--no-color'];
Expand Down Expand Up @@ -93,6 +94,10 @@ Future<int> runTests(String projectPath,
args.add(webCompilerArg);
}

if (platform != null) {
args.addAll(['-p', platform]);
}

TaskProcess process =
new TaskProcess('pub', args, workingDirectory: projectPath);

Expand Down Expand Up @@ -245,5 +250,25 @@ void main() {
await runTests(projectThatNeedsBuildRunner, expectBuildRunner: true),
equals(1));
}, tags: 'dart2-only');

test('should fail if using dartium on Dart2', () async {
expect(runTests(projectWithPassingTests, platform: 'dartium'),
throwsA(new isInstanceOf<TestFailure>()));
}, tags: 'dart2-only');

test('should fail if using content-shell on Dart2', () async {
expect(runTests(projectWithPassingTests, platform: 'content-shell'),
throwsA(new isInstanceOf<TestFailure>()));
}, tags: 'dart2-only');

test('should not fail if using dartium on Dart1', () async {
expect(await runTests(projectWithPassingTests, platform: 'dartium'),
equals(1));
}, tags: 'dart1-only');

test('should not fail if using content-shell on Dart1', () async {
expect(await runTests(projectWithPassingTests, platform: 'content-shell'),
equals(1));
}, tags: 'dart1-only');
});
}