Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1375)

Unified Diff: runtime/vm/source_report_test.cc

Issue 2038203002: Fix various nefarious problems with the script table used in source reports. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/source_report.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/source_report_test.cc
diff --git a/runtime/vm/source_report_test.cc b/runtime/vm/source_report_test.cc
index ad00dec7640c88411203448837e96266bbf48570..2d3f5bcb5fae75706e50c1300597bde097ac5373 100644
--- a/runtime/vm/source_report_test.cc
+++ b/runtime/vm/source_report_test.cc
@@ -425,6 +425,49 @@ TEST_CASE(SourceReport_Coverage_AllFunctions) {
}
+TEST_CASE(SourceReport_Coverage_AllFunctions_ForceCompile) {
+ const char* kScript =
+ "helper0() {}\n"
+ "helper1() {}\n"
+ "main() {\n"
+ " if (true) {\n"
+ " helper0();\n"
+ " } else {\n"
+ " helper1();\n"
+ " }\n"
+ "}";
+
+ Library& lib = Library::Handle();
+ lib ^= ExecuteScript(kScript);
+ ASSERT(!lib.IsNull());
+
+ SourceReport report(SourceReport::kCoverage, SourceReport::kForceCompile);
+ JSONStream js;
+
+ // We generate a report with all functions in the VM.
+ Script& null_script = Script::Handle();
+ {
+ TransitionNativeToVM transition(Thread::Current());
+ report.PrintJSON(&js, null_script);
+ }
+ const char* result = js.ToCString();
+
+ // Sanity check the header.
+ EXPECT_SUBSTRING("{\"type\":\"SourceReport\",\"ranges\":[", result);
+
+ // Make sure that the main function was found.
+ EXPECT_SUBSTRING(
+ "\"startPos\":12,\"endPos\":39,\"compiled\":true,"
+ "\"coverage\":{\"hits\":[23],\"misses\":[32]}",
+ result);
+
+ // More than one script is referenced in the report.
+ EXPECT_SUBSTRING("\"scriptIndex\":0", result);
+ EXPECT_SUBSTRING("\"scriptIndex\":1", result);
+ EXPECT_SUBSTRING("\"scriptIndex\":2", result);
+}
+
+
TEST_CASE(SourceReport_CallSites_SimpleCall) {
char buffer[1024];
const char* kScript =
« no previous file with comments | « runtime/vm/source_report.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698