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

Side by Side Diff: test/rule_test.dart

Issue 2417463002: Move MockSdk into tests. (Closed)
Patch Set: Created 4 years, 2 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 | « test/mock_sdk.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 linter.test.rule; 5 library linter.test.rule;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'mock_sdk.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 11 import 'package:analyzer/src/generated/error.dart';
11 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
12 import 'package:linter/src/ast.dart'; 13 import 'package:linter/src/ast.dart';
13 import 'package:linter/src/formatter.dart'; 14 import 'package:linter/src/formatter.dart';
14 import 'package:linter/src/io.dart'; 15 import 'package:linter/src/io.dart';
15 import 'package:linter/src/linter.dart'; 16 import 'package:linter/src/linter.dart';
16 import 'package:linter/src/rules.dart'; 17 import 'package:linter/src/rules.dart';
17 import 'package:linter/src/rules/camel_case_types.dart'; 18 import 'package:linter/src/rules/camel_case_types.dart';
18 import 'package:linter/src/rules/implementation_imports.dart'; 19 import 'package:linter/src/rules/implementation_imports.dart';
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 ++lineNumber; 403 ++lineNumber;
403 } 404 }
404 405
405 LintRule rule = ruleRegistry[ruleName]; 406 LintRule rule = ruleRegistry[ruleName];
406 if (rule == null) { 407 if (rule == null) {
407 print('WARNING: Test skipped -- rule `$ruleName` is not registered.'); 408 print('WARNING: Test skipped -- rule `$ruleName` is not registered.');
408 return; 409 return;
409 } 410 }
410 411
411 LinterOptions options = new LinterOptions([rule]) 412 LinterOptions options = new LinterOptions([rule])
412 ..useMockSdk = true 413 ..mockSdk = new MockSdk()
413 ..packageRootPath = '.'; 414 ..packageRootPath = '.';
414 415
415 DartLinter driver = new DartLinter(options); 416 DartLinter driver = new DartLinter(options);
416 417
417 Iterable<AnalysisErrorInfo> lints = driver.lintFiles([file]); 418 Iterable<AnalysisErrorInfo> lints = driver.lintFiles([file]);
418 419
419 List<Annotation> actual = []; 420 List<Annotation> actual = [];
420 lints.forEach((AnalysisErrorInfo info) { 421 lints.forEach((AnalysisErrorInfo info) {
421 info.errors.forEach((AnalysisError error) { 422 info.errors.forEach((AnalysisError error) {
422 if (error.errorCode.type == ErrorType.LINT) { 423 if (error.errorCode.type == ErrorType.LINT) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 508
508 class NoFilter implements LintFilter { 509 class NoFilter implements LintFilter {
509 @override 510 @override
510 bool filter(AnalysisError lint) => false; 511 bool filter(AnalysisError lint) => false;
511 } 512 }
512 513
513 class ResultReporter extends DetailedReporter { 514 class ResultReporter extends DetailedReporter {
514 ResultReporter(Iterable<AnalysisErrorInfo> errors) 515 ResultReporter(Iterable<AnalysisErrorInfo> errors)
515 : super(errors, new NoFilter(), stdout); 516 : super(errors, new NoFilter(), stdout);
516 } 517 }
OLDNEW
« no previous file with comments | « test/mock_sdk.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698