sdk
sdk copied to clipboard
[analyzer_testing] Testing warnings is not valid anymore
After https://github.com/dart-lang/sdk/issues/61793, I can't test warnings correctly. Because of what I mentioned in https://github.com/dart-lang/sdk/issues/61928. We are always using Registry.ruleRegistry.registerLintRule and this internally casts the DiagnosticCode to LintCode.
@mustCallSuper
@override
void setUp() {
// TODO(srawlins): In a major release, change this logic to just ensure that
// `rule` has been set to an analysis rule instance other than
// `_SentinelRule`.
if (rule is _SentinelRule) {
if (analysisRule == 'sentinel') {
throw StateError('The `rule` field must be set in the `setUp` method.');
}
// The developer is using the deprecated `analysisRule` to set the
// rule-under-test.
_analysisRule = analysisRule;
} else {
_analysisRule = rule.name;
Registry.ruleRegistry.registerLintRule(rule); // SEE THIS LINE
}
super.setUp();
newAnalysisOptionsYamlFile(
testPackageRootPath,
analysisOptionsContent(experiments: experiments, rules: [_analysisRule]),
);
}
CC @srawlins @bwilkerson