[cfe] Run fasta testing directly

This avoids the precompile step when running

package:testing/src/run_tests.dart
Change-Id: Idb7569bb865b077440eb750333cfec5b6c48cd91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345280
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This commit is contained in:
Johnni Winther
2024-01-09 12:27:48 +00:00
committed by Commit Queue
parent 1253413b71
commit b905c9a171
17 changed files with 110 additions and 57 deletions
+2 -3
View File
@@ -10,9 +10,8 @@ import '../tool/dart_doctest_impl.dart';
void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
return new Context(suite.name);
Future<Context> createContext(Chain suite, Map<String, String> environment) {
return new Future.value(new Context(suite.name));
}
class Context extends ChainContext {
+5 -2
View File
@@ -12,7 +12,10 @@ import 'package:testing/src/suite.dart' as testing show Suite;
import 'testing/suite.dart';
Future<void> internalMain(CreateContext createContext,
{List<String> arguments = const [], int shards = 1, int shard = 0}) async {
{List<String> arguments = const [],
int shards = 1,
int shard = 0,
String? configurationPath}) async {
Logger logger = const StdoutLogger();
if (arguments.contains("--traceStepTiming")) {
logger = new TracingLogger();
@@ -21,7 +24,7 @@ Future<void> internalMain(CreateContext createContext,
await runMe(
arguments,
createContext,
configurationPath: "../../testing.json",
configurationPath: configurationPath ?? "../../testing.json",
shards: shards,
shard: shard,
logger: logger,
@@ -26,9 +26,8 @@ import 'incremental_utils.dart' as util;
void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
return new Context();
Future<Context> createContext(Chain suite, Map<String, String> environment) {
return new Future.value(new Context());
}
class Context extends ChainContext {
@@ -9,7 +9,6 @@ import 'incremental_bulk_compiler_full.dart' show Context;
void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
return new Context();
Future<Context> createContext(Chain suite, Map<String, String> environment) {
return new Future.value(new Context());
}
+2 -3
View File
@@ -36,13 +36,12 @@ import 'testing_utils.dart' show checkEnvironment, getGitFiles;
void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
Future<Context> createContext(Chain suite, Map<String, String> environment) {
const Set<String> knownEnvironmentKeys = {"onlyInGit"};
checkEnvironment(environment, knownEnvironmentKeys);
bool onlyInGit = environment["onlyInGit"] != "false";
return new Context(onlyInGit: onlyInGit);
return new Future.value(new Context(onlyInGit: onlyInGit));
}
class LintTestDescription extends TestDescription {
@@ -43,8 +43,7 @@ const String EXPECTATIONS = '''
void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
Future<Context> createContext(Chain suite, Map<String, String> environment) {
const Set<String> knownEnvironmentKeys = {
UPDATE_EXPECTATIONS,
};
@@ -52,7 +51,7 @@ Future<Context> createContext(
bool updateExpectations = environment[UPDATE_EXPECTATIONS] == "true";
return new Context(suite.name, updateExpectations);
return new Future.value(new Context(suite.name, updateExpectations));
}
class Context extends ChainContext with MatchContext {
+2 -2
View File
@@ -10,6 +10,6 @@ void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<ChainContext> createContext(
Chain suite, Map<String, String> environment) async {
return new ContextChecksOnly(suite.name);
Chain suite, Map<String, String> environment) {
return new Future.value(new ContextChecksOnly(suite.name));
}
@@ -20,12 +20,11 @@ void main([List<String> arguments = const []]) => runMe(
configurationPath: "../testing.json",
);
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
Future<Context> createContext(Chain suite, Map<String, String> environment) {
const Set<String> knownEnvironmentKeys = {};
checkEnvironment(environment, knownEnvironmentKeys);
return new Context(suite.name);
return new Future.value(new Context(suite.name));
}
class Context extends ChainContext {
+3 -3
View File
@@ -59,8 +59,7 @@ const String EXPECTATIONS = '''
void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<Context> createContext(
Chain suite, Map<String, String> environment) async {
Future<Context> createContext(Chain suite, Map<String, String> environment) {
const Set<String> knownEnvironmentKeys = {
UPDATE_EXPECTATIONS,
"trace",
@@ -72,7 +71,8 @@ Future<Context> createContext(
bool trace = environment["trace"] == "true";
bool annotateLines = environment["annotateLines"] == "true";
return new Context(suite.name, updateExpectations, trace, annotateLines);
return new Future.value(
new Context(suite.name, updateExpectations, trace, annotateLines));
}
ScannerConfiguration scannerConfiguration = new ScannerConfiguration(
+4 -4
View File
@@ -85,7 +85,7 @@ class SpellTest extends Step<TestDescription, TestDescription, SpellContext> {
@override
Future<Result<TestDescription>> run(
TestDescription description, SpellContext context) async {
TestDescription description, SpellContext context) {
File f = new File.fromUri(description.uri);
List<int> rawBytes = f.readAsBytesSync();
@@ -136,7 +136,7 @@ class SpellTest extends Step<TestDescription, TestDescription, SpellContext> {
while (token != null) {
if (token is ErrorToken) {
// For now just accept that.
return pass(description);
return new Future.value(pass(description));
}
if (token.precedingComments != null) {
Token? comment = token.precedingComments;
@@ -187,9 +187,9 @@ class SpellTest extends Step<TestDescription, TestDescription, SpellContext> {
}
if (errors == null) {
return pass(description);
return new Future.value(pass(description));
} else {
return fail(description, errors!.join("\n\n"));
return new Future.value(fail(description, errors!.join("\n\n")));
}
}
}
@@ -14,13 +14,14 @@ void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<SpellContext> createContext(
Chain suite, Map<String, String> environment) async {
Chain suite, Map<String, String> environment) {
const Set<String> knownEnvironmentKeys = {"interactive", "onlyInGit"};
checkEnvironment(environment, knownEnvironmentKeys);
bool interactive = environment["interactive"] == "true";
bool onlyInGit = environment["onlyInGit"] != "false";
return new SpellContextTest(interactive: interactive, onlyInGit: onlyInGit);
return new Future.value(
new SpellContextTest(interactive: interactive, onlyInGit: onlyInGit));
}
class SpellContextTest extends SpellContext {
@@ -14,13 +14,14 @@ void main([List<String> arguments = const []]) =>
runMe(arguments, createContext, configurationPath: "../testing.json");
Future<SpellContext> createContext(
Chain suite, Map<String, String> environment) async {
Chain suite, Map<String, String> environment) {
const Set<String> knownEnvironmentKeys = {"interactive", "onlyInGit"};
checkEnvironment(environment, knownEnvironmentKeys);
bool interactive = environment["interactive"] == "true";
bool onlyInGit = environment["onlyInGit"] != "false";
return new SpellContextSource(interactive: interactive, onlyInGit: onlyInGit);
return new Future.value(
new SpellContextSource(interactive: interactive, onlyInGit: onlyInGit));
}
class SpellContextSource extends SpellContext {
+21 -21
View File
@@ -353,77 +353,77 @@ class Suite {
});
}
const List<Suite> suites = [
const Suite(
const Map<String, Suite> suites = {
'dartdoctest': const Suite(
"dartdoctest",
dartdoctest.createContext,
"../testing.json",
shardCount: 1,
),
const Suite(
'expression': const Suite(
"fasta/expression",
expression.createContext,
"../../testing.json",
shardCount: 1,
),
const Suite(
'outline': const Suite(
"fasta/outline",
outline.createContext,
"../../testing.json",
shardCount: 2,
),
const Suite(
'incremental_dartino': const Suite(
"fasta/incremental_dartino",
incremental_dartino.createContext,
"../../testing.json",
shardCount: 1,
),
const Suite(
'messages': const Suite(
"fasta/messages",
messages.createContext,
"../../testing.json",
shardCount: 1,
requiresGit: true,
),
const Suite(
'strong': const Suite(
"fasta/strong",
strong.createContext,
"../../testing.json",
path: "fasta/strong_suite.dart",
shardCount: 2,
),
const Suite(
'incremental_bulk_compiler_smoke': const Suite(
"incremental_bulk_compiler_smoke",
incremental_bulk_compiler.createContext,
"../testing.json",
shardCount: 1,
),
const Suite(
'incremental': const Suite(
"incremental",
incremental.createContext,
"../testing.json",
shardCount: 2,
),
const Suite(
'lint': const Suite(
"lint",
lint.createContext,
"../testing.json",
shardCount: 1,
requiresGit: true,
),
const Suite(
'parser': const Suite(
"parser",
parser.createContext,
"../testing.json",
shardCount: 1,
),
const Suite(
'parser_equivalence': const Suite(
"parser_equivalence",
parserEquivalence.createContext,
"../testing.json",
shardCount: 1,
),
const Suite(
'parser_all': const Suite(
"parser_all",
parserAll.createContext,
"../testing.json",
@@ -433,47 +433,47 @@ const List<Suite> suites = [
than in test_matrix.json file set */
,
),
const Suite(
'spelling_test_not_src': const Suite(
"spelling_test_not_src",
spelling_not_src.createContext,
"../testing.json",
shardCount: 1,
requiresGit: true,
),
const Suite(
'spelling_test_src': const Suite(
"spelling_test_src",
spelling_src.createContext,
"../testing.json",
shardCount: 1,
requiresGit: true,
),
const Suite(
'modular': const Suite(
"fasta/modular",
modular.createContext,
"../../testing.json",
path: "fasta/modular_suite.dart",
shardCount: 4,
),
const Suite(
'weak': const Suite(
"fasta/weak",
weak.createContext,
"../../testing.json",
path: "fasta/weak_suite.dart",
shardCount: 10,
),
const Suite(
'textual_outline': const Suite(
"fasta/textual_outline",
textual_outline.createContext,
"../../testing.json",
shardCount: 1,
),
const Suite(
'outline_extractor': const Suite(
"outline_extractor",
outline_extractor.createContext,
"../testing.json",
shardCount: 1,
),
];
};
const Duration timeoutDuration = Duration(minutes: 30);
@@ -557,7 +557,7 @@ Future<void> main([List<String> arguments = const <String>[]]) async {
int numberOfFreeWorkers = options.numberOfWorkers;
// Run test suites and record the results and possible failure logs.
int chunkNum = 0;
for (Suite suite in suites) {
for (Suite suite in suites.values) {
if (options.onlyTestsThatRequireGit && !suite.requiresGit) continue;
if (options.skipTestsThatRequireGit && suite.requiresGit) continue;
String prefix = suite.prefix;
+24
View File
@@ -0,0 +1,24 @@
// Copyright (c) 2024, 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 'dart:async' show Future;
import 'package:testing/src/chain.dart' show CreateContext;
import 'package:testing/src/run.dart' show runSuites;
import 'package:testing/src/run_tests.dart' show CommandLine;
import 'package:testing/src/test_root.dart' show TestRoot;
import 'package:testing/testing.dart';
import '../test/unit_test_suites.dart';
Future<Null> main(List<String> arguments) async {
CommandLine cl = CommandLine.parse(arguments);
Map<String, CreateContext> suiteMap = {};
for (MapEntry<String, Suite> entry in suites.entries) {
suiteMap[entry.key] = entry.value.createContext;
}
TestRoot testRoot =
await TestRoot.fromUri(Uri.base.resolve('pkg/front_end/testing.json'));
await runSuites(cl, testRoot, suiteMap);
}
+3 -3
View File
@@ -4,7 +4,6 @@
import 'dart:io';
import "package:testing/src/run_tests.dart" as run_tests;
import 'package:kernel/src/tool/dump.dart' as dump;
import '../test/utils/io_utils.dart' show computeRepoDir;
import '_fasta/abcompile.dart' as abcompile;
@@ -17,6 +16,7 @@ import '_fasta/log_collector.dart' as log_collector;
import '_fasta/outline.dart' as outline;
import '_fasta/parser.dart' as parser;
import '_fasta/scanner.dart' as scanner;
import 'all_suites.dart' as all_suites;
final String repoDir = computeRepoDir();
@@ -90,8 +90,8 @@ Future<void> main(List<String> args) async {
}
break;
case 'testing':
mainFunction = run_tests.main;
script = '${repoDir}/pkg/testing/bin/testing.dart';
mainFunction = all_suites.main;
script = '${repoDir}/all_suites.dart';
scriptArguments.add('--config=${repoDir}/pkg/front_end/testing.json');
break;
case 'generate-messages':
+21
View File
@@ -70,6 +70,27 @@ Future<void> runMe(List<String> arguments, CreateContext f,
}, logger: logger);
}
Future<void> runSuites(
CommandLine cl, TestRoot testRoot, Map<String, CreateContext> suites,
{int shards = 1,
int shard = 0,
Logger logger = const StdoutLogger()}) async {
return withErrorHandling(() async {
if (cl.verbose) enableVerboseOutput();
Set<String> selectedSuites = cl.selectedSuites;
for (MapEntry<String, CreateContext> entry in suites.entries) {
String suiteName = entry.key;
if (selectedSuites.contains(entry.key)) {
Chain suite = testRoot.getChain(suiteName)!;
CreateContext createContext = entry.value;
ChainContext context = await createContext(suite, {...cl.environment});
await context.run(suite, Set<String>.from(cl.selectors),
shards: shards, shard: shard, logger: logger);
}
}
}, logger: logger);
}
/// This is called from a `_test.dart` file, and helps integration in other
/// test runner frameworks.
///
+9
View File
@@ -55,6 +55,15 @@ class TestRoot {
List<RegExp> get excludedFromAnalysis => analyze.exclude;
Chain? getChain(String name) {
for (Suite suite in suites) {
if (suite is Chain && suite.name == name) {
return suite;
}
}
return null;
}
Iterable<Dart> get dartSuites {
return List<Dart>.from(suites.whereType<Dart>());
}