Skip to content

Commit

Permalink
[CFE] Better error and reproduction on compile and lint crash
Browse files Browse the repository at this point in the history
Change-Id: I7555d9d2c7244325d4eacba4cc8780c2a98a4fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
  • Loading branch information
jensjoha authored and Commit Queue committed Sep 18, 2024
1 parent bdddf5e commit 44e79f5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 35 additions & 1 deletion pkg/front_end/presubmit_helper_spawn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,43 @@ Future<void> main(List<String> args, [SendPort? sendPort]) async {
includedFiles: work.includedFiles,
includedDirectoryUris: work.includedDirectoryUris,
repoDir: work.repoDir));
} catch (e) {
} catch (e, st) {
// This will make it send false.
compileAndLintErrorsFound = -1;

StringBuffer sb = new StringBuffer();
sb.writeln("void main() {");
sb.writeln(" runCompileAndLintTest(includedFiles: {");
String comma = "";
for (Uri uri in work.includedFiles) {
sb.writeln(" ${comma}Uri.parse('$uri')");
comma = ", ";
}
sb.writeln(" }, includedDirectoryUris: {");
comma = "";
for (Uri uri in work.includedDirectoryUris) {
sb.writeln(" ${comma}Uri.parse('$uri')");
comma = ", ";
}
sb.writeln(" }, repoDir: Uri.parse('${work.repoDir}'));");
sb.writeln("}");

print("""
WARNING: '${work.name}' crashed:
============
${e.toString().trim()}
============
$st
============
To reproduce open up compile_and_lint_impl.dart and insert
$sb
Then run that file through your debugger or similar.
""");
print("Got error for ${work.name}: $e");
}
print("Sending ok = ${compileAndLintErrorsFound == 0} "
"for ${work.name} after ${stopwatch.elapsed}");
Expand Down
1 change: 1 addition & 0 deletions pkg/front_end/test/compile_and_lint_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Set<Uri> _replaceParts(Uri packageConfigUri, Set<Uri> files) {
in Directory.fromUri(packageEntry.key.packageUriRoot)
.listSync(recursive: true)) {
if (f is! File) continue;
if (!f.path.endsWith(".dart")) continue;
if (helpers[f.uri] == null) {
FileInfoHelper fileInfo = indexUriHelper(f.uri);
for (String name in fileInfo.libraryNames) {
Expand Down

0 comments on commit 44e79f5

Please sign in to comment.