From 7265985fed736db533020f870247c75834f6ac15 Mon Sep 17 00:00:00 2001 From: Brandon Sturgeon Date: Thu, 27 Jun 2024 14:16:41 -0700 Subject: [PATCH] Add helpers for branch detection, fix angle skips --- lua/autorun/gmod_tests_init.lua | 1 + lua/gmod_tests/sh_init.lua | 7 +++++++ lua/tests/gmod/globals/angle.lua | 8 ++++---- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 lua/autorun/gmod_tests_init.lua create mode 100644 lua/gmod_tests/sh_init.lua diff --git a/lua/autorun/gmod_tests_init.lua b/lua/autorun/gmod_tests_init.lua new file mode 100644 index 0000000..cce1f05 --- /dev/null +++ b/lua/autorun/gmod_tests_init.lua @@ -0,0 +1 @@ +include( "gmod_tests/sh_init.lua" ) diff --git a/lua/gmod_tests/sh_init.lua b/lua/gmod_tests/sh_init.lua new file mode 100644 index 0000000..bf8e151 --- /dev/null +++ b/lua/gmod_tests/sh_init.lua @@ -0,0 +1,7 @@ +-- Helpers and utilities for the gmod_tests test suite +-- (TODO: Do these belong somewhere else) +AddCSLuaFile() + +local jitVersion = jit.version +IS_BASE_BRANCH = jitVersion == "LuaJIT 2.0.4" +IS_64BIT_BRANCH = jitVersion == "LuaJIT 2.1.0-beta3" diff --git a/lua/tests/gmod/globals/angle.lua b/lua/tests/gmod/globals/angle.lua index 0c0be72..5d4a4f9 100644 --- a/lua/tests/gmod/globals/angle.lua +++ b/lua/tests/gmod/globals/angle.lua @@ -78,7 +78,7 @@ return{ },{ -- https://github.com/Facepunch/garrysmod-issues/issues/5922#issuecomment-2194156039 name = "Nil pitch returns 0, 0, 0 (base)", - when = BRANCH == "unknown", + when = IS_BASE_BRANCH, func = function() local angle = Angle( nil, 10, 22 ) expect( angle.pitch ).to.equal( 0 ) @@ -88,7 +88,7 @@ return{ },{ -- https://github.com/Facepunch/garrysmod-issues/issues/5922#issuecomment-2194156039 name = "Nil pitch falls back to 0 (x86-64)", - when = BRANCH == "x86-64", + when = IS_64BIT_BRANCH, func = function() local angle = Angle( nil, 10, 22 ) expect( angle.pitch ).to.equal( 0 ) @@ -98,7 +98,7 @@ return{ },{ -- https://github.com/Facepunch/garrysmod-issues/issues/5922#issuecomment-2194156039 name = "Table pitch returns 0, 0, 0 (base)", - when = BRANCH == "unknown", + when = IS_BASE_BRANCH, func = function() local angle = Angle( { "test" }, 10, 22 ) expect( angle.pitch ).to.equal( 0 ) @@ -108,6 +108,7 @@ return{ },{ -- https://github.com/Facepunch/garrysmod-issues/issues/5922#issuecomment-2194156039 name = "Table pitch falls back to 0 (x86-64)", + when = IS_64BIT_BRANCH, func = function() local angle = Angle( { "test" }, 10, 22 ) expect( angle.pitch ).to.equal( 0 ) @@ -189,6 +190,5 @@ return{ end }, --#endregion - } }