CQ. Remove low value test/src/lint/lint_rule_test.dart
These tests only checked that MultiAnalysisRule.reportAtNode / reportAtToken forward the supplied DiagnosticCode into DiagnosticReporter. Change-Id: Iade193431ab28ff4c2ac5f9f77874f1dd3c821cd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511200 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
96c0be6601
commit
c3c2986b82
@@ -1,97 +0,0 @@
|
||||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/analysis_rule/analysis_rule.dart';
|
||||
import 'package:analyzer/dart/ast/token.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/error/listener.dart';
|
||||
import 'package:analyzer/source/file_source.dart';
|
||||
import 'package:analyzer/src/dart/ast/ast.dart';
|
||||
import 'package:analyzer/src/dart/ast/token.dart';
|
||||
import 'package:analyzer_testing/resource_provider_mixin.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import '../../generated/test_support.dart';
|
||||
|
||||
main() {
|
||||
var testSources = _TestSources();
|
||||
|
||||
group('lint rule', () {
|
||||
group('error code reporting', () {
|
||||
test('reportLintForToken (custom)', () {
|
||||
var rule = TestRule();
|
||||
var listener = GatheringDiagnosticListener();
|
||||
var reporter = DiagnosticReporter(listener, testSources.source('mock'));
|
||||
rule.reporter = reporter;
|
||||
|
||||
rule.reportAtToken(
|
||||
SimpleToken(TokenType.SEMICOLON, 0),
|
||||
diagnosticCode: TestRule.customCode,
|
||||
);
|
||||
expect(listener.diagnostics.single.diagnosticCode, TestRule.customCode);
|
||||
});
|
||||
test('reportLintForToken (default)', () {
|
||||
var rule = TestRule();
|
||||
var listener = GatheringDiagnosticListener();
|
||||
var reporter = DiagnosticReporter(listener, testSources.source('mock'));
|
||||
rule.reporter = reporter;
|
||||
|
||||
rule.reportAtToken(
|
||||
SimpleToken(TokenType.SEMICOLON, 0),
|
||||
diagnosticCode: TestRule.code,
|
||||
);
|
||||
expect(listener.diagnostics.single.diagnosticCode, TestRule.code);
|
||||
});
|
||||
test('reportLint (custom)', () {
|
||||
var rule = TestRule();
|
||||
var listener = GatheringDiagnosticListener();
|
||||
var reporter = DiagnosticReporter(listener, testSources.source('mock'));
|
||||
rule.reporter = reporter;
|
||||
|
||||
var node = EmptyStatementImpl(
|
||||
semicolon: SimpleToken(TokenType.SEMICOLON, 0),
|
||||
);
|
||||
rule.reportAtNode(node, diagnosticCode: TestRule.customCode);
|
||||
expect(listener.diagnostics.single.diagnosticCode, TestRule.customCode);
|
||||
});
|
||||
test('reportLint (default)', () {
|
||||
var rule = TestRule();
|
||||
var listener = GatheringDiagnosticListener();
|
||||
var reporter = DiagnosticReporter(listener, testSources.source('mock'));
|
||||
rule.reporter = reporter;
|
||||
|
||||
var node = EmptyStatementImpl(
|
||||
semicolon: SimpleToken(TokenType.SEMICOLON, 0),
|
||||
);
|
||||
rule.reportAtNode(node, diagnosticCode: TestRule.code);
|
||||
expect(listener.diagnostics.single.diagnosticCode, TestRule.code);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
class TestRule extends MultiAnalysisRule {
|
||||
static const LintCode code = LintCode(
|
||||
'test_rule',
|
||||
'Test rule.',
|
||||
correctionMessage: 'Try test rule.',
|
||||
uniqueName: 'LintCode.test_rule',
|
||||
);
|
||||
|
||||
static const LintCode customCode = LintCode(
|
||||
'hash_and_equals',
|
||||
'Override `==` if overriding `hashCode`.',
|
||||
correctionMessage: 'Implement `==`.',
|
||||
uniqueName: 'LintCode.hash_and_equals',
|
||||
);
|
||||
|
||||
TestRule() : super(name: 'test_rule', description: '');
|
||||
|
||||
@override
|
||||
List<DiagnosticCode> get diagnosticCodes => [code, customCode];
|
||||
}
|
||||
|
||||
class _TestSources with ResourceProviderMixin {
|
||||
FileSource source(String name) => FileSource(newFile('/$name.dart', ''));
|
||||
}
|
||||
@@ -5,14 +5,12 @@
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'config_test.dart' as config;
|
||||
import 'lint_rule_test.dart' as lint_rule;
|
||||
import 'linter/test_all.dart' as linter;
|
||||
import 'pub_test.dart' as pub;
|
||||
|
||||
main() {
|
||||
defineReflectiveSuite(() {
|
||||
config.main();
|
||||
lint_rule.main();
|
||||
linter.main();
|
||||
pub.main();
|
||||
}, name: 'lint');
|
||||
|
||||
Reference in New Issue
Block a user