Skip to content

Commit 2f7d04f

Browse files
authored
Fix DebugServerTests issue (#146)
1 parent 51ca025 commit 2f7d04f

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

Sources/OpenGraphCxx/DebugServer/og-debug-server.mm

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,18 @@
126126

127127
// log
128128
os_log_info(misc_log(), "debug server graph://%s:%d/?token=%u", address, port, token);
129-
fprintf(stderr, "debug server graph://%s:%d/?token=%u\\n", address, port, token);
129+
fprintf(stderr, "debug server graph://%s:%d/?token=%u\n", address, port, token);
130130
}
131131

132-
// TODO: To be implemented
133-
OG::DebugServer::~DebugServer() {}
132+
OG::DebugServer::~DebugServer() {
133+
shutdown();
134+
for (auto &connection : connections) {
135+
connection.reset();
136+
}
137+
if (connections.data()) {
138+
free(connections.data());
139+
}
140+
}
134141

135142
// TODO: select will fail here
136143
void OG::DebugServer::run(int timeout) {

Sources/OpenGraphCxx/include/OpenGraphCxx/DebugServer/og-debug-server.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
OG_ASSUME_NONNULL_BEGIN
1818

19+
OG_IMPLICIT_BRIDGING_ENABLED
20+
1921
namespace OG {
2022
struct OGDebugServerMessageHeader {
2123
uint32_t token;
@@ -61,6 +63,7 @@ typedef struct OGDebugServerStorage {
6163
OG::DebugServer debugServer;
6264
} OGDebugServerStorage;
6365

66+
OG_IMPLICIT_BRIDGING_DISABLED
6467

6568
OG_ASSUME_NONNULL_END
6669

Tests/OpenGraphCompatibilityTests/Debug/DebugServerTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import CoreFoundation
77
import Foundation
88
import Testing
99

10+
@MainActor
1011
struct DebugServerTests {
1112
@Test
1213
func testMode0() {
1314
#expect(OGDebugServer.start(mode: 0) == nil)
1415
#expect(OGDebugServer.copyURL() == nil)
1516
}
16-
17+
1718
// To make AG start debugServer, we need to pass internal_diagnostics check.
1819
// In debug mode, we can breakpoint on `_ZN2AG11DebugServer5startEj` and
1920
// executable `reg write w0 1` after `internal_diagnostics` call.
@@ -22,11 +23,12 @@ struct DebugServerTests {
2223
.disabled(if: compatibilityTestEnabled, "Skip on AG due to internal_diagnostics check"),
2324
)
2425
func testMode1() throws {
25-
_ = try #require(OGDebugServer.start(mode: 1))
26+
let _ = try #require(OGDebugServer.start(mode: 1))
2627
let url = try #require(OGDebugServer.copyURL())
2728
let urlString = (url as URL).absoluteString
2829
#expect(urlString.hasPrefix("graph://"))
2930
OGDebugServer.run(timeout: 1)
31+
OGDebugServer.stop()
3032
}
3133
}
3234
#endif

Tests/OpenGraphTests/DummyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// DummyTests.swift
33
// OpenGraphTests
44

5-
@testable import OpenGraph
5+
import OpenGraph
66
import Testing
77

88
struct DummyTests {}

0 commit comments

Comments
 (0)