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

Side by Side Diff: pkg/analyzer_cli/test/driver_test.dart

Issue 2364643002: Replace using reprecated 'package:analyzer/src/generated/error.dart'. (Closed)
Patch Set: Created 4 years, 3 months 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_cli/lib/src/error_formatter.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 analyzer_cli.test.driver; 5 library analyzer_cli.test.driver;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analyzer/error/error.dart';
9 import 'package:analyzer/plugin/options.dart'; 10 import 'package:analyzer/plugin/options.dart';
10 import 'package:analyzer/source/analysis_options_provider.dart'; 11 import 'package:analyzer/source/analysis_options_provider.dart';
11 import 'package:analyzer/source/error_processor.dart'; 12 import 'package:analyzer/source/error_processor.dart';
13 import 'package:analyzer/src/error/codes.dart';
12 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/error.dart';
14 import 'package:analyzer/src/generated/source.dart'; 15 import 'package:analyzer/src/generated/source.dart';
15 import 'package:analyzer/src/services/lint.dart'; 16 import 'package:analyzer/src/services/lint.dart';
17 import 'package:analyzer/src/task/options.dart';
16 import 'package:analyzer_cli/src/driver.dart'; 18 import 'package:analyzer_cli/src/driver.dart';
17 import 'package:analyzer_cli/src/options.dart'; 19 import 'package:analyzer_cli/src/options.dart';
18 import 'package:path/path.dart' as path; 20 import 'package:path/path.dart' as path;
19 import 'package:plugin/plugin.dart'; 21 import 'package:plugin/plugin.dart';
20 import 'package:unittest/unittest.dart'; 22 import 'package:unittest/unittest.dart';
21 import 'package:yaml/src/yaml_node.dart'; 23 import 'package:yaml/src/yaml_node.dart';
22 24
23 import 'utils.dart'; 25 import 'utils.dart';
24 26
25 main() { 27 main() {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 runLinter(); 199 runLinter();
198 expect(getLints(driver.context), isEmpty); 200 expect(getLints(driver.context), isEmpty);
199 }); 201 });
200 202
201 test('no generated warnings', () { 203 test('no generated warnings', () {
202 runLinter(); 204 runLinter();
203 expect(outSink.toString(), contains('No issues found')); 205 expect(outSink.toString(), contains('No issues found'));
204 }); 206 });
205 }); 207 });
206 } 208 }
209
207 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); 210 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE);
208 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 211 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
209 }); 212 });
210 213
211 test('containsLintRuleEntry', () { 214 test('containsLintRuleEntry', () {
212 Map<String, YamlNode> options; 215 Map<String, YamlNode> options;
213 options = parseOptions(''' 216 options = parseOptions('''
214 linter: 217 linter:
215 rules: 218 rules:
216 - foo 219 - foo
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 expect(processorFor(undefined_function).severity, 299 expect(processorFor(undefined_function).severity,
297 ErrorSeverity.WARNING); 300 ErrorSeverity.WARNING);
298 // Should not be made fatal by `--fatal-warnings`. 301 // Should not be made fatal by `--fatal-warnings`.
299 expect(outSink.toString(), 302 expect(outSink.toString(),
300 contains("[warning] The function 'baz' is not defined")); 303 contains("[warning] The function 'baz' is not defined"));
301 expect( 304 expect(
302 outSink.toString(), contains("1 error and 1 warning found.")); 305 outSink.toString(), contains("1 error and 1 warning found."));
303 }); 306 });
304 }); 307 });
305 } 308 }
309
306 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); 310 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE);
307 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 311 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
308 }); 312 });
309 313
310 void createTests(String designator, String optionsFileName) { 314 void createTests(String designator, String optionsFileName) {
311 group('build-mode - $designator', () { 315 group('build-mode - $designator', () {
312 // Shared driver command. 316 // Shared driver command.
313 void doDrive(String filePath, {List<String> additionalArgs: const []}) { 317 void doDrive(String filePath, {List<String> additionalArgs: const []}) {
314 drive('file:///test_file.dart|$filePath', 318 drive('file:///test_file.dart|$filePath',
315 args: [ 319 args: [
(...skipping 28 matching lines...) Expand all
344 348
345 test( 349 test(
346 'Succeeds if there are errors, when --build-suppress-exit-code is gi ven', 350 'Succeeds if there are errors, when --build-suppress-exit-code is gi ven',
347 () { 351 () {
348 doDrive('data/file_with_error.dart', 352 doDrive('data/file_with_error.dart',
349 additionalArgs: ['--build-suppress-exit-code']); 353 additionalArgs: ['--build-suppress-exit-code']);
350 expect(exitCode, 0); 354 expect(exitCode, 0);
351 }); 355 });
352 }); 356 });
353 } 357 }
358
354 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE); 359 createTests('old', AnalysisEngine.ANALYSIS_OPTIONS_FILE);
355 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 360 createTests('new', AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
356 361
357 //TODO(pq): fix to be bot-friendly (sdk#25258). 362 //TODO(pq): fix to be bot-friendly (sdk#25258).
358 // group('in temp directory', () { 363 // group('in temp directory', () {
359 // Directory savedCurrentDirectory; 364 // Directory savedCurrentDirectory;
360 // Directory tempDir; 365 // Directory tempDir;
361 // setUp(() { 366 // setUp(() {
362 // // Call base setUp. 367 // // Call base setUp.
363 // _setUp(); 368 // _setUp();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 457
453 /// Try to find a appropriate directory to pass to "--dart-sdk" that will 458 /// Try to find a appropriate directory to pass to "--dart-sdk" that will
454 /// allow summaries to be found. 459 /// allow summaries to be found.
455 String findSdkDirForSummaries() { 460 String findSdkDirForSummaries() {
456 Set<String> triedDirectories = new Set<String>(); 461 Set<String> triedDirectories = new Set<String>();
457 bool isSuitable(String sdkDir) { 462 bool isSuitable(String sdkDir) {
458 triedDirectories.add(sdkDir); 463 triedDirectories.add(sdkDir);
459 return new File(path.join(sdkDir, 'lib', '_internal', 'spec.sum')) 464 return new File(path.join(sdkDir, 'lib', '_internal', 'spec.sum'))
460 .existsSync(); 465 .existsSync();
461 } 466 }
467
462 // Usually the sdk directory is the parent of the parent of the "dart" 468 // Usually the sdk directory is the parent of the parent of the "dart"
463 // executable. 469 // executable.
464 Directory executableParent = new File(Platform.executable).parent; 470 Directory executableParent = new File(Platform.executable).parent;
465 Directory executableGrandparent = executableParent.parent; 471 Directory executableGrandparent = executableParent.parent;
466 if (isSuitable(executableGrandparent.path)) { 472 if (isSuitable(executableGrandparent.path)) {
467 return executableGrandparent.path; 473 return executableGrandparent.path;
468 } 474 }
469 // During buildbot execution, the sdk directory is simply the parent of the 475 // During buildbot execution, the sdk directory is simply the parent of the
470 // "dart" executable. 476 // "dart" executable.
471 if (isSuitable(executableParent.path)) { 477 if (isSuitable(executableParent.path)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 this.options = options; 537 this.options = options;
532 } 538 }
533 } 539 }
534 540
535 class TestSource implements Source { 541 class TestSource implements Source {
536 TestSource(); 542 TestSource();
537 543
538 @override 544 @override
539 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 545 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
540 } 546 }
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/lib/src/error_formatter.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698