55/// Unit tests for lib/src/experiment_options.dart.
66library dartdoc.experiment_options_test;
77
8- import 'dart:cli' ;
98import 'dart:io' ;
109
1110import '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