Migrate to runZonedGuarded (#28)
The `onError` argument to `runZoned` is deprecated. Switch to the
supported `runZonedGuarded`. Add ignored parameters for the `StackTrace`
argument to fit the more strict static type.
Bump min SDK to 2.8.1 which is the first published with the
`runZonedGuarded` API.
diff --git a/.travis.yml b/.travis.yml
index 8914450..50bda8c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
dart:
- dev
- - 2.7.0
+ - 2.8.1
dart_task:
- test
@@ -14,7 +14,7 @@
- dart: dev
dart_task:
dartanalyzer: --fatal-infos --fatal-warnings .
- - dart: 2.7.0
+ - dart: 2.8.1
dart_task:
dartanalyzer: --fatal-warnings .
diff --git a/lib/src/pattern_descriptor.dart b/lib/src/pattern_descriptor.dart
index 9de3b99..4c1760d 100644
--- a/lib/src/pattern_descriptor.dart
+++ b/lib/src/pattern_descriptor.dart
@@ -59,12 +59,12 @@
var results = await Future.wait(matchingEntries.map((entry) {
var basename = p.basename(entry);
- return runZoned(() {
+ return runZonedGuarded(() {
return Result.capture(Future.sync(() async {
await _fn(basename).validate(parent);
return basename;
}));
- }, onError: (_) {
+ }, (_, __) {
// Validate may produce multiple errors, but we ignore all but the first
// to avoid cluttering the user with many different errors from many
// different un-matched entries.
diff --git a/pubspec.yaml b/pubspec.yaml
index 0931981..290888f 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -4,7 +4,7 @@
homepage: https://github.com/dart-lang/test_descriptor
environment:
- sdk: '>=2.7.0 <3.0.0'
+ sdk: '>=2.8.1 <3.0.0'
dependencies:
archive: '^2.0.0'
diff --git a/test/directory_test.dart b/test/directory_test.dart
index 71b998e..e135086 100644
--- a/test/directory_test.dart
+++ b/test/directory_test.dart
@@ -103,7 +103,7 @@
var errors = 0;
var controller = StreamController<String>();
- runZoned(() {
+ runZonedGuarded(() {
d.dir('dir', [
d.dir('subdir', [
d.file('subfile1.txt', 'subcontents1'),
@@ -113,7 +113,7 @@
d.file('file2.txt', 'contents2')
]).validate();
},
- onError: expectAsync1((error) {
+ expectAsync2((error, _) {
errors++;
controller.add(error.toString());
if (errors == 3) controller.close();