Skip to content

Commit

Permalink
Make column match fuzzy
Browse files Browse the repository at this point in the history
Summary:
We are currently very strict about breakpoint location matching. This
diff allows some fuzz in the column, but not in the line.

Changelog: [Internal] Setting Hermes breakpoints no longer requires exact column match

Reviewed By: avp

Differential Revision: D21343198

fbshipit-source-id: a59786a9d63f9fe1ed576835ed660ba3343affe1
  • Loading branch information
willholen authored and facebook-github-bot committed May 5, 2020
1 parent 1740233 commit 4459c08
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions ReactCommon/hermes/inspector/chrome/tests/ConnectionTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,46 @@ TEST(ConnectionTests, testSetBreakpointById) {
expectNotification<m::debugger::ResumedNotification>(conn);
}

TEST(ConnectionTests, testSetBreakpointByIdWithColumnInIndenting) {
TestContext context;
AsyncHermesRuntime &asyncRuntime = context.runtime();
SyncConnection &conn = context.conn();
int msgId = 1;

asyncRuntime.executeScriptAsync(R"(
debugger; // line 1
Math.random(); // 2
)");

send<m::debugger::EnableRequest>(conn, ++msgId);
expectExecutionContextCreated(conn);
auto script = expectNotification<m::debugger::ScriptParsedNotification>(conn);

expectPaused(conn, "other", {{"global", 1, 1}});

m::debugger::SetBreakpointRequest req;
req.id = ++msgId;
req.location.scriptId = script.scriptId;
req.location.lineNumber = 2;
// Specify a column location *before* rather than *on* the actual location
req.location.columnNumber = 0;

conn.send(req.toJson());
auto resp = expectResponse<m::debugger::SetBreakpointResponse>(conn, req.id);
EXPECT_EQ(resp.actualLocation.scriptId, script.scriptId);
EXPECT_EQ(resp.actualLocation.lineNumber, 2);
// Check that we resolved the column to the first available location
EXPECT_EQ(resp.actualLocation.columnNumber.value(), 4);

send<m::debugger::ResumeRequest>(conn, ++msgId);
expectNotification<m::debugger::ResumedNotification>(conn);

expectPaused(conn, "other", {{"global", 2, 1}});

send<m::debugger::ResumeRequest>(conn, ++msgId);
expectNotification<m::debugger::ResumedNotification>(conn);
}

TEST(ConnectionTests, testSetLazyBreakpoint) {
TestContext context;
AsyncHermesRuntime &asyncRuntime = context.runtime();
Expand Down

0 comments on commit 4459c08

Please sign in to comment.