Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit acb552d

Browse files
jensjohacommit-bot@chromium.org
authored andcommitted
[CFE] Make incremental tests output expect files for expression compilations
Also add reproduction for issue #41976. Change-Id: I65c55ce0b7ef65e28903b924945e148a1a2285d8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149844 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent e5b2cb0 commit acb552d

17 files changed

+133
-8
lines changed

pkg/front_end/test/incremental_load_from_dill_suite.dart

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ import 'package:kernel/kernel.dart'
6262
Member,
6363
Name,
6464
Procedure,
65-
Supertype;
65+
Supertype,
66+
TreeNode;
6667

6768
import 'package:kernel/target/targets.dart'
6869
show NoneTarget, Target, TargetFlags;
6970

70-
import 'package:kernel/text/ast_to_text.dart' show componentToString;
71+
import 'package:kernel/text/ast_to_text.dart' show Printer, componentToString;
7172

7273
import "package:testing/testing.dart"
7374
show Chain, ChainContext, Result, Step, TestDescription, runMe;
@@ -643,7 +644,7 @@ class NewWorldTest {
643644
}
644645
}
645646

646-
checkExpectFile(data, worldNum, context, actualSerialized);
647+
checkExpectFile(data, worldNum, "", context, actualSerialized);
647648
checkClassHierarchy(compiler, component, data, worldNum, context);
648649

649650
int nonSyntheticLibraries = countNonSyntheticLibraries(component);
@@ -777,13 +778,15 @@ class NewWorldTest {
777778
} else {
778779
compilations = [world["expressionCompilation"]];
779780
}
781+
int expressionCompilationNum = 0;
780782
for (Map compilation in compilations) {
783+
expressionCompilationNum++;
781784
clearPrevErrorsEtc();
782785
bool expectErrors = compilation["errors"] ?? false;
783786
bool expectWarnings = compilation["warnings"] ?? false;
784787
Uri uri = base.resolve(compilation["uri"]);
785788
String expression = compilation["expression"];
786-
await compiler.compileExpression(
789+
Procedure procedure = await compiler.compileExpression(
787790
expression, {}, [], "debugExpr", uri);
788791
if (gotError && !expectErrors) {
789792
throw "Got error(s) on expression compilation: ${formattedErrors}.";
@@ -796,6 +799,12 @@ class NewWorldTest {
796799
} else if (!gotWarning && expectWarnings) {
797800
throw "Didn't get any warnings.";
798801
}
802+
checkExpectFile(
803+
data,
804+
worldNum,
805+
".expression.$expressionCompilationNum",
806+
context,
807+
nodeToString(procedure));
799808
}
800809
}
801810

@@ -876,10 +885,10 @@ class NewWorldTest {
876885
}
877886
}
878887

879-
void checkExpectFile(
880-
TestData data, int worldNum, Context context, String actualSerialized) {
881-
Uri uri = data.loadedFrom
882-
.resolve(data.loadedFrom.pathSegments.last + ".world.$worldNum.expect");
888+
void checkExpectFile(TestData data, int worldNum, String extraUriString,
889+
Context context, String actualSerialized) {
890+
Uri uri = data.loadedFrom.resolve(data.loadedFrom.pathSegments.last +
891+
".world.$worldNum${extraUriString}.expect");
883892
String expected;
884893
File file = new File.fromUri(uri);
885894
if (file.existsSync()) {
@@ -1274,6 +1283,12 @@ void checkNeededDillLibraries(
12741283
}
12751284
}
12761285

1286+
String nodeToString(TreeNode node) {
1287+
StringBuffer buffer = new StringBuffer();
1288+
new Printer(buffer, syntheticNames: new NameSystem()).writeNode(node);
1289+
return '$buffer';
1290+
}
1291+
12771292
String componentToStringSdkFiltered(Component node) {
12781293
Component c = new Component();
12791294
List<Uri> dartUris = new List<Uri>();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:1: Error: Method not found: 'foo'.\nfoo()\n^^^";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(#lib1::NumberParsing|parseInt("1234"));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(#lib1::NumberParsing|parseInt("1234"));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:14: Error: The method 'parseInt' isn't defined for the class 'String'.\nTry correcting the name to the name of an existing method, or defining a method named 'parseInt'.\nprint(\"1234\".parseInt())\n ^^^^^^^^");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:14: Error: The method 'parseInt' isn't defined for the class 'String'.\nTry correcting the name to the name of an existing method, or defining a method named 'parseInt'.\nprint(\"1234\".parseInt())\n ^^^^^^^^");
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(#lib1::NumberParsing|parseInt("1234"));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(#lib1::DuplicateName|fooMe1("1234"));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(#lib1::NumberParsing|parseInt("1234"));
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
2+
return dart.core::print(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:14: Error: The method 'parseInt' isn't defined for the class 'String'.\nTry correcting the name to the name of an existing method, or defining a method named 'parseInt'.\nprint(\"1234\".parseInt())\n ^^^^^^^^");

0 commit comments

Comments
 (0)