Skip to content

Commit

Permalink
Update to analyzer: ^0.39.12, and use overrideKnownFeaturesAsync() in…
Browse files Browse the repository at this point in the history
…stead of dart:cli. (#2250)
  • Loading branch information
scheglov authored Jul 6, 2020
1 parent cfc9492 commit 95214ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 15 additions & 23 deletions test/experiment_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -19,9 +18,9 @@ void main() {
ExperimentalFeature defaultOnNotExpired, defaultOffNotExpired;
ExperimentalFeature defaultOnExpired, defaultOffExpired;

void withSyntheticExperimentalFeatures(
void Function() operation,
) {
Future<void> withSyntheticExperimentalFeatures(
Future<void> Function() operation,
) async {
defaultOnNotExpired = ExperimentalFeature(
index: 0,
enableString: 'a',
Expand Down Expand Up @@ -55,16 +54,14 @@ void main() {
firstSupportedVersion: null,
);

overrideKnownFeatures(
await overrideKnownFeaturesAsync(
{
'a': defaultOnNotExpired,
'b': defaultOffNotExpired,
'c': defaultOnExpired,
'd': defaultOffExpired,
},
() {
operation();
},
operation,
);
}

Expand All @@ -78,25 +75,20 @@ void main() {
});

group('Experimental options test', () {
void withExperimentOptions(
Future<void> 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);
Expand All @@ -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',
Expand Down

0 comments on commit 95214ad

Please sign in to comment.