aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Roman <george.roman.99@gmail.com>2018-05-24 09:46:33 +0300
committerHisham Muhammad <hisham@gobolinux.org>2018-05-28 14:16:08 -0300
commit0e8089c20e43e92e9351a71e92396b83faf23632 (patch)
tree3c8544c9c5f8bc4f48eea9f234e132a71206bd8a
parent4ac4aad3bf7e37c6e1467f1885036850f903d70c (diff)
downloadluarocks-0e8089c20e43e92e9351a71e92396b83faf23632.tar.gz
luarocks-0e8089c20e43e92e9351a71e92396b83faf23632.tar.bz2
luarocks-0e8089c20e43e92e9351a71e92396b83faf23632.zip
Make the mock server run on Windows
-rw-r--r--appveyor.yml2
-rw-r--r--spec/util/mock-server.lua2
-rw-r--r--spec/util/test_env.lua26
3 files changed, 23 insertions, 7 deletions
diff --git a/appveyor.yml b/appveyor.yml
index 87e49122..33d1033b 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -46,7 +46,7 @@ build_script:
46 - luarocks install cluacov 1> NUL 2> NUL 46 - luarocks install cluacov 1> NUL 2> NUL
47 47
48test_script: 48test_script:
49 - busted -o gtest -v --lpath=.//?.lua --exclude-tags=ssh,unix,mock -Xhelper lua_dir=%CD%\lua_install,appveyor,%COMPILER% 49 - busted -o gtest -v --lpath=.//?.lua --exclude-tags=ssh,unix -Xhelper lua_dir=%CD%\lua_install,appveyor,%COMPILER%
50 50
51after_test: 51after_test:
52 - pip install codecov 52 - pip install codecov
diff --git a/spec/util/mock-server.lua b/spec/util/mock-server.lua
index ae41b964..8e498d57 100644
--- a/spec/util/mock-server.lua
+++ b/spec/util/mock-server.lua
@@ -71,7 +71,7 @@ server:add_resource("/file/{name:[^/]+}", {
71 produces = "text/plain", 71 produces = "text/plain",
72 handler = function(query, name) 72 handler = function(query, name)
73 local basedir = arg[1] or "./spec/fixtures" 73 local basedir = arg[1] or "./spec/fixtures"
74 local fd = io.open(basedir .. "/" .. name, "r") 74 local fd = io.open(basedir .. "/" .. name, "rb")
75 if not fd then 75 if not fd then
76 return restserver.response():status(404) 76 return restserver.response():status(404)
77 end 77 end
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index f55fb53a..48914311 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -380,8 +380,12 @@ local function create_env(testing_paths)
380 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" 380 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;"
381 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" 381 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;"
382 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" 382 env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;"
383 env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" 383 local lib_extension = "so"
384 .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" 384 if test_env.TEST_TARGET_OS == "windows" then
385 lib_extension = "dll"
386 end
387 env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. lib_extension .. ";"
388 .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. lib_extension .. ";"
385 env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" 389 env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;"
386 390
387 return env_variables 391 return env_variables
@@ -764,13 +768,25 @@ end
764function test_env.mock_server_init() 768function test_env.mock_server_init()
765 local testing_paths = test_env.testing_paths 769 local testing_paths = test_env.testing_paths
766 assert(test_env.need_rock("restserver-xavante")) 770 assert(test_env.need_rock("restserver-xavante"))
767 local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua " .. testing_paths.fixtures_dir .. " &", true, test_env.env_variables) 771 local final_command
772 local sleep_command
773 if test_env.TEST_TARGET_OS == "windows" then
774 final_command = test_env.execute_helper("start /b \"\" " .. Q(testing_paths.lua) .. " " .. Q(testing_paths.util_dir .. "/mock-server.lua") .. " " .. Q(testing_paths.fixtures_dir), true, test_env.env_variables)
775 sleep_command = "timeout 1 > NUL"
776 else
777 final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua " .. testing_paths.fixtures_dir .. " &", true, test_env.env_variables)
778 sleep_command = "sleep 1"
779 end
768 os.execute(final_command) 780 os.execute(final_command)
769 os.execute("sleep 1") 781 os.execute(sleep_command)
770end 782end
771 783
772function test_env.mock_server_done() 784function test_env.mock_server_done()
773 os.execute("curl localhost:8080/shutdown") 785 if test_env.TEST_TARGET_OS == "windows" then
786 os.execute(Q(test_env.testing_paths.win_tools .. "/wget") .. " --quiet --timeout=5 --tries=1 localhost:8080/shutdown")
787 else
788 os.execute("curl localhost:8080/shutdown")
789 end
774end 790end
775 791
776--- 792---