Skip to content

Commit

Permalink
Remove unused options from package:testing (batch 1)
Browse files Browse the repository at this point in the history
Change-Id: I5b214a9661c00cb1817f51bb76c7ad9b2407cc26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346521
Reviewed-by: Johnni Winther <[email protected]>
  • Loading branch information
jensjoha committed Jan 16, 2024
1 parent 9985bad commit 0fabbeb
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 245 deletions.
7 changes: 0 additions & 7 deletions pkg/front_end/test/dartdoctest_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ class Context extends ChainContext {
const DartDocTestStep(),
];

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}

@override
Stream<DartDocTestTestDescription> list(Chain suite) async* {
await for (TestDescription entry in super.list(suite)) {
Expand Down
7 changes: 0 additions & 7 deletions pkg/front_end/test/incremental_bulk_compiler_full.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ class Context extends ChainContext {
const RunTest(),
];

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}

IncrementalKernelGenerator? compiler;
}

Expand Down
7 changes: 0 additions & 7 deletions pkg/front_end/test/lint_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ class Context extends ChainContext {
const LintStep(),
];

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}

@override
Stream<LintTestDescription> list(Chain suite) async* {
late Set<Uri> gitFiles;
Expand Down
7 changes: 0 additions & 7 deletions pkg/front_end/test/outline_extractor_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@ class Context extends ChainContext with MatchContext {
@override
final ExpectationSet expectationSet =
new ExpectationSet.fromJsonList(jsonDecode(EXPECTATIONS));

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}
}

class OutlineExtractorStep
Expand Down
14 changes: 0 additions & 14 deletions pkg/front_end/test/parser_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ class Context extends ChainContext with MatchContext {
@override
final ExpectationSet expectationSet =
new ExpectationSet.fromJsonList(jsonDecode(EXPECTATIONS));

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}
}

class ContextChecksOnly extends Context {
Expand All @@ -150,13 +143,6 @@ class ContextChecksOnly extends Context {
@override
final ExpectationSet expectationSet =
new ExpectationSet.fromJsonList(jsonDecode(EXPECTATIONS));

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}
}

class ParserAstStep extends Step<TestDescription, TestDescription, Context> {
Expand Down
7 changes: 0 additions & 7 deletions pkg/front_end/test/spelling_test_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ abstract class SpellContext extends ChainContext {

SpellContext({required this.interactive, required this.onlyInGit});

// Override special handling of negative tests.
@override
Result processTestResult(
TestDescription description, Result result, bool last) {
return result;
}

List<spell.Dictionaries> get dictionaries;

bool get onlyDenylisted;
Expand Down
55 changes: 2 additions & 53 deletions pkg/testing/lib/src/chain.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import 'error_handling.dart' show withErrorHandling;

import 'log.dart' show Logger, StdoutLogger, splitLines;

import 'multitest.dart' show MultitestTransformer, isError;

import 'expectation.dart' show Expectation, ExpectationGroup, ExpectationSet;

typedef CreateContext = Future<ChainContext> Function(
Expand All @@ -40,10 +38,8 @@ class Chain extends Suite {

final List<RegExp> exclude;

final bool processMultitests;

Chain(String name, String kind, this.source, this.uri, Uri statusFile,
this.pattern, this.exclude, this.processMultitests)
this.pattern, this.exclude)
: super(name, kind, statusFile);

factory Chain.fromJsonMap(Uri base, Map json, String name, String kind) {
Expand All @@ -56,9 +52,7 @@ class Chain extends Suite {
Uri statusFile = base.resolve(json["status"]);
List<RegExp> pattern = [for (final p in json['pattern']) RegExp(p)];
List<RegExp> exclude = [for (final e in json['exclude']) RegExp(e)];
bool processMultitests = json["process-multitests"] ?? false;
return Chain(name, kind, source, uri, statusFile, pattern, exclude,
processMultitests);
return Chain(name, kind, source, uri, statusFile, pattern, exclude);
}

void writeImportOn(StringSink sink) {
Expand Down Expand Up @@ -87,7 +81,6 @@ class Chain extends Suite {
"source": "$source",
"path": "$uri",
"status": "$statusFile",
"process-multitests": processMultitests,
"pattern": [for (final r in pattern) r.pattern],
"exclude": [for (final r in exclude) r.pattern],
};
Expand Down Expand Up @@ -115,9 +108,6 @@ abstract class ChainContext {
TestExpectations expectations = await readTestExpectations(
<String>[suite.statusFile!.toFilePath()], {}, expectationSet);
Stream<TestDescription> stream = list(suite);
if (suite.processMultitests) {
stream = stream.transform(MultitestTransformer());
}
List<TestDescription> descriptions = await stream.toList();
descriptions.sort();
if (shards > 1) {
Expand Down Expand Up @@ -155,7 +145,6 @@ abstract class ChainContext {
}
if (shouldSkip) continue;
final StringBuffer sb = StringBuffer();
final Step? lastStep = steps.isNotEmpty ? steps.last : null;
final Iterator<Step> iterator = steps.iterator;

Result? result;
Expand Down Expand Up @@ -210,8 +199,6 @@ abstract class ChainContext {
}
}
await cleanUp(description, result!);
result =
processTestResult(description, result!, lastStep == lastStepRun);
if (!expectedOutcomes.contains(result!.outcome) &&
!expectedOutcomes.contains(result!.outcome.canonical)) {
result!.addLog("$sb");
Expand Down Expand Up @@ -279,44 +266,6 @@ abstract class ChainContext {
return outcomes;
}

Result processTestResult(
TestDescription description, Result result, bool last) {
if (description is FileBasedTestDescription &&
description.multitestExpectations != null) {
if (isError(description.multitestExpectations!)) {
result =
toNegativeTestResult(result, description.multitestExpectations);
}
} else if (last && description.shortName.endsWith("negative_test")) {
if (result.outcome == Expectation.pass) {
result.addLog("Negative test didn't report an error.\n");
} else if (result.outcome == Expectation.fail) {
result.addLog("Negative test reported an error as expected.\n");
}
result = toNegativeTestResult(result);
}
return result;
}

Result toNegativeTestResult(Result result, [Set<String>? expectations]) {
Expectation outcome = result.outcome;
if (outcome == Expectation.pass) {
if (expectations == null) {
outcome = Expectation.fail;
} else if (expectations.contains("compile-time error")) {
outcome = expectationSet["MissingCompileTimeError"];
} else if (expectations.contains("runtime error") ||
expectations.contains("dynamic type error")) {
outcome = expectationSet["MissingRuntimeError"];
} else {
outcome = Expectation.fail;
}
} else if (outcome == Expectation.fail) {
outcome = Expectation.pass;
}
return result.copyWithOutcome(outcome);
}

Future<void> cleanUp(TestDescription description, Result result) async {}

Future<void> postRun() async {}
Expand Down
143 changes: 0 additions & 143 deletions pkg/testing/lib/src/multitest.dart

This file was deleted.

0 comments on commit 0fabbeb

Please sign in to comment.