diff --git a/lib/src/dart_dev_cli.dart b/lib/src/dart_dev_cli.dart index ca79846b..d282207b 100644 --- a/lib/src/dart_dev_cli.dart +++ b/lib/src/dart_dev_cli.dart @@ -170,9 +170,15 @@ Future _run(List 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) { diff --git a/lib/src/tasks/test/api.dart b/lib/src/tasks/test/api.dart index 6ae6e2a6..e25aeeea 100644 --- a/lib/src/tasks/test/api.dart +++ b/lib/src/tasks/test/api.dart @@ -32,8 +32,21 @@ TestTask test( List tests: const []}) { final executable = 'pub'; final args = []; - 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']); } diff --git a/test/integration/test_test.dart b/test/integration/test_test.dart index fc99dbac..31d380c7 100644 --- a/test/integration/test_test.dart +++ b/test/integration/test_test.dart @@ -45,7 +45,8 @@ Future 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 = ['run', 'dart_dev', 'test', '--no-color']; @@ -93,6 +94,10 @@ Future runTests(String projectPath, args.add(webCompilerArg); } + if (platform != null) { + args.addAll(['-p', platform]); + } + TaskProcess process = new TaskProcess('pub', args, workingDirectory: projectPath); @@ -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())); + }, tags: 'dart2-only'); + + test('should fail if using content-shell on Dart2', () async { + expect(runTests(projectWithPassingTests, platform: 'content-shell'), + throwsA(new isInstanceOf())); + }, 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'); }); }