aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluau-project <luau.project@gmail.com>2025-03-07 22:00:35 -0300
committerHisham Muhammad <hisham@gobolinux.org>2025-03-09 20:20:41 -0300
commitac2a322b59ff612a74bae144fc553b673f2345f6 (patch)
tree63516afc0cb55392db533d035fe30fc4ac7302c4
parent3dd63039e1c93a258a232bcd187dbe79f4478d4e (diff)
downloadluarocks-ac2a322b59ff612a74bae144fc553b673f2345f6.tar.gz
luarocks-ac2a322b59ff612a74bae144fc553b673f2345f6.tar.bz2
luarocks-ac2a322b59ff612a74bae144fc553b673f2345f6.zip
ci(windows): support MinGW-w64 UCRT64 on test_env
-rw-r--r--spec/util/test_env.lua50
1 files changed, 49 insertions, 1 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index 645c182f..69874d79 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -19,6 +19,7 @@ ARGUMENTS
19 noreset Don't reset environment after each test 19 noreset Don't reset environment after each test
20 clean Remove existing testing environment. 20 clean Remove existing testing environment.
21 ci Add if running on Unix CI. 21 ci Add if running on Unix CI.
22 ci-windows Add if running on Windows CI.
22 appveyor Add if running on Appveyor. 23 appveyor Add if running on Appveyor.
23 os=<type> Set OS ("linux", "osx", or "windows"). 24 os=<type> Set OS ("linux", "osx", or "windows").
24 lua_dir=<path> Path of Lua installation (default "/usr/local") 25 lua_dir=<path> Path of Lua installation (default "/usr/local")
@@ -351,6 +352,8 @@ function test_env.set_args()
351 test_env.VERBOSE = true 352 test_env.VERBOSE = true
352 elseif argument == "ci" then 353 elseif argument == "ci" then
353 test_env.CI = true 354 test_env.CI = true
355 elseif argument == "ci-windows" then
356 test_env.CI_WINDOWS = true
354 elseif argument == "appveyor" then 357 elseif argument == "appveyor" then
355 test_env.APPVEYOR = true 358 test_env.APPVEYOR = true
356 elseif argument:find("^os=") then 359 elseif argument:find("^os=") then
@@ -379,6 +382,20 @@ function test_env.set_args()
379 if test_env.MINGW then 382 if test_env.MINGW then
380 test_env.OPENSSL_LIBDIR = "C:\\OpenSSL-v111-Win32\\bin" 383 test_env.OPENSSL_LIBDIR = "C:\\OpenSSL-v111-Win32\\bin"
381 end 384 end
385 elseif test_env.CI_WINDOWS then
386 if test_env.MINGW then
387 test_env.OPENSSL_INCDIR = "c:\\msys64\\ucrt64\\include"
388 test_env.OPENSSL_LIBDIR = "c:\\msys64\\ucrt64\\lib"
389
390 test_env.ZLIB_INCDIR = test_env.OPENSSL_INCDIR
391 test_env.ZLIB_LIBDIR = test_env.OPENSSL_LIBDIR
392
393 test_env.BZ2_INCDIR = test_env.OPENSSL_INCDIR
394 test_env.BZ2_LIBDIR = test_env.OPENSSL_LIBDIR
395 else
396 test_env.OPENSSL_INCDIR = "c:\\external\\include"
397 test_env.OPENSSL_LIBDIR = "c:\\external\\lib"
398 end
382 end 399 end
383 else 400 else
384 local system = execute_output("uname -s") 401 local system = execute_output("uname -s")
@@ -669,7 +686,11 @@ local function build_environment(rocks, env_variables)
669 lfs.mkdir(testing_paths.testing_deps_tree) 686 lfs.mkdir(testing_paths.testing_deps_tree)
670 687
671 test_env.run.luarocks_admin_nocov(C("make_manifest", Q(testing_paths.testing_server))) 688 test_env.run.luarocks_admin_nocov(C("make_manifest", Q(testing_paths.testing_server)))
672 test_env.run.luarocks_admin_nocov(C("make_manifest", Q(testing_paths.testing_cache))) 689 test_env.run.luarocks_admin_nocov(C("make_manifest", Q(testing_paths.testing_cache)))
690
691 if test_env.MSVCRT then
692 test_env.run.luarocks_nocov(C("config", "variables.MSVCRT", Q(test_env.MSVCRT), Q("--tree=" .. testing_paths.testing_cache)))
693 end
673 694
674 for _, rock in ipairs(rocks) do 695 for _, rock in ipairs(rocks) do
675 local only_server = "--only-server=" .. testing_paths.testing_cache 696 local only_server = "--only-server=" .. testing_paths.testing_cache
@@ -782,6 +803,25 @@ function test_env.unload_luarocks()
782 end 803 end
783end 804end
784 805
806--- Gets the C Run Time of the Lua interpreter built by mingw-w64 on ci-windows.
807-- Returns the MSVCRT on success
808-- Returns nil on failure
809local function get_MSVCRT(variables)
810 if not (test_env.CI_WINDOWS and test_env.MINGW) then return nil end
811 local pe_parser_path = dir_path(test_env.testing_paths.src_dir, '..', 'win32', 'pe-parser.lua')
812 local print_arch_script = "\"" ..
813 "local pe = assert(loadfile([[" .. pe_parser_path .. "]]))();" ..
814 "local rt, _ = pe.msvcrt([[" .. test_env.testing_paths.lua .. "]]);" ..
815 "print(rt or 'nil');" ..
816 "\""
817 local cmd = C(test_env.testing_paths.lua, "-e", print_arch_script)
818 local output = execute_output(cmd, false, variables)
819 if output == 'nil' then
820 output = nil
821 end
822 return output
823end
824
785local function get_luarocks_platform(variables) 825local function get_luarocks_platform(variables)
786 local print_arch_script = "\"" .. 826 local print_arch_script = "\"" ..
787 "cfg = require('luarocks.core.cfg');" .. 827 "cfg = require('luarocks.core.cfg');" ..
@@ -1106,6 +1146,12 @@ function test_env.main()
1106 end 1146 end
1107 assert(test_env.run.luarocks_nocov(C("config", "variables.OPENSSL_INCDIR", Q(test_env.OPENSSL_INCDIR)), env_vars)) 1147 assert(test_env.run.luarocks_nocov(C("config", "variables.OPENSSL_INCDIR", Q(test_env.OPENSSL_INCDIR)), env_vars))
1108 assert(test_env.run.luarocks_nocov(C("config", "variables.OPENSSL_LIBDIR", Q(test_env.OPENSSL_LIBDIR)), env_vars)) 1148 assert(test_env.run.luarocks_nocov(C("config", "variables.OPENSSL_LIBDIR", Q(test_env.OPENSSL_LIBDIR)), env_vars))
1149 if test_env.CI_WINDOWS and test_env.MINGW then
1150 assert(test_env.run.luarocks_nocov(C("config", "variables.ZLIB_INCDIR", Q(test_env.ZLIB_INCDIR)), env_vars))
1151 assert(test_env.run.luarocks_nocov(C("config", "variables.ZLIB_LIBDIR", Q(test_env.ZLIB_LIBDIR)), env_vars))
1152 assert(test_env.run.luarocks_nocov(C("config", "variables.BZ2_INCDIR", Q(test_env.BZ2_INCDIR)), env_vars))
1153 assert(test_env.run.luarocks_nocov(C("config", "variables.BZ2_LIBDIR", Q(test_env.BZ2_LIBDIR)), env_vars))
1154 end
1109 end 1155 end
1110 1156
1111 -- luacov is needed for both minimal or full environment 1157 -- luacov is needed for both minimal or full environment
@@ -1152,6 +1198,7 @@ function test_env.setup_specs(extra_rocks, use_mock)
1152 package.path = variables.LUA_PATH 1198 package.path = variables.LUA_PATH
1153 package.cpath = variables.LUA_CPATH 1199 package.cpath = variables.LUA_CPATH
1154 1200
1201 test_env.MSVCRT = get_MSVCRT(test_env.env_variables)
1155 test_env.platform = get_luarocks_platform(test_env.env_variables) 1202 test_env.platform = get_luarocks_platform(test_env.env_variables)
1156 test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or "" 1203 test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or ""
1157 test_env.setup_done = true 1204 test_env.setup_done = true
@@ -1186,6 +1233,7 @@ test_env.exists = exists
1186test_env.V = V 1233test_env.V = V
1187test_env.Q = Q 1234test_env.Q = Q
1188test_env.P = P 1235test_env.P = P
1236test_env.MSVCRT = get_MSVCRT(test_env.env_variables)
1189test_env.platform = get_luarocks_platform(test_env.env_variables) 1237test_env.platform = get_luarocks_platform(test_env.env_variables)
1190 1238
1191return test_env 1239return test_env