Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: pkg/analyzer/test/source/analysis_options_provider_test.dart

Issue 1415153004: Improved YAML doc exception handling. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/source/analysis_options_provider.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.source.analysis_options_provider; 5 library test.source.analysis_options_provider;
6 6
7 import 'package:analyzer/file_system/memory_file_system.dart'; 7 import 'package:analyzer/file_system/memory_file_system.dart';
8 import 'package:analyzer/source/analysis_options_provider.dart'; 8 import 'package:analyzer/source/analysis_options_provider.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:yaml/yaml.dart'; 10 import 'package:yaml/yaml.dart';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 try { 68 try {
69 Map<String, YamlNode> options = 69 Map<String, YamlNode> options =
70 optionsProvider.getOptions(resourceProvider.getFolder('/')); 70 optionsProvider.getOptions(resourceProvider.getFolder('/'));
71 expect(options, isNotNull); 71 expect(options, isNotNull);
72 } catch (e) { 72 } catch (e) {
73 exceptionCaught = true; 73 exceptionCaught = true;
74 } 74 }
75 expect(exceptionCaught, isTrue); 75 expect(exceptionCaught, isTrue);
76 }); 76 });
77 }); 77 });
78 group('AnalysisOptionsProvider', () {
79 test('test_bad_yaml', () {
80 var src = '''
81 analyzer:
82 exclude:
83 - test/data/*
84 error:
85 invalid_assignment: ignore
86 unused_local_variable: # <=== bang
87 linter:
88 rules:
89 - camel_case_types
90 ''';
91
92 var optionsProvider = new AnalysisOptionsProvider();
93 expect(() => optionsProvider.getOptionsFromString(src),
94 throwsA(new isInstanceOf<OptionsFormatException>()));
95 });
96 });
78 } 97 }
79 98
80 MemoryResourceProvider resourceProvider; 99 MemoryResourceProvider resourceProvider;
81 100
82 buildResourceProvider({bool emptyAnalysisOptions : false, 101 buildResourceProvider(
83 bool badAnalysisOptions : false}) { 102 {bool emptyAnalysisOptions: false, bool badAnalysisOptions: false}) {
84 resourceProvider = new MemoryResourceProvider(); 103 resourceProvider = new MemoryResourceProvider();
85 resourceProvider.newFolder('/empty'); 104 resourceProvider.newFolder('/empty');
86 resourceProvider.newFolder('/tmp'); 105 resourceProvider.newFolder('/tmp');
87 if (badAnalysisOptions) { 106 if (badAnalysisOptions) {
88 resourceProvider.newFile('/.analysis_options', r''':'''); 107 resourceProvider.newFile('/.analysis_options', r''':''');
89 } else if (emptyAnalysisOptions) { 108 } else if (emptyAnalysisOptions) {
90 resourceProvider.newFile('/.analysis_options', r'''#empty'''); 109 resourceProvider.newFile('/.analysis_options', r'''#empty''');
91 } else { 110 } else {
92 resourceProvider.newFile( 111 resourceProvider.newFile(
93 '/.analysis_options', 112 '/.analysis_options',
94 r''' 113 r'''
95 analyzer: 114 analyzer:
96 ignore: 115 ignore:
97 - ignoreme.dart 116 - ignoreme.dart
98 - 'sdk_ext/**' 117 - 'sdk_ext/**'
99 '''); 118 ''');
100 } 119 }
101 } 120 }
102 121
103 clearResourceProvider() { 122 clearResourceProvider() {
104 resourceProvider = null; 123 resourceProvider = null;
105 } 124 }
106 125
107 emptyResourceProvider() { 126 emptyResourceProvider() {
108 resourceProvider = new MemoryResourceProvider(); 127 resourceProvider = new MemoryResourceProvider();
109 } 128 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/source/analysis_options_provider.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698