diff options
| author | Stefan Boberg <[email protected]> | 2026-03-02 09:37:14 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-03-02 09:37:14 +0100 |
| commit | d604351cb5dc3032a7cb8c84d6ad5f1480325e5c (patch) | |
| tree | ecf3e5a0de3ae58e2f81988b72ae520a347d4433 /src/zenhttp | |
| parent | added `--verbose` option to zenserver-test and `xmake test` (#798) (diff) | |
| download | zen-d604351cb5dc3032a7cb8c84d6ad5f1480325e5c.tar.xz zen-d604351cb5dc3032a7cb8c84d6ad5f1480325e5c.zip | |
Add test suites (#799)
Makes all test cases part of a test suite. Test suites are named after the module and the name of the file containing the implementation of the test.
* This allows for better and more predictable filtering of which test cases to run which should also be able to reduce the time CI spends in tests since it can filter on the tests for that particular module.
Also improves `xmake test` behaviour:
* instead of an explicit list of projects just enumerate the test projects which are available based on build system state
* also introduces logic to avoid running `xmake config` unnecessarily which would invalidate the existing build and do lots of unnecessary work since dependencies were invalidated by the updated config
* also invokes build only for the chosen test targets
As a bonus, also adds `xmake sln --open` which allows opening IDE after generation of solution/xmake project is done.
Diffstat (limited to 'src/zenhttp')
| -rw-r--r-- | src/zenhttp/clients/httpclientcommon.cpp | 4 | ||||
| -rw-r--r-- | src/zenhttp/httpclient.cpp | 4 | ||||
| -rw-r--r-- | src/zenhttp/httpclient_test.cpp | 4 | ||||
| -rw-r--r-- | src/zenhttp/httpserver.cpp | 4 | ||||
| -rw-r--r-- | src/zenhttp/packageformat.cpp | 4 | ||||
| -rw-r--r-- | src/zenhttp/security/passwordsecurity.cpp | 5 | ||||
| -rw-r--r-- | src/zenhttp/servers/wstest.cpp | 4 |
7 files changed, 29 insertions, 0 deletions
diff --git a/src/zenhttp/clients/httpclientcommon.cpp b/src/zenhttp/clients/httpclientcommon.cpp index c016e1c3c..248ae9d70 100644 --- a/src/zenhttp/clients/httpclientcommon.cpp +++ b/src/zenhttp/clients/httpclientcommon.cpp @@ -597,6 +597,8 @@ namespace testutil { } // namespace testutil +TEST_SUITE_BEGIN("http.httpclientcommon"); + TEST_CASE("BufferedReadFileStream") { ScopedTemporaryDirectory TmpDir; @@ -787,5 +789,7 @@ TEST_CASE("MultipartBoundaryParser") } } +TEST_SUITE_END(); + } // namespace zen #endif diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp index 1cfddb366..f94c58581 100644 --- a/src/zenhttp/httpclient.cpp +++ b/src/zenhttp/httpclient.cpp @@ -430,6 +430,8 @@ MeasureLatency(HttpClient& Client, std::string_view Url) #if ZEN_WITH_TESTS +TEST_SUITE_BEGIN("http.httpclient"); + TEST_CASE("responseformat") { using namespace std::literals; @@ -839,6 +841,8 @@ TEST_CASE("httpclient.password") AsioServer->RequestExit(); } } +TEST_SUITE_END(); + void httpclient_forcelink() { diff --git a/src/zenhttp/httpclient_test.cpp b/src/zenhttp/httpclient_test.cpp index 91b1a3414..52bf149a7 100644 --- a/src/zenhttp/httpclient_test.cpp +++ b/src/zenhttp/httpclient_test.cpp @@ -257,6 +257,8 @@ struct TestServerFixture ////////////////////////////////////////////////////////////////////////// // Tests +TEST_SUITE_BEGIN("http.httpclient"); + TEST_CASE("httpclient.verbs") { TestServerFixture Fixture; @@ -1352,6 +1354,8 @@ TEST_CASE("httpclient.transport-faults-post" * doctest::skip()) } } +TEST_SUITE_END(); + void httpclient_test_forcelink() { diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp index 3cefa0ad8..2facd8401 100644 --- a/src/zenhttp/httpserver.cpp +++ b/src/zenhttp/httpserver.cpp @@ -1322,6 +1322,8 @@ HandlePackageOffers(HttpService& Service, HttpServerRequest& Request, Ref<IHttpP #if ZEN_WITH_TESTS +TEST_SUITE_BEGIN("http.httpserver"); + TEST_CASE("http.common") { using namespace std::literals; @@ -1540,6 +1542,8 @@ TEST_CASE("http.common") } } +TEST_SUITE_END(); + void http_forcelink() { diff --git a/src/zenhttp/packageformat.cpp b/src/zenhttp/packageformat.cpp index 9a80d07c8..cbfe4d889 100644 --- a/src/zenhttp/packageformat.cpp +++ b/src/zenhttp/packageformat.cpp @@ -805,6 +805,8 @@ CbPackageReader::Finalize() #if ZEN_WITH_TESTS +TEST_SUITE_BEGIN("http.packageformat"); + TEST_CASE("CbPackage.Serialization") { // Make a test package @@ -926,6 +928,8 @@ TEST_CASE("CbPackage.LocalRef") Reader.Finalize(); } +TEST_SUITE_END(); + void forcelink_packageformat() { diff --git a/src/zenhttp/security/passwordsecurity.cpp b/src/zenhttp/security/passwordsecurity.cpp index a8fb9c3f5..0e3a743c3 100644 --- a/src/zenhttp/security/passwordsecurity.cpp +++ b/src/zenhttp/security/passwordsecurity.cpp @@ -76,6 +76,8 @@ PasswordSecurity::IsAllowed(std::string_view InPassword, std::string_view BaseUr #if ZEN_WITH_TESTS +TEST_SUITE_BEGIN("http.passwordsecurity"); + TEST_CASE("passwordsecurity.allowanything") { PasswordSecurity Anything({}); @@ -162,6 +164,9 @@ TEST_CASE("passwordsecurity.conflictingunprotecteduris") "uri #1 ('/free/access')")); } } + +TEST_SUITE_END(); + void passwordsecurity_forcelink() { diff --git a/src/zenhttp/servers/wstest.cpp b/src/zenhttp/servers/wstest.cpp index 95f8587df..fd023c490 100644 --- a/src/zenhttp/servers/wstest.cpp +++ b/src/zenhttp/servers/wstest.cpp @@ -41,6 +41,8 @@ using namespace std::literals; // Unit tests: WsFrameCodec // +TEST_SUITE_BEGIN("http.wstest"); + TEST_CASE("websocket.framecodec") { SUBCASE("ComputeAcceptKey RFC 6455 test vector") @@ -912,6 +914,8 @@ TEST_CASE("websocket.client") } } +TEST_SUITE_END(); + void websocket_forcelink() { |