From c46faeab54751b4cac4f5650744224b06bb6816e Mon Sep 17 00:00:00 2001 From: Gary Roumanis <groumanis@gmail.com> Date: Mon, 11 Jun 2018 17:36:08 -0700 Subject: [PATCH] More Dart 2 fixes (#867) More towards #842 - Export @Retry annotation (this is technically broken now but the corresponding tests only fail under preview-dart-2) - Fix type issue with mapping over dynamic values --- lib/src/frontend/retry.dart | 15 +++++++++++++++ lib/src/runner/compiler_pool.dart | 4 ++-- lib/test.dart | 1 + test/runner/loader_test.dart | 4 +++- 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 lib/src/frontend/retry.dart diff --git a/lib/src/frontend/retry.dart b/lib/src/frontend/retry.dart new file mode 100644 index 00000000..0c57f674 --- /dev/null +++ b/lib/src/frontend/retry.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// An annotation for marking a test to be retried. +/// +/// A test with retries enabled will be re-run if it fails for a reason +/// other than [TestFailure]. +class Retry { + /// The number of times the test will be retried. + final int count; + + /// Marks a test to be retried. + const Retry(this.count); +} diff --git a/lib/src/runner/compiler_pool.dart b/lib/src/runner/compiler_pool.dart index 506aefa4..6a6b5e30 100644 --- a/lib/src/runner/compiler_pool.dart +++ b/lib/src/runner/compiler_pool.dart @@ -115,8 +115,8 @@ class CompilerPool { var map = jsonDecode(new File(mapPath).readAsStringSync()); var root = map['sourceRoot'] as String; - map['sources'] = map['sources'].map((String source) { - var url = Uri.parse(root + source); + map['sources'] = map['sources'].map((source) { + var url = Uri.parse(root + '$source'); if (url.scheme != '' && url.scheme != 'file') return source; if (url.path.endsWith("/runInBrowser.dart")) return ""; return p.toUri(mapPath).resolveUri(url).toString(); diff --git a/lib/test.dart b/lib/test.dart index 2c98dba2..2712bd3e 100644 --- a/lib/test.dart +++ b/lib/test.dart @@ -27,6 +27,7 @@ export 'src/frontend/future_matchers.dart'; export 'src/frontend/on_platform.dart'; export 'src/frontend/never_called.dart'; export 'src/frontend/prints_matcher.dart'; +export 'src/frontend/retry.dart'; export 'src/frontend/skip.dart'; export 'src/frontend/spawn_hybrid.dart'; export 'src/frontend/stream_matcher.dart'; diff --git a/test/runner/loader_test.dart b/test/runner/loader_test.dart index 13eeae5d..da093cb8 100644 --- a/test/runner/loader_test.dart +++ b/test/runner/loader_test.dart @@ -5,6 +5,7 @@ @TestOn("vm") import 'package:path/path.dart' as p; +import 'package:test/src/runner/runner_suite.dart'; import 'package:test_descriptor/test_descriptor.dart' as d; import 'package:test/src/backend/state.dart'; @@ -123,7 +124,8 @@ void main() { }); test("can run tests in those suites", () { - var suite = suites.firstWhere((suite) => suite.path.contains("a_test")); + var suite = suites + .firstWhere((RunnerSuite suite) => suite.path.contains("a_test")); var liveTest = suite.group.entries[1].load(suite); expectSingleFailure(liveTest); return liveTest.run().whenComplete(() => liveTest.close()); -- GitLab