From 673ac063c94a5127e0c7c2c985934f8ba6ead3d1 Mon Sep 17 00:00:00 2001 From: Corwin Sheahan Date: Fri, 28 Dec 2018 14:57:24 -0700 Subject: [PATCH 1/3] quit if dartium or content-shell on dart 2 --- lib/src/dart_dev_cli.dart | 12 +++++++++--- lib/src/tasks/test/api.dart | 19 +++++++++++++++---- test/integration/test_test.dart | 27 ++++++++++++++++++++++++++- 3 files changed, 50 insertions(+), 8 deletions(-) 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..54a9f9f9 100644 --- a/lib/src/tasks/test/api.dart +++ b/lib/src/tasks/test/api.dart @@ -32,10 +32,21 @@ TestTask test( List tests: const []}) { final executable = 'pub'; final args = []; - if (dartMajorVersion == 2 && hasImmediateDependency('build_test')) { - args.addAll(['run', 'build_runner', 'test', '--']); - } else { - args.addAll(['run', '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']); + } } if (concurrency != null) { diff --git a/test/integration/test_test.dart b/test/integration/test_test.dart index fc99dbac..dc1c8121 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: 'dart1-only'); + + test('should not fail if using dartium on Dart1', () async { + expect(runTests(projectWithPassingTests, platform: 'dartium'), + throwsA(new isInstanceOf())); + }, tags: 'dart1-only'); + + test('should not fail if using content-shell on Dart1', () async { + expect(runTests(projectWithPassingTests, platform: 'content-shell'), + throwsA(new isInstanceOf())); + }, tags: 'dart1-only'); }); } From b8a9b0b320a9b3b44fe41e27f5e000ce7dc9a2b1 Mon Sep 17 00:00:00 2001 From: Corwin Sheahan Date: Fri, 28 Dec 2018 15:11:21 -0700 Subject: [PATCH 2/3] fix dart 1 pub run test --- lib/src/tasks/test/api.dart | 2 ++ test/integration/test_test.dart | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/src/tasks/test/api.dart b/lib/src/tasks/test/api.dart index 54a9f9f9..e25aeeea 100644 --- a/lib/src/tasks/test/api.dart +++ b/lib/src/tasks/test/api.dart @@ -47,6 +47,8 @@ TestTask test( } else { args.addAll(['run', 'test']); } + } else { + args.addAll(['run', 'test']); } if (concurrency != null) { diff --git a/test/integration/test_test.dart b/test/integration/test_test.dart index dc1c8121..e3008040 100644 --- a/test/integration/test_test.dart +++ b/test/integration/test_test.dart @@ -259,16 +259,14 @@ void main() { test('should fail if using content-shell on Dart2', () async { expect(runTests(projectWithPassingTests, platform: 'content-shell'), throwsA(new isInstanceOf())); - }, tags: 'dart1-only'); + }, tags: 'dart2-only'); test('should not fail if using dartium on Dart1', () async { - expect(runTests(projectWithPassingTests, platform: 'dartium'), - throwsA(new isInstanceOf())); + expect(await runTests(projectWithPassingTests, platform: 'dartium'), equals(1)); }, tags: 'dart1-only'); test('should not fail if using content-shell on Dart1', () async { - expect(runTests(projectWithPassingTests, platform: 'content-shell'), - throwsA(new isInstanceOf())); + expect(await runTests(projectWithPassingTests, platform: 'content-shell'), equals(1)); }, tags: 'dart1-only'); }); } From fd5db6e65014673ed357aa6fe036420d800aac54 Mon Sep 17 00:00:00 2001 From: Corwin Sheahan Date: Wed, 2 Jan 2019 08:43:36 -0700 Subject: [PATCH 3/3] format on dart 2 --- test/integration/test_test.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/integration/test_test.dart b/test/integration/test_test.dart index e3008040..31d380c7 100644 --- a/test/integration/test_test.dart +++ b/test/integration/test_test.dart @@ -262,11 +262,13 @@ void main() { }, tags: 'dart2-only'); test('should not fail if using dartium on Dart1', () async { - expect(await runTests(projectWithPassingTests, platform: 'dartium'), equals(1)); + 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)); + expect(await runTests(projectWithPassingTests, platform: 'content-shell'), + equals(1)); }, tags: 'dart1-only'); }); }