30ae8e3d14
This CL is a warm-up to a follow-up change that will make running the CFE trybot faster. This CL: * Rename tests that require git (because when working with filesets and shards in the test system, the "checkout" is not a git checkout and git commands thus doesn't work properly. * Filters the front-end unit test setup on the front-end bot the way it was probably intended, i.e. run tests in pkg/kernel, pkg/front_end and pkg/fasta (actually, the last one doesn't exist, but still) instead of just in folders inside the "suite" 'pkg' that somewhere in the path has something called 'kernel', 'front_end' or 'fasta'. * Split unit_test_suites.dart into a "forwarding shell" and a impl. In a follow-up CL the impl will be converted to nnbd to allow for using 'required' on named parameters, but if the entry point was nnbd it would run in sound nnbd mode and nothing would compile because all imports are not nnbd. Overall this CL should change very little, mostly just run a few less tests, i.e. for instance skip tests that live inside a folder called 'fasta' somewhere inside the analyzer directory path. Change-Id: I3226c7261cff8b68cc287cff07dc1715dfd85159 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181381 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
151 lines
3.8 KiB
Dart
151 lines
3.8 KiB
Dart
// Copyright (c) 2016, 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
/// Tests the tool `pkg/front_end/tool/fasta`.
|
|
|
|
import "dart:io";
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
import "package:front_end/src/fasta/fasta_codes.dart"
|
|
show messageFastaUsageShort;
|
|
|
|
const String toolPath = "pkg/front_end/tool/fasta";
|
|
|
|
const List<String> subtools = const <String>[
|
|
"abcompile",
|
|
"compile",
|
|
"compile-platform",
|
|
"log",
|
|
"logd",
|
|
"outline",
|
|
"parser",
|
|
"scanner",
|
|
"dump-ir",
|
|
"testing",
|
|
"generate-messages",
|
|
];
|
|
|
|
/// An unsafe tool is a tool that shouldn't be run during this test. Please
|
|
/// document below why the tool shouldn't be run, and how it is tested.
|
|
const List<String> unsafeTools = const <String>[
|
|
// This modifies the source code in the repository, and that could cause
|
|
// other tests to fail. This tool is tested as we invoke it everytime we edit
|
|
// messages.yaml.
|
|
"generate-messages",
|
|
|
|
// This is a daemon process that never terminates. It's not currently tested
|
|
// directly.
|
|
"logd",
|
|
|
|
// This would eventually run this test again, recursively, and never
|
|
// finish. As this tool is part of the workflow for testing Fasta, we assume
|
|
// is exercised sufficiently.
|
|
"testing",
|
|
];
|
|
|
|
main() {
|
|
if (!Platform.isMacOS && !Platform.isLinux) {
|
|
// The tool is a shell script and only works on Mac and Linux.
|
|
return;
|
|
}
|
|
Set<String> testedSubtools = new Set<String>.from(subtools)
|
|
.difference(new Set<String>.from(unsafeTools));
|
|
String usage = messageFastaUsageShort.message;
|
|
Map expectations = {
|
|
"abcompile": {
|
|
"exitCode": 1,
|
|
"stdout": """[]
|
|
Expected -DbRoot=/absolute/path/to/other/sdk/repo
|
|
""",
|
|
"stderr": "",
|
|
},
|
|
"compile": {
|
|
"exitCode": 1,
|
|
"stdout": """
|
|
Usage: compile [options] dartfile
|
|
|
|
Compiles a Dart program to the Dill/Kernel IR format.
|
|
|
|
$usage
|
|
Error: No Dart file specified.
|
|
""",
|
|
"stderr": "",
|
|
},
|
|
"compile-platform": {
|
|
"exitCode": 1,
|
|
"stdout": """
|
|
Usage: compile_platform [options] dart-library-uri libraries.json vm_outline_strong.dill platform.dill outline.dill
|
|
|
|
Compiles Dart SDK platform to the Dill/Kernel IR format.
|
|
|
|
$usage
|
|
Error: Expected five arguments.
|
|
""",
|
|
"stderr": "",
|
|
},
|
|
"log": {
|
|
"exitCode": 0,
|
|
"stdout": "",
|
|
"stderr": "",
|
|
},
|
|
"outline": {
|
|
"exitCode": 1,
|
|
"stdout": """
|
|
Usage: outline [options] dartfile
|
|
|
|
Creates an outline of a Dart program in the Dill/Kernel IR format.
|
|
|
|
$usage
|
|
Error: No Dart file specified.
|
|
""",
|
|
"stderr": "",
|
|
},
|
|
"parser": {
|
|
"exitCode": 0,
|
|
"stdout": "",
|
|
"stderr": "",
|
|
},
|
|
"scanner": {
|
|
"exitCode": 0,
|
|
"stderr": "",
|
|
},
|
|
"dump-ir": {
|
|
"exitCode": 2,
|
|
"stdout": "",
|
|
"stderr": "Usage: dump-ir dillfile [output]\n",
|
|
},
|
|
};
|
|
|
|
for (String subtool in testedSubtools) {
|
|
print("Testing $subtool");
|
|
ProcessResult result = Process.runSync(
|
|
"/bin/bash", <String>[toolPath, subtool],
|
|
environment: <String, String>{"DART_VM": Platform.resolvedExecutable});
|
|
Map expectation = expectations.remove(subtool);
|
|
String combinedOutput = """
|
|
stdout:
|
|
${result.stdout}
|
|
stderr:
|
|
${result.stderr}
|
|
""";
|
|
Expect.equals(expectation["exitCode"], result.exitCode, combinedOutput);
|
|
|
|
switch (subtool) {
|
|
case "scanner":
|
|
Expect.isTrue(result.stdout.startsWith("Reading files took: "));
|
|
Expect.stringEquals(expectation["stderr"], result.stderr);
|
|
break;
|
|
|
|
default:
|
|
Expect.stringEquals(expectation["stdout"], result.stdout);
|
|
Expect.stringEquals(expectation["stderr"], result.stderr);
|
|
break;
|
|
}
|
|
}
|
|
Expect.isTrue(expectations.isEmpty);
|
|
}
|