Skip to content

Commit 95214ad

Browse files
authored
Update to analyzer: ^0.39.12, and use overrideKnownFeaturesAsync() instead of dart:cli. (#2250)
1 parent cfc9492 commit 95214ad

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ environment:
77
sdk: '>=2.7.0 <3.0.0'
88

99
dependencies:
10-
analyzer: ^0.39.11
10+
analyzer: ^0.39.12
1111
args: '>=1.5.0 <2.0.0'
1212
collection: ^1.2.0
1313
cli_util: ^0.1.3+2

test/experiment_options_test.dart

+15-23
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
/// Unit tests for lib/src/experiment_options.dart.
66
library dartdoc.experiment_options_test;
77

8-
import 'dart:cli';
98
import 'dart:io';
109

1110
import 'package:analyzer/src/dart/analysis/experiments.dart';
@@ -19,9 +18,9 @@ void main() {
1918
ExperimentalFeature defaultOnNotExpired, defaultOffNotExpired;
2019
ExperimentalFeature defaultOnExpired, defaultOffExpired;
2120

22-
void withSyntheticExperimentalFeatures(
23-
void Function() operation,
24-
) {
21+
Future<void> withSyntheticExperimentalFeatures(
22+
Future<void> Function() operation,
23+
) async {
2524
defaultOnNotExpired = ExperimentalFeature(
2625
index: 0,
2726
enableString: 'a',
@@ -55,16 +54,14 @@ void main() {
5554
firstSupportedVersion: null,
5655
);
5756

58-
overrideKnownFeatures(
57+
await overrideKnownFeaturesAsync(
5958
{
6059
'a': defaultOnNotExpired,
6160
'b': defaultOffNotExpired,
6261
'c': defaultOnExpired,
6362
'd': defaultOffExpired,
6463
},
65-
() {
66-
operation();
67-
},
64+
operation,
6865
);
6966
}
7067

@@ -78,25 +75,20 @@ void main() {
7875
});
7976

8077
group('Experimental options test', () {
81-
void withExperimentOptions(
78+
Future<void> withExperimentOptions(
8279
void Function(DartdocOptionSet) operation,
83-
) {
84-
withSyntheticExperimentalFeatures(() {
85-
// The enclosing function expects only synchronous function argument.
86-
// But `fromOptionGenerators` is asynchronous.
87-
// So, we have to use `waitFor` to adapt it.
88-
var experimentOptions = waitFor(
89-
DartdocOptionSet.fromOptionGenerators(
90-
'dartdoc',
91-
[createExperimentOptions],
92-
),
80+
) async {
81+
await withSyntheticExperimentalFeatures(() async {
82+
var experimentOptions = await DartdocOptionSet.fromOptionGenerators(
83+
'dartdoc',
84+
[createExperimentOptions],
9385
);
9486
operation(experimentOptions);
9587
});
9688
}
9789

98-
test('Defaults work for all options', () {
99-
withExperimentOptions((experimentOptions) {
90+
test('Defaults work for all options', () async {
91+
await withExperimentOptions((experimentOptions) {
10092
experimentOptions.parseArguments([]);
10193
var tester = DartdocOptionContext(experimentOptions, emptyTempDir);
10294
expect(tester.experimentStatus.isEnabled(defaultOnNotExpired), isTrue);
@@ -107,8 +99,8 @@ void main() {
10799
});
108100
});
109101

110-
test('Overriding defaults works via args', () {
111-
withExperimentOptions((experimentOptions) {
102+
test('Overriding defaults works via args', () async {
103+
await withExperimentOptions((experimentOptions) {
112104
// Set all experiments to non-default values.
113105
experimentOptions.parseArguments([
114106
'--enable-experiment',

0 commit comments

Comments
 (0)