[CFE] Include _fe_analyzer_shared in tests

Change-Id: I6d2ab3465a0aa2488cbe7b9a2f1909ab6c615d32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147082
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Jens Johansen 2020-05-11 13:13:21 +00:00 committed by commit-bot@chromium.org
parent 33056425af
commit 64714f2596
11 changed files with 110 additions and 77 deletions

View file

@ -110,8 +110,8 @@ abstract class FactorTypeTestMixin<Type> {
void expect(Type T, Type S, String actualResult, String expectedResult);
void check(Type T, Type S, String expectedStr) {
var result = factor(T, S);
var resultStr = typeString(result);
Type result = factor(T, S);
String resultStr = typeString(result);
expect(T, S, resultStr, expectedStr);
}

View file

@ -1244,7 +1244,7 @@ class FlowModel<Variable, Type> {
if (newVariableInfo == null) return this;
return FlowModel<Variable, Type>._(reachable, newVariableInfo);
return new FlowModel<Variable, Type>._(reachable, newVariableInfo);
}
/// Updates the state to indicate that the given [writtenVariables] are no
@ -2065,8 +2065,8 @@ class VariableModel<Variable, Type> {
bool skipped2 = false;
List<Type> result;
while (index1 < chain1.length && index2 < chain2.length) {
var type1 = chain1[index1];
var type2 = chain2[index2];
Type type1 = chain1[index1];
Type type2 = chain2[index2];
if (typeOperations.isSameType(type1, type2)) {
result ??= <Type>[];
result.add(type1);
@ -2838,7 +2838,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
void whileStatement_end() {
_WhileContext<Variable, Type> context =
_stack.removeLast() as _WhileContext<Variable, Type>;
var afterBody = _current;
FlowModel<Variable, Type> afterBody = _current;
_current = _join(context._conditionInfo.ifFalse, context._breakModel);
_current = _current.joinUnassigned(other: afterBody);
}

View file

@ -12,9 +12,7 @@ import '../scanner/token.dart' show Token;
import 'severity.dart' show Severity;
import '../util/relativize.dart' show isWindows;
import '../util/relativize.dart' as util show relativizeUri;
import '../util/relativize.dart' as util show isWindows, relativizeUri;
part 'codes_generated.dart';
@ -275,7 +273,7 @@ String relativizeUri(Uri uri) {
// (otherwise, we might get an `UNUSED_IMPORT` warning).
//
// 2. We can change `base` argument here if needed.
return uri == null ? null : util.relativizeUri(Uri.base, uri, isWindows);
return uri == null ? null : util.relativizeUri(Uri.base, uri, util.isWindows);
}
typedef SummaryTemplate = Message Function(int, int, num, num, num);

View file

@ -4,8 +4,6 @@
library _fe_analyzer_shared.parser.parser;
import '../messages/codes.dart' show Message, Template;
import '../messages/codes.dart' as codes;
import '../scanner/scanner.dart' show ErrorToken, Token;
@ -1305,7 +1303,7 @@ class Parser {
/// Return the message that should be produced when the formal parameters are
/// missing.
Message missingParameterMessage(MemberKind kind) {
codes.Message missingParameterMessage(MemberKind kind) {
if (kind == MemberKind.FunctionTypeAlias) {
return codes.messageMissingTypedefParameters;
} else if (kind == MemberKind.NonStaticMethod ||
@ -2188,7 +2186,7 @@ class Parser {
/// message based on the given [context]. Return the synthetic identifier that
/// was inserted.
Token insertSyntheticIdentifier(Token token, IdentifierContext context,
{Message message, Token messageOnToken}) {
{codes.Message message, Token messageOnToken}) {
Token next = token.next;
reportRecoverableError(messageOnToken ?? next,
message ?? context.recoveryTemplate.withArguments(next));
@ -2894,7 +2892,7 @@ class Parser {
/// a default error message instead.
Token ensureBlock(
Token token,
Template<Message Function(Token token)> template,
codes.Template<codes.Message Function(Token token)> template,
String missingBlockName) {
Token next = token.next;
if (optional('{', next)) return next;
@ -2956,7 +2954,7 @@ class Parser {
Token ensureColon(Token token) {
Token next = token.next;
if (optional(':', next)) return next;
Message message = codes.templateExpectedButGot.withArguments(':');
codes.Message message = codes.templateExpectedButGot.withArguments(':');
Token newToken = new SyntheticToken(TokenType.COLON, next.charOffset);
return rewriteAndRecover(token, message, newToken);
}
@ -2967,7 +2965,7 @@ class Parser {
Token ensureLiteralString(Token token) {
Token next = token.next;
if (!identical(next.kind, STRING_TOKEN)) {
Message message = codes.templateExpectedString.withArguments(next);
codes.Message message = codes.templateExpectedString.withArguments(next);
Token newToken =
new SyntheticStringToken(TokenType.STRING, '""', next.charOffset, 0);
rewriteAndRecover(token, message, newToken);
@ -2995,7 +2993,7 @@ class Parser {
/// Report an error at the token after [token] that has the given [message].
/// Insert the [newToken] after [token] and return [newToken].
Token rewriteAndRecover(Token token, Message message, Token newToken) {
Token rewriteAndRecover(Token token, codes.Message message, Token newToken) {
reportRecoverableError(token.next, message);
return rewriter.insertToken(token, newToken);
}
@ -4978,7 +4976,7 @@ class Parser {
// This looks like the start of an expression.
// Report an error, insert the comma, and continue parsing.
SyntheticToken comma = new SyntheticToken(TokenType.COMMA, next.offset);
Message message = ifCount > 0
codes.Message message = ifCount > 0
? codes.messageExpectedElseOrComma
: codes.templateExpectedButGot.withArguments(',');
next = rewriteAndRecover(token, message, comma);
@ -5061,7 +5059,7 @@ class Parser {
// TODO(danrubel): Consider better error message
SyntheticToken comma =
new SyntheticToken(TokenType.COMMA, next.offset);
Message message = ifCount > 0
codes.Message message = ifCount > 0
? codes.messageExpectedElseOrComma
: codes.templateExpectedButGot.withArguments(',');
token = rewriteAndRecover(token, message, comma);
@ -6962,14 +6960,14 @@ class Parser {
return token;
}
void reportRecoverableError(Token token, Message message) {
void reportRecoverableError(Token token, codes.Message message) {
// Find a non-synthetic token on which to report the error.
token = findNonZeroLengthToken(token);
listener.handleRecoverableError(message, token, token);
}
void reportRecoverableErrorWithToken(
Token token, Template<_MessageWithArgument<Token>> template) {
Token token, codes.Template<_MessageWithArgument<Token>> template) {
// Find a non-synthetic token on which to report the error.
token = findNonZeroLengthToken(token);
listener.handleRecoverableError(
@ -7358,4 +7356,4 @@ class Parser {
}
// TODO(ahe): Remove when analyzer supports generalized function syntax.
typedef _MessageWithArgument<T> = Message Function(T);
typedef _MessageWithArgument<T> = codes.Message Function(T);

View file

@ -52,7 +52,7 @@ Quote analyzeQuote(String first) {
if (first.startsWith('r"')) return Quote.RawDouble;
if (first.startsWith("'")) return Quote.Single;
if (first.startsWith("r'")) return Quote.RawSingle;
return throw UnsupportedError("'$first' in analyzeQuote");
return throw new UnsupportedError("'$first' in analyzeQuote");
}
// Note: based on [StringValidator.quotingFromString]
@ -102,7 +102,7 @@ int firstQuoteLength(String first, Quote quote) {
case Quote.RawMultiLineDouble:
return lengthOfOptionalWhitespacePrefix(first, 4);
}
return throw UnsupportedError("'$quote' in firstQuoteLength");
return throw new UnsupportedError("'$quote' in firstQuoteLength");
}
int lastQuoteLength(Quote quote) {
@ -119,7 +119,7 @@ int lastQuoteLength(Quote quote) {
case Quote.RawMultiLineDouble:
return 3;
}
return throw UnsupportedError("'$quote' in lastQuoteLength");
return throw new UnsupportedError("'$quote' in lastQuoteLength");
}
String unescapeFirstStringPart(String first, Quote quote, Object location,

View file

@ -224,27 +224,27 @@ class TokenStreamGhostWriter
@override
void _setEndGroup(BeginToken setOn, Token endGroup) {
throw UnimplementedError("_setEndGroup");
throw new UnimplementedError("_setEndGroup");
}
@override
Token _setNext(Token setOn, Token nextToken) {
throw UnimplementedError("_setNext");
throw new UnimplementedError("_setNext");
}
@override
void _setOffset(Token setOn, int offset) {
throw UnimplementedError("_setOffset");
throw new UnimplementedError("_setOffset");
}
@override
void _setPrecedingComments(SimpleToken setOn, CommentToken comment) {
throw UnimplementedError("_setPrecedingComments");
throw new UnimplementedError("_setPrecedingComments");
}
@override
void _setPrevious(Token setOn, Token previous) {
throw UnimplementedError("_setPrevious");
throw new UnimplementedError("_setPrevious");
}
}

View file

@ -13,6 +13,11 @@ main(List<String> args) async {
List<Future> futures = new List<Future>();
futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart",
["--", "spelling_test_src/_fe_analyzer_shared/..."]));
futures.add(run(
"pkg/front_end/test/explicit_creation_test.dart", ["--shared-only"],
filter: false));
futures.add(run("pkg/front_end/test/lint_suite.dart",
["--", "lint/_fe_analyzer_shared/..."]));
await Future.wait(futures);
print("\n-----------------------\n");
print("Done with exitcode $exitCode in ${stopwatch.elapsedMilliseconds} ms");

View file

@ -50,9 +50,9 @@ Uri _computeRepoDir() {
return new Directory(dirPath).uri;
}
Uri frontendLibUri;
Set<Uri> libUris = {};
Future<void> main() async {
Future<void> main(List<String> args) async {
Ticker ticker = new Ticker(isVerbose: false);
api.CompilerOptions compilerOptions = getOptions();
@ -64,12 +64,25 @@ Future<void> main() async {
ProcessedOptions options = new ProcessedOptions(options: compilerOptions);
frontendLibUri = repoDir.resolve("pkg/front_end/lib/");
List<FileSystemEntity> entities =
new Directory.fromUri(frontendLibUri).listSync(recursive: true);
for (FileSystemEntity entity in entities) {
if (entity is File && entity.path.endsWith(".dart")) {
options.inputs.add(entity.uri);
if (args.isEmpty) {
libUris.add(repoDir.resolve("pkg/front_end/lib/"));
libUris.add(repoDir.resolve("pkg/_fe_analyzer_shared/lib/"));
} else {
if (args[0] == "--front-end-only") {
libUris.add(repoDir.resolve("pkg/front_end/lib/"));
} else if (args[0] == "--shared-only") {
libUris.add(repoDir.resolve("pkg/_fe_analyzer_shared/lib/"));
} else {
throw "Unsupported arguments: $args";
}
}
for (Uri uri in libUris) {
List<FileSystemEntity> entities =
new Directory.fromUri(uri).listSync(recursive: true);
for (FileSystemEntity entity in entities) {
if (entity is File && entity.path.endsWith(".dart")) {
options.inputs.add(entity.uri);
}
}
}
@ -238,8 +251,17 @@ class BodyBuilderTest extends BodyBuilder {
doReport = false;
}
}
if (doReport && !uri.toString().startsWith(frontendLibUri.toString())) {
doReport = false;
if (doReport) {
bool match = false;
for (Uri libUri in libUris) {
if (uri.toString().startsWith(libUri.toString())) {
match = true;
break;
}
}
if (!match) {
doReport = false;
}
}
if (doReport) {
addProblem(

View file

@ -2,33 +2,39 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE.md file.
src/api_prototype/compiler_options/Exports: Fail
src/api_prototype/constant_evaluator/Exports: Fail
src/api_prototype/front_end/Exports: Fail
src/api_prototype/incremental_kernel_generator/Exports: Fail
src/api_prototype/language_version/Exports: Fail
src/api_unstable/bazel_worker/ImportsTwice: Fail
src/fasta/fasta_codes/Exports: Fail
src/fasta/incremental_compiler/ImportsTwice: Fail
src/fasta/kernel/body_builder/ImportsTwice: Fail
src/fasta/kernel/constant_evaluator/ExplicitType: Pass
src/fasta/kernel/expression_generator_helper/ImportsTwice: Fail
src/fasta/kernel/kernel_api/Exports: Fail
src/fasta/kernel/kernel_ast_api/Exports: Fail
src/fasta/kernel/kernel_builder/Exports: Fail
src/fasta/kernel/type_algorithms/Exports: Fail
src/fasta/messages/Exports: Fail
src/fasta/parser/Exports: Fail
src/fasta/parser/parser/ImportsTwice: Fail
src/fasta/scanner/abstract_scanner/ImportsTwice: Fail
src/fasta/scanner/Exports: Fail
src/fasta/scanner/recover/ImportsTwice: Fail
src/fasta/scanner/string_scanner/ImportsTwice: Fail
src/fasta/scanner/token/ImportsTwice: Fail
src/fasta/scanner/utf8_bytes_scanner/ImportsTwice: Fail
src/fasta/source/scope_listener/Exports: Fail
src/fasta/source/source_class_builder/ImportsTwice: Fail
src/fasta/source/value_kinds/ImportsTwice: Fail
src/fasta/type_inference/type_constraint_gatherer/ImportsTwice: Fail
src/fasta/type_inference/type_inferrer/ImportsTwice: Fail
src/testing/id_testing_helper/Exports: Fail
_fe_analyzer_shared/lib/src/parser/parser/Exports: Fail
_fe_analyzer_shared/lib/src/scanner/abstract_scanner/ImportsTwice: Fail
_fe_analyzer_shared/lib/src/scanner/scanner/Exports: Fail
_fe_analyzer_shared/lib/src/scanner/string_scanner/ImportsTwice: Fail
_fe_analyzer_shared/lib/src/scanner/token_impl/ImportsTwice: Fail
_fe_analyzer_shared/lib/src/scanner/utf8_bytes_scanner/ImportsTwice: Fail
front_end/lib/src/api_prototype/compiler_options/Exports: Fail
front_end/lib/src/api_prototype/constant_evaluator/Exports: Fail
front_end/lib/src/api_prototype/front_end/Exports: Fail
front_end/lib/src/api_prototype/incremental_kernel_generator/Exports: Fail
front_end/lib/src/api_prototype/language_version/Exports: Fail
front_end/lib/src/api_unstable/bazel_worker/ImportsTwice: Fail
front_end/lib/src/fasta/fasta_codes/Exports: Fail
front_end/lib/src/fasta/incremental_compiler/ImportsTwice: Fail
front_end/lib/src/fasta/kernel/body_builder/ImportsTwice: Fail
front_end/lib/src/fasta/kernel/constant_evaluator/ExplicitType: Pass
front_end/lib/src/fasta/kernel/expression_generator_helper/ImportsTwice: Fail
front_end/lib/src/fasta/kernel/kernel_api/Exports: Fail
front_end/lib/src/fasta/kernel/kernel_ast_api/Exports: Fail
front_end/lib/src/fasta/kernel/kernel_builder/Exports: Fail
front_end/lib/src/fasta/kernel/type_algorithms/Exports: Fail
front_end/lib/src/fasta/messages/Exports: Fail
front_end/lib/src/fasta/parser/Exports: Fail
front_end/lib/src/fasta/parser/parser/ImportsTwice: Fail
front_end/lib/src/fasta/scanner/abstract_scanner/ImportsTwice: Fail
front_end/lib/src/fasta/scanner/Exports: Fail
front_end/lib/src/fasta/scanner/recover/ImportsTwice: Fail
front_end/lib/src/fasta/scanner/string_scanner/ImportsTwice: Fail
front_end/lib/src/fasta/scanner/token/ImportsTwice: Fail
front_end/lib/src/fasta/scanner/utf8_bytes_scanner/ImportsTwice: Fail
front_end/lib/src/fasta/source/scope_listener/Exports: Fail
front_end/lib/src/fasta/source/source_class_builder/ImportsTwice: Fail
front_end/lib/src/fasta/source/value_kinds/ImportsTwice: Fail
front_end/lib/src/fasta/type_inference/type_constraint_gatherer/ImportsTwice: Fail
front_end/lib/src/fasta/type_inference/type_inferrer/ImportsTwice: Fail
front_end/lib/src/testing/id_testing_helper/Exports: Fail

View file

@ -262,13 +262,15 @@
"name": "lint",
"kind": "Chain",
"source": "test/lint_suite.dart",
"path": "lib/",
"path": "../",
"status": "test/lint_test.status",
"pattern": [
".*\\.dart$"
"_fe_analyzer_shared/lib/.*\\.dart$",
"front_end/lib/.*\\.dart$"
],
"exclude": [
"src/fasta/fasta_codes_generated\\.dart$"
"_fe_analyzer_shared/lib/src/messages/codes_generated\\.dart$",
"front_end/lib/src/fasta/fasta_codes_cfe_generated\\.dart$"
]
},
{

View file

@ -13,8 +13,9 @@ String get dartVm => Platform.executable;
main(List<String> args) async {
Stopwatch stopwatch = new Stopwatch()..start();
List<Future> futures = new List<Future>();
futures.add(
run("pkg/front_end/test/explicit_creation_test.dart", [], filter: false));
futures.add(run(
"pkg/front_end/test/explicit_creation_test.dart", ["--front-end-only"],
filter: false));
futures.add(run(
"pkg/front_end/test/fasta/messages_suite.dart",
["-DfastOnly=true"],
@ -22,7 +23,8 @@ main(List<String> args) async {
futures.add(run("pkg/front_end/test/spelling_test_not_src_suite.dart", []));
futures.add(run("pkg/front_end/test/spelling_test_src_suite.dart",
["--", "spelling_test_src/front_end/..."]));
futures.add(run("pkg/front_end/test/lint_suite.dart", []));
futures.add(
run("pkg/front_end/test/lint_suite.dart", ["--", "lint/front_end/..."]));
futures.add(run("pkg/front_end/test/deps_test.dart", [], filter: false));
await Future.wait(futures);
print("\n-----------------------\n");