From 95214adca76275849cf28e428c41e7a83f814fce Mon Sep 17 00:00:00 2001 From: Konstantin Scheglov Date: Mon, 6 Jul 2020 16:11:58 -0700 Subject: [PATCH] Update to analyzer: ^0.39.12, and use overrideKnownFeaturesAsync() instead of dart:cli. (#2250) --- pubspec.yaml | 2 +- test/experiment_options_test.dart | 38 ++++++++++++------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 55e20fe8ed..555a7b62d7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=2.7.0 <3.0.0' dependencies: - analyzer: ^0.39.11 + analyzer: ^0.39.12 args: '>=1.5.0 <2.0.0' collection: ^1.2.0 cli_util: ^0.1.3+2 diff --git a/test/experiment_options_test.dart b/test/experiment_options_test.dart index 10f1b03500..b0421b8c75 100644 --- a/test/experiment_options_test.dart +++ b/test/experiment_options_test.dart @@ -5,7 +5,6 @@ /// Unit tests for lib/src/experiment_options.dart. library dartdoc.experiment_options_test; -import 'dart:cli'; import 'dart:io'; import 'package:analyzer/src/dart/analysis/experiments.dart'; @@ -19,9 +18,9 @@ void main() { ExperimentalFeature defaultOnNotExpired, defaultOffNotExpired; ExperimentalFeature defaultOnExpired, defaultOffExpired; - void withSyntheticExperimentalFeatures( - void Function() operation, - ) { + Future withSyntheticExperimentalFeatures( + Future Function() operation, + ) async { defaultOnNotExpired = ExperimentalFeature( index: 0, enableString: 'a', @@ -55,16 +54,14 @@ void main() { firstSupportedVersion: null, ); - overrideKnownFeatures( + await overrideKnownFeaturesAsync( { 'a': defaultOnNotExpired, 'b': defaultOffNotExpired, 'c': defaultOnExpired, 'd': defaultOffExpired, }, - () { - operation(); - }, + operation, ); } @@ -78,25 +75,20 @@ void main() { }); group('Experimental options test', () { - void withExperimentOptions( + Future withExperimentOptions( void Function(DartdocOptionSet) operation, - ) { - withSyntheticExperimentalFeatures(() { - // The enclosing function expects only synchronous function argument. - // But `fromOptionGenerators` is asynchronous. - // So, we have to use `waitFor` to adapt it. - var experimentOptions = waitFor( - DartdocOptionSet.fromOptionGenerators( - 'dartdoc', - [createExperimentOptions], - ), + ) async { + await withSyntheticExperimentalFeatures(() async { + var experimentOptions = await DartdocOptionSet.fromOptionGenerators( + 'dartdoc', + [createExperimentOptions], ); operation(experimentOptions); }); } - test('Defaults work for all options', () { - withExperimentOptions((experimentOptions) { + test('Defaults work for all options', () async { + await withExperimentOptions((experimentOptions) { experimentOptions.parseArguments([]); var tester = DartdocOptionContext(experimentOptions, emptyTempDir); expect(tester.experimentStatus.isEnabled(defaultOnNotExpired), isTrue); @@ -107,8 +99,8 @@ void main() { }); }); - test('Overriding defaults works via args', () { - withExperimentOptions((experimentOptions) { + test('Overriding defaults works via args', () async { + await withExperimentOptions((experimentOptions) { // Set all experiments to non-default values. experimentOptions.parseArguments([ '--enable-experiment',