From 21166ac40c48bc282b97fe2692a6aab93de85ad7 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:21:03 -0500 Subject: [PATCH 01/10] Rename stubMaker because consistency is important and Linux will be sad if we don't --- lua/gluatest/init.lua | 2 +- lua/gluatest/runner/helpers.lua | 2 +- lua/gluatest/stubs/{stubMaker.lua => stub_maker.lua} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename lua/gluatest/stubs/{stubMaker.lua => stub_maker.lua} (100%) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index bf5208a..a01d49b 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -22,7 +22,7 @@ if GLuaTest.RUN_CLIENTSIDE then AddCSLuaFile( "gluatest/expectations/positive.lua" ) AddCSLuaFile( "gluatest/expectations/negative.lua" ) - AddCSLuaFile( "gluatest/stubs/stubMaker.lua" ) + AddCSLuaFile( "gluatest/stubs/stub_maker.lua" ) AddCSLuaFile( "gluatest/runner/runner.lua" ) AddCSLuaFile( "gluatest/runner/colors.lua" ) diff --git a/lua/gluatest/runner/helpers.lua b/lua/gluatest/runner/helpers.lua index 2d0e777..4f0c1df 100644 --- a/lua/gluatest/runner/helpers.lua +++ b/lua/gluatest/runner/helpers.lua @@ -8,7 +8,7 @@ local Helpers = { local expect = include( "gluatest/expectations/expect.lua" ) --- @type GLuaTest_StubMaker -local stubMaker = include( "gluatest/stubs/stubMaker.lua" ) +local stubMaker = include( "gluatest/stubs/stub_maker.lua" ) --- Gets a unique case ID --- @return string diff --git a/lua/gluatest/stubs/stubMaker.lua b/lua/gluatest/stubs/stub_maker.lua similarity index 100% rename from lua/gluatest/stubs/stubMaker.lua rename to lua/gluatest/stubs/stub_maker.lua From 8654b0b77f6fd37963ef5fb101e28ca6de14d73a Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:22:16 -0500 Subject: [PATCH 02/10] Color log prefix to differentiate server and client tests --- lua/gluatest/runner/colors.lua | 15 +++++++++------ lua/gluatest/runner/logger.lua | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lua/gluatest/runner/colors.lua b/lua/gluatest/runner/colors.lua index 6592758..4ba6f75 100644 --- a/lua/gluatest/runner/colors.lua +++ b/lua/gluatest/runner/colors.lua @@ -2,13 +2,16 @@ --- @type GLuaTest_LogColors local colors = { - red = Color( 255, 0, 0 ), - green = Color( 0, 255, 0 ), - grey = Color( 175, 192, 198 ), + red = Color( 255, 0, 0 ), + green = Color( 0, 255, 0 ), + grey = Color( 175, 192, 198 ), darkgrey = Color( 125, 125, 125 ), - yellow = Color( 235, 226, 52 ), - white = Color( 220, 220, 220 ), - blue = Color( 120, 162, 204 ) + yellow = Color( 235, 226, 52 ), + white = Color( 220, 220, 220 ), + blue = Color( 120, 162, 204 ), + + server = Color( 100, 200, 255 ), + client = Color( 195, 201, 75 ), } hook.Run( "GLuaTest_MakeColors", colors ) diff --git a/lua/gluatest/runner/logger.lua b/lua/gluatest/runner/logger.lua index 9f862f1..5d5b7eb 100644 --- a/lua/gluatest/runner/logger.lua +++ b/lua/gluatest/runner/logger.lua @@ -13,8 +13,10 @@ local ResultLogger = {} function ResultLogger.prefixLog( ... ) + local prefixColor = SERVER and colors.server or colors.client + MsgC( colors.darkgrey, "[" ) - MsgC( colors.white, "GLuaTest" ) + MsgC( prefixColor, "GLuaTest" ) MsgC( colors.darkgrey, "] " ) MsgC( ... ) end From 220c427f74088efadd749db82f729187230ba91b Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:41:38 -0500 Subject: [PATCH 03/10] Split gluatest_enable into two convars, one for server and one for client Always send clients all of the testing framework so clientside tests can be enabled/disabled at will Run clientside tests after serverside tests finish --- lua/gluatest/init.lua | 94 ++++++++++++++----- lua/gluatest/loader.lua | 2 +- lua/gluatest/runner/runner.lua | 2 +- lua/tests/gluatest/init.lua | 11 ++- .../gluatest/loader/checkSendToClients.lua | 24 ++--- 5 files changed, 94 insertions(+), 39 deletions(-) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index a01d49b..3f0ec27 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -3,10 +3,12 @@ local RED = Color( 255, 0, 0 ) --- @type VersionTools local VersionTools = include( "utils/version.lua" ) +local conVarFlags = bit.bor( FCVAR_ARCHIVE, FCVAR_PROTECTED ) --- @class GLuaTest GLuaTest = { - -- If, for some reason, you need to run GLuaTest clientside, set this to true (not very well supported) - RUN_CLIENTSIDE = false, + RunServersideConVar = CreateConVar( "gluatest_server_enable", "1", conVarFlags, "Should GLuaTest run automatically on the server side?" ), + RunClientsideConVar = CreateConVar( "gluatest_client_enable", "0", conVarFlags, "Should GLuaTest run automatically on the client side?" ), + SelfTestConVar = CreateConVar( "gluatest_selftest_enable", "0", conVarFlags, "Should GLuaTest run its own tests?" ), DeprecatedNotice = function( old, new ) local msg = [[GLuaTest: (DEPRECATION NOTICE) "]] .. old .. [[" is deprecated, use "]] .. new .. [[" instead.]] @@ -14,35 +16,71 @@ GLuaTest = { end } -if GLuaTest.RUN_CLIENTSIDE then - AddCSLuaFile() - AddCSLuaFile( "gluatest/loader.lua" ) +--[[ Set Up Client Testing ]] do + if SERVER then + util.AddNetworkString( "GLuaTest_RunClientTests" ) - AddCSLuaFile( "gluatest/expectations/expect.lua" ) - AddCSLuaFile( "gluatest/expectations/positive.lua" ) - AddCSLuaFile( "gluatest/expectations/negative.lua" ) + -- /* + AddCSLuaFile( "gluatest/init.lua" ) + AddCSLuaFile( "gluatest/loader.lua" ) + AddCSLuaFile( "gluatest/types.lua" ) + -- /util/* + AddCSLuaFile( "gluatest/utils/git_tools.lua" ) + AddCSLuaFile( "gluatest/utils/version.lua" ) + + -- /stubs/* AddCSLuaFile( "gluatest/stubs/stub_maker.lua" ) - AddCSLuaFile( "gluatest/runner/runner.lua" ) - AddCSLuaFile( "gluatest/runner/colors.lua" ) - AddCSLuaFile( "gluatest/runner/logger.lua" ) - AddCSLuaFile( "gluatest/runner/helpers.lua" ) - AddCSLuaFile( "gluatest/runner/log_helpers.lua" ) - AddCSLuaFile( "gluatest/runner/msgc_wrapper.lua" ) -end + -- /runner/* + AddCSLuaFile( "gluatest/runner/colors.lua" ) + AddCSLuaFile( "gluatest/runner/helpers.lua" ) + AddCSLuaFile( "gluatest/runner/log_helpers.lua" ) + AddCSLuaFile( "gluatest/runner/logger.lua" ) + AddCSLuaFile( "gluatest/runner/runner.lua" ) + AddCSLuaFile( "gluatest/runner/test_case_runner.lua" ) + AddCSLuaFile( "gluatest/runner/test_group_runner.lua" ) + + -- /expectations/* + AddCSLuaFile( "gluatest/expectations/expect.lua" ) + AddCSLuaFile( "gluatest/expectations/negative.lua" ) + AddCSLuaFile( "gluatest/expectations/positive.lua" ) + + -- /expectations/utils/* + AddCSLuaFile( "gluatest/expectations/utils/table_diff.lua" ) + + -- When the server finishes its tests, notify clients to start theirs + -- While it is possible to run client and server tests in parallel, that may lead to + -- undesirable side-effects or conflicts. + hook.Add( "GLuaTest_Finished", "GLuaTest_RunClientTests", function() + -- Give the server tests a moment to finish so the console messages on local servers don't get mixed together + timer.Simple( 0.1, function() + if GLuaTest.RunClientsideConVar:GetBool() then + net.Start( "GLuaTest_RunClientTests" ) + net.Broadcast() + end + end ) + end) + end ---- @diagnostic disable-next-line: param-type-mismatch -local shouldRun = CreateConVar( "gluatest_enable", "1", FCVAR_ARCHIVE + FCVAR_PROTECTED, "Should GLuaTest run?" ) ---- @diagnostic disable-next-line: param-type-mismatch -local shouldSelfTest = CreateConVar( "gluatest_selftest_enable", "0", FCVAR_ARCHIVE + FCVAR_PROTECTED, "Should GLuaTest run its own tests?" ) + if CLIENT then + -- Run clientside tests when the server asks + net.Receive( "GLuaTest_RunClientTests", function( _, _ ) + if not GLuaTest then + error( "[GLuaTest] Client tests are attempting to run before GLuaTest has initialized" ) + end + + GLuaTest.runAllTests() + end ) + end +end --- @param loader GLuaTest_Loader --- @param projectName string --- @param path string --- @param testFiles GLuaTest_TestGroup[] local function addTestFiles( loader, projectName, path, testFiles ) - if projectName == "gluatest" and not shouldSelfTest:GetBool() then + if projectName == "gluatest" and not GLuaTest.SelfTestConVar:GetBool() then return end @@ -65,8 +103,20 @@ end --- Loads and runs all tests in the tests/ directory GLuaTest.runAllTests = function() - if not shouldRun:GetBool() then - print( "[GLuaTest] Test runs are disabled. Enable them with: gluatest_enable 1" ) + local shouldRunServerside = GLuaTest.RunServersideConVar:GetBool() + local shouldRunClientside = GLuaTest.RunClientsideConVar:GetBool() + + if SERVER and not shouldRunServerside then + -- Alert the client immediately if we are skipping server tests and are still running client tests + if shouldRunClientside then + net.Start( "GLuaTest_RunClientTests" ) + net.Broadcast() + end + + if not shouldRunClientside then + print( "[GLuaTest] Test runs are disabled clientside and serverside. Enable them with gluatest_server_enable 1 and/or gluatest_client_enable 1" ) + end + return end diff --git a/lua/gluatest/loader.lua b/lua/gluatest/loader.lua index e6fb65d..36ed690 100644 --- a/lua/gluatest/loader.lua +++ b/lua/gluatest/loader.lua @@ -5,7 +5,7 @@ local Loader = {} --- @param filePath string --- @param cases GLuaTest_TestCase[] function Loader.checkSendToClients( filePath, cases ) - if not GLuaTest.RUN_CLIENTSIDE then return end + if not GLuaTest.RunClientsideConVar:GetBool() then return end for _, case in ipairs( cases ) do if case.clientside then diff --git a/lua/gluatest/runner/runner.lua b/lua/gluatest/runner/runner.lua index 4fefcb9..2ce04b0 100644 --- a/lua/gluatest/runner/runner.lua +++ b/lua/gluatest/runner/runner.lua @@ -40,7 +40,7 @@ end --- Runs all given test groups --- @param testGroups GLuaTest_RunnableTestGroup[] function TestRunner:Run( testGroups ) - if CLIENT and not GLuaTest.RUN_CLIENTSIDE then return end + if CLIENT and not GLuaTest.RunClientsideConVar:GetBool() then return end PlainLogStart() diff --git a/lua/tests/gluatest/init.lua b/lua/tests/gluatest/init.lua index e8a4661..9f5c1c9 100644 --- a/lua/tests/gluatest/init.lua +++ b/lua/tests/gluatest/init.lua @@ -1,3 +1,4 @@ +--- @type GLuaTest_TestGroup return { groupName = "Initialization", @@ -20,7 +21,8 @@ return { { name = "Convars exist", func = function() - expect( ConVarExists( "gluatest_enable" ) ).to.beTrue() + expect( ConVarExists( "gluatest_server_enable" ) ).to.beTrue() + expect( ConVarExists( "gluatest_client_enable" ) ).to.beTrue() expect( ConVarExists( "gluatest_selftest_enable" ) ).to.beTrue() end }, @@ -28,8 +30,11 @@ return { { name = "Convars have correct defaults", func = function() - local gluatest_enable = GetConVar( "gluatest_enable" ) - expect( gluatest_enable:GetDefault() ).to.equal( "1" ) + local gluatest_server_enable = GetConVar( "gluatest_server_enable" ) + expect( gluatest_server_enable:GetDefault() ).to.equal( "1" ) + + local gluatest_client_enable = GetConVar( "gluatest_client_enable" ) + expect( gluatest_client_enable:GetDefault() ).to.equal( "0" ) local gluatest_selftest_enable = GetConVar( "gluatest_selftest_enable" ) expect( gluatest_selftest_enable:GetDefault() ).to.equal( "0" ) diff --git a/lua/tests/gluatest/loader/checkSendToClients.lua b/lua/tests/gluatest/loader/checkSendToClients.lua index 1a3a111..b151d24 100644 --- a/lua/tests/gluatest/loader/checkSendToClients.lua +++ b/lua/tests/gluatest/loader/checkSendToClients.lua @@ -15,12 +15,12 @@ return { }, { - name = "Sends clientside cases when RUN_CLIENTSIDE is enabled", + name = "Sends clientside cases when the gluatest_client_enable ConVar is enabled", func = function( state ) local Loader = state.Loader - state.currentRunClientside = GLuaTest.RUN_CLIENTSIDE + state.currentRunClientside = GLuaTest.RunClientsideConVar:GetBool() - GLuaTest.RUN_CLIENTSIDE = true + GLuaTest.RunClientsideConVar:SetBool( true ) local AddCSLuaFileStub = stub( _G, "AddCSLuaFile" ) local cases = { { clientside = true } } @@ -28,17 +28,17 @@ return { expect( AddCSLuaFileStub ).was.called() end, cleanup = function( state ) - GLuaTest.RUN_CLIENTSIDE = state.currentRunClientside + GLuaTest.RunClientsideConVar:SetBool( state.currentRunClientside ) end }, { - name = "Does not send clientside cases if RUN_CLIENTSIDE is disabled", + name = "Does not send clientside cases if the gluatest_client_enable ConVar is disabled", func = function( state ) local Loader = state.Loader - state.currentRunClientside = GLuaTest.RUN_CLIENTSIDE + state.currentRunClientside = GLuaTest.RunClientsideConVar:GetBool() - GLuaTest.RUN_CLIENTSIDE = false + GLuaTest.RunClientsideConVar:SetBool( false ) local AddCSLuaFileStub = stub( _G, "AddCSLuaFile" ) local cases = { { clientside = true } } @@ -47,17 +47,17 @@ return { end, cleanup = function( state ) - GLuaTest.RUN_CLIENTSIDE = state.currentRunClientside + GLuaTest.RunClientsideConVar:SetBool( state.currentRunClientside ) end }, { - name = "Does not send non-clientside cases when RUN_CLIENTSIDE is enabled", + name = "Does not send non-clientside cases when the gluatest_client_enable ConVar is enabled", func = function( state ) local Loader = state.Loader - state.currentRunClientside = GLuaTest.RUN_CLIENTSIDE + state.currentRunClientside = GLuaTest.RunClientsideConVar:GetBool() - GLuaTest.RUN_CLIENTSIDE = true + GLuaTest.RunClientsideConVar:SetBool( true ) local AddCSLuaFileStub = stub( _G, "AddCSLuaFile" ) local cases = { { clientside = false } } @@ -66,7 +66,7 @@ return { end, cleanup = function( state ) - GLuaTest.RUN_CLIENTSIDE = state.currentRunClientside + GLuaTest.RunClientsideConVar:SetBool( state.currentRunClientside ) end } } From 48ae9898c8433d4dd72988d296c7a14c22e4c822 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Wed, 30 Apr 2025 15:42:48 -0500 Subject: [PATCH 04/10] Don't re-run tests when hotloading --- lua/gluatest/init.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index 3f0ec27..06ee954 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -4,6 +4,8 @@ local RED = Color( 255, 0, 0 ) local VersionTools = include( "utils/version.lua" ) local conVarFlags = bit.bor( FCVAR_ARCHIVE, FCVAR_PROTECTED ) + +local isHotload = GLuaTest ~= nil --- @class GLuaTest GLuaTest = { RunServersideConVar = CreateConVar( "gluatest_server_enable", "1", conVarFlags, "Should GLuaTest run automatically on the server side?" ), @@ -147,10 +149,13 @@ GLuaTest.runAllTests = function() runner:Run( testFiles ) end -hook.Add( "Tick", "GLuaTest_Runner", function() - hook.Remove( "Tick", "GLuaTest_Runner" ) - GLuaTest.runAllTests() -end ) +-- Automatically run tests when loading into a map +if not isHotload then + hook.Add( "Tick", "GLuaTest_Runner", function() + hook.Remove( "Tick", "GLuaTest_Runner" ) + GLuaTest.runAllTests() + end ) +end --- @diagnostic disable-next-line: param-type-mismatch concommand.Add( "gluatest_run_tests", GLuaTest.runAllTests, nil, "Run all tests in the tests/ directory", FCVAR_PROTECTED ) From 3449058098ce10cb912ae88dec64a8c3681f1c29 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Wed, 30 Apr 2025 19:23:30 -0500 Subject: [PATCH 05/10] Stop complaining about mismatches that don't exist you old hag --- lua/gluatest/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index 06ee954..3151913 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -8,8 +8,11 @@ local conVarFlags = bit.bor( FCVAR_ARCHIVE, FCVAR_PROTECTED ) local isHotload = GLuaTest ~= nil --- @class GLuaTest GLuaTest = { + --- @diagnostic disable-next-line: param-type-mismatch RunServersideConVar = CreateConVar( "gluatest_server_enable", "1", conVarFlags, "Should GLuaTest run automatically on the server side?" ), + --- @diagnostic disable-next-line: param-type-mismatch RunClientsideConVar = CreateConVar( "gluatest_client_enable", "0", conVarFlags, "Should GLuaTest run automatically on the client side?" ), + --- @diagnostic disable-next-line: param-type-mismatch SelfTestConVar = CreateConVar( "gluatest_selftest_enable", "0", conVarFlags, "Should GLuaTest run its own tests?" ), DeprecatedNotice = function( old, new ) From 6d4f8c13a126115dd6265d36171401218aac20d4 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Wed, 30 Apr 2025 19:43:45 -0500 Subject: [PATCH 06/10] Fix typo and style issues --- lua/gluatest/init.lua | 2 +- lua/gluatest/runner/helpers.lua | 2 +- lua/gluatest/runner/test_case_runner.lua | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index 3151913..d630314 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -65,7 +65,7 @@ GLuaTest = { net.Broadcast() end end ) - end) + end ) end if CLIENT then diff --git a/lua/gluatest/runner/helpers.lua b/lua/gluatest/runner/helpers.lua index 4f0c1df..9f6536a 100644 --- a/lua/gluatest/runner/helpers.lua +++ b/lua/gluatest/runner/helpers.lua @@ -376,7 +376,7 @@ function Helpers.CreateCaseState( testGroupState ) end } - hook.Run( "GLuaTest_CaseStateCreated", state, meta, testGroupStatee ) + hook.Run( "GLuaTest_CaseStateCreated", state, meta, testGroupState ) return setmetatable( state, meta ) end diff --git a/lua/gluatest/runner/test_case_runner.lua b/lua/gluatest/runner/test_case_runner.lua index cd3d667..b49d567 100644 --- a/lua/gluatest/runner/test_case_runner.lua +++ b/lua/gluatest/runner/test_case_runner.lua @@ -28,8 +28,8 @@ local function checkShouldSkip( case ) if cond == false then return true end -- Function conditions are expected to return true - if isfunction( cond ) then - if cond() ~= true then return true end + if isfunction( cond ) and cond() ~= true then + return true end end From b200c5eefac7213e802922d96bc7c4493d1ed639 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Thu, 1 May 2025 10:25:20 -0500 Subject: [PATCH 07/10] Move loader to GLuaTest table Load extensions immediately instead of waiting for the tests to run so that clients receive them in time --- lua/gluatest/init.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index d630314..7937337 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -15,12 +15,20 @@ GLuaTest = { --- @diagnostic disable-next-line: param-type-mismatch SelfTestConVar = CreateConVar( "gluatest_selftest_enable", "0", conVarFlags, "Should GLuaTest run its own tests?" ), + --- @type GLuaTest_Loader + Loader = include( "gluatest/loader.lua" ), + DeprecatedNotice = function( old, new ) local msg = [[GLuaTest: (DEPRECATION NOTICE) "]] .. old .. [[" is deprecated, use "]] .. new .. [[" instead.]] if SERVER then MsgC( RED, msg .. "\n" ) end end } +--[[ Extensions ]] do + -- Because extensions do their own AddCSLuaFile calls, we need to load them immediately so local server clients receive them + GLuaTest.Loader.loadExtensions( "gluatest/extensions" ) +end + --[[ Set Up Client Testing ]] do if SERVER then util.AddNetworkString( "GLuaTest_RunClientTests" ) @@ -127,10 +135,6 @@ GLuaTest.runAllTests = function() GLuaTest.VERSION = VersionTools.getVersion() - --- @type GLuaTest_Loader - local Loader = include( "gluatest/loader.lua" ) - Loader.loadExtensions( "gluatest/extensions" ) - local testPaths = { "tests", GAMEMODE.FolderName .. "/gamemode/tests" @@ -142,7 +146,7 @@ GLuaTest.runAllTests = function() for i = 1, #testPaths do local path = testPaths[i] - loadAllProjectsFrom( Loader, path, testFiles ) + loadAllProjectsFrom( GLuaTest.Loader, path, testFiles ) end hook.Run( "GLuaTest_RunTestFiles", testFiles ) From cd91f5b56802dce78252cbcee7eb7520f6caa4db Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Thu, 1 May 2025 10:26:15 -0500 Subject: [PATCH 08/10] Add cl_ and sv_ prefixes to logs to differentiate server and client test logs in situations where the text color isn't present --- lua/gluatest/runner/logger.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/gluatest/runner/logger.lua b/lua/gluatest/runner/logger.lua index 5d5b7eb..98befaf 100644 --- a/lua/gluatest/runner/logger.lua +++ b/lua/gluatest/runner/logger.lua @@ -13,10 +13,18 @@ local ResultLogger = {} function ResultLogger.prefixLog( ... ) - local prefixColor = SERVER and colors.server or colors.client + local prefixColor + local prefixText = "GLuaTest" + if SERVER then + prefixText = "sv_" .. prefixText + prefixColor = colors.server + else + prefixText = "cl_" .. prefixText + prefixColor = colors.client + end MsgC( colors.darkgrey, "[" ) - MsgC( prefixColor, "GLuaTest" ) + MsgC( prefixColor, prefixText ) MsgC( colors.darkgrey, "] " ) MsgC( ... ) end From e5fd133ba33ff126a493405e1cba4770894a63d3 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Thu, 1 May 2025 10:44:18 -0500 Subject: [PATCH 09/10] Minor formatting --- lua/gluatest/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index 7937337..b38c2c8 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -25,11 +25,13 @@ GLuaTest = { } --[[ Extensions ]] do + -- Because extensions do their own AddCSLuaFile calls, we need to load them immediately so local server clients receive them GLuaTest.Loader.loadExtensions( "gluatest/extensions" ) end --[[ Set Up Client Testing ]] do + if SERVER then util.AddNetworkString( "GLuaTest_RunClientTests" ) From 8d6affefe9e4955fbab173542edcdf8433d76e77 Mon Sep 17 00:00:00 2001 From: John Schneider <8369707+A1steaksa@users.noreply.github.com> Date: Thu, 1 May 2025 10:44:46 -0500 Subject: [PATCH 10/10] Re-load extensions when running tests to make extension development easier --- lua/gluatest/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/gluatest/init.lua b/lua/gluatest/init.lua index b38c2c8..a9c3fbe 100644 --- a/lua/gluatest/init.lua +++ b/lua/gluatest/init.lua @@ -135,6 +135,9 @@ GLuaTest.runAllTests = function() return end + -- Re-load extensions to make extension development easier + GLuaTest.Loader.loadExtensions( "gluatest/extensions" ) + GLuaTest.VERSION = VersionTools.getVersion() local testPaths = {