mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 03:53:26 -08:00
[Server] Smoke-test the dev server end to end (#7865)
* [Server] Smoke-test the dev server end to end Spawns servatrice-dev on an ephemeral port and drives a real RemoteClient through login, room list, room join and game creation, asserting each response and the Event_GameJoined payload. The test is WITH_SERVER-gated, links only the client remote library, and keeps the dev server's throwaway settings inside a temporary directory. * [Server] Publish the dev server's port through a file The smoke test parsed the listening port out of the dev server's stdout, but the server announces it from the main thread while the logger thread writes to the same stream. A log line can land inside the announcement — Arch CI caught it — leaving the digits on the next line, so the test read nothing and failed. Add --port-file, written through QSaveFile once the server listens, and read the port from there instead of from the log. The file is either absent or complete, so logging cannot corrupt the handshake. * [Tests] Tick the event loop while waiting for the port file The port-file wait loop slept with QThread::msleep and never reached the event dispatcher. QProcess fills its read buffers and flips its state only from its socket notifiers, so drainProcessOutput() was a no-op and a child that died before publishing its port went unnoticed until the full 15 s startup timeout, with empty stdout and stderr in the failure message. Pump the event loop instead, as the previous waitForReadyRead loop did.
This commit is contained in:
parent
15d69eb929
commit
ccda73fe5c
3 changed files with 347 additions and 4 deletions
|
|
@ -394,6 +394,25 @@ cockatrice_add_test(
|
|||
LABELS
|
||||
server
|
||||
)
|
||||
if(WITH_SERVER)
|
||||
# The only test that starts a separately scheduled server process. servatrice-dev is built by the
|
||||
# servatrice subdirectory, which exists only when WITH_SERVER is on; the binary path is baked in
|
||||
# because CTest runs the test from its own working directory.
|
||||
cockatrice_add_test(
|
||||
NAME
|
||||
server_dev_smoke_test
|
||||
SOURCES
|
||||
${VERSION_STRING_CPP}
|
||||
server_dev_smoke_test.cpp
|
||||
LIBS
|
||||
libcockatrice_network_client_remote
|
||||
LABELS
|
||||
server
|
||||
DEFINITIONS
|
||||
"SERVATRICE_DEV_BINARY=\"$<TARGET_FILE:servatrice-dev>\""
|
||||
)
|
||||
add_dependencies(server_dev_smoke_test servatrice-dev)
|
||||
endif()
|
||||
cockatrice_add_test(
|
||||
NAME
|
||||
client_login_status_test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue