aboutsummaryrefslogtreecommitdiff
path: root/spec/util
diff options
context:
space:
mode:
Diffstat (limited to 'spec/util')
-rw-r--r--spec/util/test_env.lua75
1 files changed, 42 insertions, 33 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index 48914311..b3b9bb77 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -317,12 +317,12 @@ end
317-- @param save_path string: path to directory, where to download rocks/rockspecs 317-- @param save_path string: path to directory, where to download rocks/rockspecs
318-- @return make_manifest boolean: true if new rocks downloaded 318-- @return make_manifest boolean: true if new rocks downloaded
319local function download_rocks(urls, save_path) 319local function download_rocks(urls, save_path)
320 local luarocks_repo = "https://luarocks.org" 320 local luarocks_repo = "https://luarocks.org/"
321 local make_manifest = false 321 local make_manifest = false
322 322
323 for _, url in ipairs(urls) do 323 for _, url in ipairs(urls) do
324 -- check if already downloaded 324 -- check if already downloaded
325 if not test_env.exists(save_path .. url) then 325 if not test_env.exists(save_path .. "/" .. url) then
326 if test_env.TEST_TARGET_OS == "windows" then 326 if test_env.TEST_TARGET_OS == "windows" then
327 assert(execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate")) 327 assert(execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate"))
328 else 328 else
@@ -442,6 +442,14 @@ local function make_run_functions()
442 } 442 }
443end 443end
444 444
445local function move_file(src, dst)
446 if test_env.TEST_TARGET_OS == "windows" then
447 execute_bool(test_env.testing_paths.win_tools .. "/mv " .. src .. " " .. dst)
448 else
449 execute_bool("mv " .. src .. " " .. dst)
450 end
451end
452
445--- Rebuild environment. 453--- Rebuild environment.
446-- Remove old installed rocks and install new ones, 454-- Remove old installed rocks and install new ones,
447-- updating manifests and tree copies. 455-- updating manifests and tree copies.
@@ -461,13 +469,9 @@ local function build_environment(rocks, env_variables)
461 469
462 for _, rock in ipairs(rocks) do 470 for _, rock in ipairs(rocks) do
463 if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables) then 471 if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables) then
464 test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock) .. "", env_variables) 472 test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables)
465 test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) 473 test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables)
466 if test_env.TEST_TARGET_OS == "windows" then 474 move_file(rock .. "-*.rock", testing_paths.testing_cache)
467 execute_bool(testing_paths.win_tools .. "/mv " .. rock .. "-*.rock " .. testing_paths.testing_cache)
468 else
469 execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache)
470 end
471 end 475 end
472 end 476 end
473 477
@@ -740,31 +744,6 @@ local function install_luarocks(install_env_vars)
740 print("LuaRocks installed correctly!") 744 print("LuaRocks installed correctly!")
741end 745end
742 746
743function test_env.mock_server_extra_rocks(more)
744 local rocks = {
745 -- rocks needed for mock-server
746 "/copas-2.0.1-1.src.rock",
747 "/coxpcall-1.16.0-1.src.rock",
748 "/dkjson-2.5-2.src.rock",
749 "/luafilesystem-1.6.3-1.src.rock",
750 "/luasec-0.6-1.rockspec",
751 "/luasocket-3.0rc1-2.src.rock",
752 "/luasocket-3.0rc1-2.rockspec",
753 "/restserver-0.1-1.src.rock",
754 "/restserver-xavante-0.2-1.src.rock",
755 "/rings-1.3.0-1.src.rock",
756 "/wsapi-1.6.1-1.src.rock",
757 "/wsapi-xavante-1.6.1-1.src.rock",
758 "/xavante-2.4.0-1.src.rock"
759 }
760 if more then
761 for _, rock in ipairs(more) do
762 table.insert(rocks, rock)
763 end
764 end
765 return rocks
766end
767
768function test_env.mock_server_init() 747function test_env.mock_server_init()
769 local testing_paths = test_env.testing_paths 748 local testing_paths = test_env.testing_paths
770 assert(test_env.need_rock("restserver-xavante")) 749 assert(test_env.need_rock("restserver-xavante"))
@@ -789,6 +768,33 @@ function test_env.mock_server_done()
789 end 768 end
790end 769end
791 770
771local function prepare_mock_server_binary_rocks()
772 local testing_paths = test_env.testing_paths
773
774 local rocks = {
775 -- rocks needed for mock-server
776 "luasocket-3.0rc1-2.src.rock",
777 "coxpcall-1.16.0-1.src.rock",
778 "copas-2.0.1-1.src.rock",
779 "luafilesystem-1.7.0-2.src.rock",
780 "xavante-2.4.0-1.src.rock",
781 "wsapi-1.6.1-1.src.rock",
782 "rings-1.3.0-1.src.rock",
783 "wsapi-xavante-1.6.1-1.src.rock",
784 "dkjson-2.5-2.src.rock",
785 "restserver-0.1-1.src.rock",
786 "restserver-xavante-0.2-1.src.rock",
787 }
788 download_rocks(rocks, testing_paths.testing_server)
789 for _, rock in ipairs(rocks) do
790 test_env.run.luarocks_nocov("build " .. Q(testing_paths.testing_server .. "/" .. rock) .. " --tree=" .. testing_paths.testing_cache)
791 local rockname = rock:gsub("%-[^-]+%-%d+%.[%a.]+$", "")
792 test_env.run.luarocks_nocov("pack " .. rockname .. " --tree=" .. testing_paths.testing_cache)
793 move_file(rockname .. "-*.rock", testing_paths.testing_server)
794 end
795 test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_server))
796end
797
792--- 798---
793-- Main function to create config files and testing environment 799-- Main function to create config files and testing environment
794function test_env.main() 800function test_env.main()
@@ -837,7 +843,10 @@ function test_env.main()
837 -- Download rocks needed for LuaRocks testing environment 843 -- Download rocks needed for LuaRocks testing environment
838 lfs.mkdir(testing_paths.testing_server) 844 lfs.mkdir(testing_paths.testing_server)
839 download_rocks(urls, testing_paths.testing_server) 845 download_rocks(urls, testing_paths.testing_server)
846
840 build_environment(rocks, install_env_vars) 847 build_environment(rocks, install_env_vars)
848
849 prepare_mock_server_binary_rocks()
841end 850end
842 851
843test_env.set_lua_version() 852test_env.set_lua_version()