Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linux tests build #1387

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions unittests/API/CDPAgentTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,6 @@ void CDPAgentTest::expectErrorMessageContaining(
void CDPAgentTest::expectHeapSnapshot(
int messageID,
bool ignoreTrackingNotifications) {
JSLexer::Allocator jsonAlloc;
JSONFactory factory(jsonAlloc);

// Expect chunk notifications until the snapshot object is complete. Fail if
// the object is invalid (e.g. truncated data, excess data, malformed JSON).
// There is no indication of how many segments there will be, so just receive
Expand All @@ -383,7 +380,7 @@ void CDPAgentTest::expectHeapSnapshot(

ASSERT_EQ(method, "HeapProfiler.addHeapSnapshotChunk");
snapshot << jsonScope_.getString(note, {"params", "chunk"});
} while (!parseStrAsJsonObj(snapshot.str(), factory).has_value());
} while (!jsonScope_.tryParseObject(snapshot.str()).has_value());

// Expect the snapshot response after all chunks have been received.
ensureOkResponse(waitForMessage(), messageID);
Expand Down
4 changes: 4 additions & 0 deletions unittests/API/CDPJSONHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ JSONObject *JSONScope::parseObject(const std::string &json) {
return mustParseStrAsJsonObj(json, private_->factory);
}

std::optional<JSONObject *> JSONScope::tryParseObject(const std::string &json) {
return parseStrAsJsonObj(json, private_->factory);
}

std::string JSONScope::getString(
JSONObject *obj,
std::vector<std::string> paths) {
Expand Down
1 change: 1 addition & 0 deletions unittests/API/CDPJSONHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct JSONScope {

JSONValue *parse(const std::string &str);
JSONObject *parseObject(const std::string &str);
std::optional<JSONObject *> tryParseObject(const std::string &json);
std::string getString(JSONObject *obj, std::vector<std::string> paths);
long long getNumber(JSONObject *obj, std::vector<std::string> paths);
bool getBoolean(JSONObject *obj, std::vector<std::string> paths);
Expand Down