Skip to content

Commit 5fe2f3b

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
[analyzer] Fix options-parsing tests on Windows
Change-Id: I8b625783e1273f052db7864395821ccaf4307c59 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279075 Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 73bdcab commit 5fe2f3b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

pkg/analyzer/test/src/task/options_test.dart

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import 'package:test_reflective_loader/test_reflective_loader.dart';
2121
import 'package:yaml/yaml.dart';
2222

2323
import '../../generated/test_support.dart';
24-
import '../../resource_utils.dart';
2524

2625
main() {
2726
defineReflectiveSuite(() {
@@ -626,7 +625,6 @@ linter:
626625

627626
@reflectiveTest
628627
class OptionsProviderTest with ResourceProviderMixin {
629-
late final TestPathTranslator pathTranslator;
630628
late final SourceFactory sourceFactory;
631629

632630
late final AnalysisOptionsProvider provider;
@@ -644,9 +642,9 @@ class OptionsProviderTest with ResourceProviderMixin {
644642

645643
void assertErrorsInOptionsFile(
646644
String code, List<ExpectedError> expectedErrors) async {
647-
pathTranslator.newFile(optionsFilePath, code);
645+
newFile(optionsFilePath, code);
648646
var errors = analyzeAnalysisOptions(
649-
sourceFactory.forUri('file://$optionsFilePath')!,
647+
sourceFactory.forUri2(toUri(optionsFilePath))!,
650648
code,
651649
sourceFactory,
652650
'/',
@@ -678,20 +676,19 @@ class OptionsProviderTest with ResourceProviderMixin {
678676

679677
void setUp() {
680678
resourceProvider = MemoryResourceProvider();
681-
pathTranslator = TestPathTranslator(resourceProvider);
682679
sourceFactory = SourceFactory([ResourceUriResolver(resourceProvider)]);
683680
provider = AnalysisOptionsProvider(sourceFactory);
684681
}
685682

686683
test_chooseFirstPlugin() {
687-
pathTranslator.newFile('/more_options.yaml', '''
684+
newFile('/more_options.yaml', '''
688685
analyzer:
689686
plugins:
690687
- plugin_ddd
691688
- plugin_ggg
692689
- plugin_aaa
693690
''');
694-
pathTranslator.newFile('/other_options.yaml', '''
691+
newFile('/other_options.yaml', '''
695692
include: more_options.yaml
696693
analyzer:
697694
plugins:
@@ -707,7 +704,7 @@ analyzer:
707704
- plugin_iii
708705
- plugin_ccc
709706
''';
710-
pathTranslator.newFile(optionsFilePath, code);
707+
newFile(optionsFilePath, code);
711708

712709
final options = _getOptionsObject('/');
713710
expect(options.enabledPluginNames, unorderedEquals(['plugin_ddd']));
@@ -722,7 +719,7 @@ analyzer:
722719
// TODO(https://github.com/dart-lang/sdk/issues/50980): add tests with
723720
// duplicate plugin names.
724721

725-
pathTranslator.newFile('/other_options.yaml', '''
722+
newFile('/other_options.yaml', '''
726723
analyzer:
727724
exclude:
728725
- toplevelexclude.dart
@@ -746,7 +743,7 @@ linter:
746743
rules:
747744
- lowlevellint
748745
''';
749-
pathTranslator.newFile(optionsFilePath, code);
746+
newFile(optionsFilePath, code);
750747

751748
final lowlevellint = TestRule.withName('lowlevellint');
752749
final toplevellint = TestRule.withName('toplevellint');
@@ -769,7 +766,7 @@ linter:
769766
}
770767

771768
test_multiplePlugins_firstIsDirectlyIncluded_secondIsDirect_listForm() {
772-
pathTranslator.newFile('/other_options.yaml', '''
769+
newFile(convertPath('/other_options.yaml'), '''
773770
analyzer:
774771
plugins:
775772
- plugin_one
@@ -785,7 +782,7 @@ analyzer:
785782
}
786783

787784
test_multiplePlugins_firstIsDirectlyIncluded_secondIsDirect_mapForm() {
788-
pathTranslator.newFile('/other_options.yaml', '''
785+
newFile('/other_options.yaml', '''
789786
analyzer:
790787
plugins:
791788
- plugin_one
@@ -802,7 +799,7 @@ analyzer:
802799
}
803800

804801
test_multiplePlugins_firstIsDirectlyIncluded_secondIsDirect_scalarForm() {
805-
pathTranslator.newFile('/other_options.yaml', '''
802+
newFile('/other_options.yaml', '''
806803
analyzer:
807804
plugins:
808805
- plugin_one
@@ -817,12 +814,12 @@ analyzer:
817814
}
818815

819816
test_multiplePlugins_firstIsIndirectlyIncluded_secondIsDirect() {
820-
pathTranslator.newFile('/more_options.yaml', '''
817+
newFile('/more_options.yaml', '''
821818
analyzer:
822819
plugins:
823820
- plugin_one
824821
''');
825-
pathTranslator.newFile('/other_options.yaml', '''
822+
newFile('/other_options.yaml', '''
826823
include: more_options.yaml
827824
''');
828825
assertErrorsInOptionsFile(r'''
@@ -836,12 +833,12 @@ analyzer:
836833
}
837834

838835
test_multiplePlugins_firstIsIndirectlyIncluded_secondIsDirectlyIncluded() {
839-
pathTranslator.newFile('/more_options.yaml', '''
836+
newFile('/more_options.yaml', '''
840837
analyzer:
841838
plugins:
842839
- plugin_one
843840
''');
844-
pathTranslator.newFile('/other_options.yaml', '''
841+
newFile('/other_options.yaml', '''
845842
include: more_options.yaml
846843
analyzer:
847844
plugins:
@@ -908,7 +905,7 @@ analyzer:
908905
}
909906

910907
List<AnalysisError> validate(String code, List<ErrorCode> expected) {
911-
pathTranslator.newFile(optionsFilePath, code);
908+
newFile(optionsFilePath, code);
912909
var errors = analyzeAnalysisOptions(
913910
sourceFactory.forUri('file://$optionsFilePath')!,
914911
code,
@@ -924,7 +921,7 @@ analyzer:
924921
}
925922

926923
YamlMap _getOptions(String posixPath) {
927-
var resource = pathTranslator.getResource(posixPath) as Folder;
924+
var resource = getFolder(posixPath);
928925
return provider.getOptions(resource);
929926
}
930927

0 commit comments

Comments
 (0)