Skip to content

Commit 81f3be1

Browse files
motiz88facebook-github-bot
authored andcommitted
Fix test build failures and ASAN violation (#52812)
Summary: Pull Request resolved: #52812 1. Fix forward from D76486572 (cc christophpurrer) - `#include <format>` is, for whatever reason, not available in fbcode (?) but `fmt` is an adequate, working substitute that is also used elsewhere RN (specifically in ReactCxxPlatform). Also removed the `folly/Format` include that had erroneously been left in, and the `fbobjc_ios_propagated_target_sdk_version` setting that was added purely to support `<format>`. 2. Fixes a dangling reference to an immediately-destroyed `MockHostTargetDelegate` in `ReactInstanceIntegrationTest`, caught by ASAN. 3. Adds a missing `#include <stdexcept>` to `Utf8.h`. Changelog: [Internal] Reviewed By: huntie Differential Revision: D78756286 fbshipit-source-id: d9428c54fc512f5ab33d31300aba9bf5c3e619b2
1 parent d90c5c0 commit 81f3be1

File tree

5 files changed

+48
-49
lines changed

5 files changed

+48
-49
lines changed

packages/react-native/ReactCommon/jsinspector-modern/Utf8.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#pragma once
99

10+
#include <stdexcept>
1011
#include <vector>
1112

1213
namespace facebook::react::jsinspector_modern {

packages/react-native/ReactCommon/jsinspector-modern/tests/InspectorPackagerConnectionTest.cpp

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#include <folly/Format.h>
8+
#include <fmt/format.h>
99
#include <folly/dynamic.h>
1010
#include <folly/executors/ManualExecutor.h>
1111
#include <folly/executors/QueuedImmediateExecutor.h>
@@ -16,7 +16,6 @@
1616
#include <jsinspector-modern/InspectorInterfaces.h>
1717
#include <jsinspector-modern/InspectorPackagerConnection.h>
1818

19-
#include <format>
2019
#include <memory>
2120

2221
#include "FollyDynamicMatchers.h"
@@ -282,7 +281,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEvents) {
282281
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
283282

284283
// Connect to the page.
285-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
284+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
286285
R"({{
287286
"event": "connect",
288287
"payload": {{
@@ -322,7 +321,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEvents) {
322321
AtJsonPtr("/params", ElementsAre("arg1", "arg2"))))))
323322
.RetiresOnSaturation();
324323

325-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
324+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
326325
R"({{
327326
"event": "wrappedEvent",
328327
"payload": {{
@@ -374,7 +373,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEventsToMultiplePages) {
374373

375374
for (int i = 0; i < kNumPages; ++i) {
376375
// Connect to the i-th page.
377-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
376+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
378377
R"({{
379378
"event": "connect",
380379
"payload": {{
@@ -416,7 +415,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendReceiveEventsToMultiplePages) {
416415
*localConnections_[i],
417416
sendMessage(JsonParsed(AtJsonPtr("/method", Eq(method)))))
418417
.RetiresOnSaturation();
419-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
418+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
420419
R"({{
421420
"event": "wrappedEvent",
422421
"payload": {{
@@ -446,7 +445,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendEventToAllConnections) {
446445
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
447446

448447
// Connect to the page.
449-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
448+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
450449
R"({{
451450
"event": "connect",
452451
"payload": {{
@@ -487,7 +486,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenDisconnect) {
487486
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
488487

489488
// Connect to the page.
490-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
489+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
491490
R"({{
492491
"event": "connect",
493492
"payload": {{
@@ -499,7 +498,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenDisconnect) {
499498

500499
// Disconnect from the page.
501500
EXPECT_CALL(*localConnections_[0], disconnect()).RetiresOnSaturation();
502-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
501+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
503502
R"({{
504503
"event": "disconnect",
505504
"payload": {{
@@ -522,7 +521,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenCloseSocket) {
522521
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
523522

524523
// Connect to the page.
525-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
524+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
526525
R"({{
527526
"event": "connect",
528527
"payload": {{
@@ -550,7 +549,7 @@ TEST_F(InspectorPackagerConnectionTest, TestConnectThenSocketFailure) {
550549
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
551550

552551
// Connect to the page.
553-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
552+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
554553
R"({{
555554
"event": "connect",
556555
"payload": {{
@@ -580,7 +579,7 @@ TEST_F(
580579
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
581580

582581
// Connect to the page.
583-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
582+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
584583
R"({{
585584
"event": "connect",
586585
"payload": {{
@@ -626,7 +625,7 @@ TEST_F(
626625
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
627626

628627
// Connect to the page.
629-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
628+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
630629
R"({{
631630
"event": "connect",
632631
"payload": {{
@@ -638,7 +637,7 @@ TEST_F(
638637

639638
// Try connecting to the same page again. This results in a disconnection.
640639
EXPECT_CALL(*localConnections_[0], disconnect()).RetiresOnSaturation();
641-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
640+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
642641
R"({{
643642
"event": "connect",
644643
"payload": {{
@@ -661,7 +660,7 @@ TEST_F(InspectorPackagerConnectionTest, TestMultipleDisconnect) {
661660
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
662661

663662
// Connect to the page.
664-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
663+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
665664
R"({{
666665
"event": "connect",
667666
"payload": {{
@@ -673,7 +672,7 @@ TEST_F(InspectorPackagerConnectionTest, TestMultipleDisconnect) {
673672

674673
// Disconnect from the page.
675674
EXPECT_CALL(*localConnections_[0], disconnect()).RetiresOnSaturation();
676-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
675+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
677676
R"({{
678677
"event": "disconnect",
679678
"payload": {{
@@ -684,7 +683,7 @@ TEST_F(InspectorPackagerConnectionTest, TestMultipleDisconnect) {
684683
EXPECT_FALSE(localConnections_[0]);
685684

686685
// Disconnect again. This is a noop.
687-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
686+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
688687
R"({{
689688
"event": "disconnect",
690689
"payload": {{
@@ -707,7 +706,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDisconnectThenSendEvent) {
707706
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
708707

709708
// Connect to the page.
710-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
709+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
711710
R"({{
712711
"event": "connect",
713712
"payload": {{
@@ -719,7 +718,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDisconnectThenSendEvent) {
719718

720719
// Disconnect from the page.
721720
EXPECT_CALL(*localConnections_[0], disconnect()).RetiresOnSaturation();
722-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
721+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
723722
R"({{
724723
"event": "disconnect",
725724
"payload": {{
@@ -731,7 +730,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDisconnectThenSendEvent) {
731730

732731
// Send an event from the frontend (remote) to the backend (local). This
733732
// is a noop.
734-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
733+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
735734
R"({{
736735
"event": "wrappedEvent",
737736
"payload": {{
@@ -755,7 +754,7 @@ TEST_F(InspectorPackagerConnectionTest, TestSendEventToUnknownPage) {
755754

756755
// Send an event from the frontend (remote) to the backend (local). This
757756
// is a noop (except for logging).
758-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
757+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
759758
R"({{
760759
"event": "wrappedEvent",
761760
"payload": {{
@@ -922,7 +921,7 @@ TEST_F(
922921
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
923922

924923
// Connect to the page.
925-
retainedWebSocketDelegate->didReceiveMessage(std::format(
924+
retainedWebSocketDelegate->didReceiveMessage(fmt::format(
926925
R"({{
927926
"event": "connect",
928927
"payload": {{
@@ -942,7 +941,7 @@ TEST_F(
942941
AtJsonPtr("/params", ElementsAre("arg1", "arg2"))))))
943942
.RetiresOnSaturation();
944943

945-
retainedWebSocketDelegate->didReceiveMessage(std::format(
944+
retainedWebSocketDelegate->didReceiveMessage(fmt::format(
946945
R"({{
947946
"event": "wrappedEvent",
948947
"payload": {{
@@ -976,7 +975,7 @@ TEST_F(InspectorPackagerConnectionTest, TestDestroyConnectionOnPageRemoved) {
976975
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
977976

978977
// Connect to the page.
979-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
978+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
980979
R"({{
981980
"event": "connect",
982981
"payload": {{
@@ -1006,7 +1005,7 @@ TEST_F(
10061005
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
10071006

10081007
// Connect to the page.
1009-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1008+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
10101009
R"({{
10111010
"event": "connect",
10121011
"payload": {{
@@ -1046,7 +1045,7 @@ TEST_F(
10461045
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
10471046

10481047
// Connect to the page.
1049-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1048+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
10501049
R"({{
10511050
"event": "connect",
10521051
"payload": {{
@@ -1065,7 +1064,7 @@ TEST_F(
10651064

10661065
// Disconnect from the page.
10671066
EXPECT_CALL(*localConnections_[0], disconnect()).RetiresOnSaturation();
1068-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1067+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
10691068
R"({{
10701069
"event": "disconnect",
10711070
"payload": {{
@@ -1076,7 +1075,7 @@ TEST_F(
10761075
EXPECT_FALSE(localConnections_[0]);
10771076

10781077
// Connect to the same page again.
1079-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1078+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
10801079
R"({{
10811080
"event": "connect",
10821081
"payload": {{
@@ -1128,7 +1127,7 @@ TEST_F(
11281127
.lazily_make_unique<std::unique_ptr<IRemoteConnection>>());
11291128

11301129
// Connect to the page.
1131-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1130+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
11321131
R"({{
11331132
"event": "connect",
11341133
"payload": {{
@@ -1152,7 +1151,7 @@ TEST_F(
11521151

11531152
// Disconnect from the page.
11541153
EXPECT_CALL(*localConnections_[0], disconnect()).RetiresOnSaturation();
1155-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1154+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
11561155
R"({{
11571156
"event": "disconnect",
11581157
"payload": {{
@@ -1163,7 +1162,7 @@ TEST_F(
11631162
EXPECT_FALSE(localConnections_[0]);
11641163

11651164
// Connect to the same page again.
1166-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1165+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
11671166
R"({{
11681167
"event": "connect",
11691168
"payload": {{
@@ -1257,7 +1256,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
12571256
AtJsonPtr("/payload/pageId", Eq(std::to_string(pageId)))))))
12581257
.RetiresOnSaturation();
12591258

1260-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1259+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
12611260
R"({{
12621261
"event": "connect",
12631262
"payload": {{
@@ -1266,7 +1265,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
12661265
}})",
12671266
toJson(std::to_string(pageId))));
12681267

1269-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1268+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
12701269
R"({{
12711270
"event": "wrappedEvent",
12721271
"payload": {{
@@ -1292,7 +1291,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
12921291
AtJsonPtr("/payload/pageId", Eq(std::to_string(pageId)))))))
12931292
.RetiresOnSaturation();
12941293

1295-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1294+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
12961295
R"({{
12971296
"event": "connect",
12981297
"payload": {{
@@ -1301,7 +1300,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
13011300
}})",
13021301
toJson(std::to_string(pageId))));
13031302

1304-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1303+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
13051304
R"({{
13061305
"event": "wrappedEvent",
13071306
"payload": {{
@@ -1320,7 +1319,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
13201319
// page.
13211320
mockNextConnectionBehavior = Accept;
13221321

1323-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1322+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
13241323
R"({{
13251324
"event": "connect",
13261325
"payload": {{
@@ -1337,7 +1336,7 @@ TEST_F(InspectorPackagerConnectionTest, TestRejectedPageConnection) {
13371336
AtJsonPtr("/params", ElementsAre("arg1", "arg2"))))))
13381337
.RetiresOnSaturation();
13391338

1340-
webSockets_[0]->getDelegate().didReceiveMessage(std::format(
1339+
webSockets_[0]->getDelegate().didReceiveMessage(fmt::format(
13411340
R"({{
13421341
"event": "wrappedEvent",
13431342
"payload": {{

0 commit comments

Comments
 (0)