From 42237ddc036d835b0fc4c1800730cfc4002a2829 Mon Sep 17 00:00:00 2001 From: peace-maker Date: Mon, 14 Sep 2026 23:55:15 +0200 Subject: [PATCH] CI: Fix hl2sdk-mock test error detection (#2558) * Build sdktools for hl2sdk-mock The test_format script requires it. * Fix test_format %T translation test %T expects a client index and translation phrase as arguments, the test was passing a language id and a phrase. It never ran due to sdktools missing on the mock srcds before. * mocktest: Check for passing tests or exceptions too When sourcemod wouldn't even load the tests were still green since there was no "FAIL" in the output :D * Test 32bit x86 srcds too * Build against MMS 1.12-dev --- .github/workflows/mocktest.yml | 46 ++++---- extensions/sdktools/AMBuilder | 2 - plugins/testsuite/mock/test_format.sp | 147 +++++++++++++------------- 3 files changed, 101 insertions(+), 94 deletions(-) diff --git a/.github/workflows/mocktest.yml b/.github/workflows/mocktest.yml index 9bf67e4d..d85091b8 100644 --- a/.github/workflows/mocktest.yml +++ b/.github/workflows/mocktest.yml @@ -24,6 +24,7 @@ jobs: name: Clone metamod-source with: repository: alliedmodders/metamod-source + ref: 1.12-dev submodules: recursive path: metamod-source @@ -37,19 +38,19 @@ jobs: - name: Build MetaMod:Source working-directory: metamod-source run: | - python3 configure.py --enable-optimize --sdks=mock --targets=x86_64 + python3 configure.py --enable-optimize --sdks=mock --targets=x86,x86_64 ambuild objdir - name: Build SourceMod working-directory: sourcemod run: | - python3 configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86_64 + python3 configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86,x86_64 ambuild objdir - name: Build hl2sdk-mock working-directory: hl2sdk-mock run: | - python3 configure.py --enable-optimize --targets=x86_64 + python3 configure.py --enable-optimize --targets=x86,x86_64 ambuild objdir - name: Setup gamedir @@ -75,22 +76,31 @@ jobs: working-directory: hl2sdk-mock shell: bash run: | - for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do + for arch in x86 x86_64; do echo "===================================" - echo "Running $(basename $f)..." + echo "Testing $arch..." echo "===================================" - timeout 60 ./objdir/dist/x86_64/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 | - { - failed=0 - while IFS= read -r line; do - echo "$line" - if [[ "$line" == *"FAIL"* ]]; then - failed=1 + for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do + echo "===================================" + echo "Running $(basename $f)..." + echo "===================================" + timeout 60 ./objdir/dist/$arch/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 | + { + failed=0 + succeeded=0 + while IFS= read -r line; do + echo "$line" + if [[ "$line" == *"FAIL"* || "$line" == *"Exception reported"* ]]; then + failed=1 + fi + if [[ "$line" == *" OK"* ]]; then + succeeded=1 + fi + done + if [ "$failed" = "1" ] || [ "$succeeded" = "0" ]; then + echo "$(basename $f) failed." + exit 1 fi - done - if [ "$failed" = "1" ]; then - echo "$(basename $f) failed." - exit 1 - fi - } + } + done done diff --git a/extensions/sdktools/AMBuilder b/extensions/sdktools/AMBuilder index e71c3657..eec5a7ba 100644 --- a/extensions/sdktools/AMBuilder +++ b/extensions/sdktools/AMBuilder @@ -29,8 +29,6 @@ project.sources += [ for sdk_name in SM.sdks: sdk = SM.sdks[sdk_name] - if sdk['name'] in ['mock']: - continue for cxx in builder.targets: if not cxx.target.arch in sdk['platforms'][cxx.target.platform]: diff --git a/plugins/testsuite/mock/test_format.sp b/plugins/testsuite/mock/test_format.sp index cdb62f93..0681df8d 100644 --- a/plugins/testsuite/mock/test_format.sp +++ b/plugins/testsuite/mock/test_format.sp @@ -1780,82 +1780,81 @@ void TestTranslates() SetTestContext("Test Translates"); - int lang = GetLanguageByCode("en"); - - // Base - AssertFmtTR1("'%T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR2("'%T'", "Chat admins", lang, 0, "'(ADMINS) Console'"); - AssertFmtTR2("'%T'", "Vote Delay Seconds", lang, 77777777, "'You must wait 77777777 seconds before starting another vote.'"); - AssertFmtTR3("'%T'", "Vote Select", lang, "player1", "option2", "'player1 has chosen option2.'"); - - // Precision - AssertFmtTR1("'%.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%.32T'", "Unable to target", lang, "'You cannot target this player.'"); - - // Width - AssertFmtTR1("'%T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%32T'", "Unable to target", lang, "'You cannot target this player.'"); - - // Precision & Width - AssertFmtTR1("'%0.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%0.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%0.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%32.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%32.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%32.32T'", "Unable to target", lang, "'You cannot target this player.'"); - - // Flags - AssertFmtTR1("'%0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0T'", "Unable to target", lang, "'You cannot target this player.'"); - - // Flags & Precision - AssertFmtTR1("'%0.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%0.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%0.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0.32T'", "Unable to target", lang, "'You cannot target this player.'"); - - // Flags & Width - AssertFmtTR1("'%0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%00T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%032T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-00T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-032T'", "Unable to target", lang, "'You cannot target this player.'"); - - // Flags & Precision & Width - AssertFmtTR1("'%00.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%00.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%00.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%032.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%032.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%032.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-0.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-32.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-32.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-32.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-00.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-00.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-00.32T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-032.T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-032.0T'", "Unable to target", lang, "'You cannot target this player.'"); - AssertFmtTR1("'%-032.32T'", "Unable to target", lang, "'You cannot target this player.'"); - // Ensure that the global language target is English // otherwise it may deviate from the expected value - AssertEq("Server Language", GetServerLanguage(), lang); + AssertEq("Server Language", GetServerLanguage(), GetLanguageByCode("en")); + + // Base + AssertFmtTR1("'%T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR2("'%T'", "Chat admins", 0, 0, "'(ADMINS) Console'"); + AssertFmtTR2("'%T'", "Vote Delay Seconds", 0, 77777777, "'You must wait 77777777 seconds before starting another vote.'"); + AssertFmtTR3("'%T'", "Vote Select", 0, "player1", "option2", "'player1 has chosen option2.'"); + + // Precision + AssertFmtTR1("'%.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%.32T'", "Unable to target", 0, "'You cannot target this player.'"); + + // Width + AssertFmtTR1("'%T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%32T'", "Unable to target", 0, "'You cannot target this player.'"); + + // Precision & Width + AssertFmtTR1("'%0.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%0.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%0.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%32.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%32.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%32.32T'", "Unable to target", 0, "'You cannot target this player.'"); + + // Flags + AssertFmtTR1("'%0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0T'", "Unable to target", 0, "'You cannot target this player.'"); + + // Flags & Precision + AssertFmtTR1("'%0.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%0.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%0.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0.32T'", "Unable to target", 0, "'You cannot target this player.'"); + + // Flags & Width + AssertFmtTR1("'%0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%00T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%032T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-00T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-032T'", "Unable to target", 0, "'You cannot target this player.'"); + + // Flags & Precision & Width + AssertFmtTR1("'%00.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%00.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%00.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%032.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%032.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%032.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-0.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-32.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-32.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-32.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-00.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-00.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-00.32T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-032.T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-032.0T'", "Unable to target", 0, "'You cannot target this player.'"); + AssertFmtTR1("'%-032.32T'", "Unable to target", 0, "'You cannot target this player.'"); + SetGlobalTransTarget(LANG_SERVER); // Base