diff options
| author | George Roman <george.roman.99@gmail.com> | 2018-05-24 09:46:33 +0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-05-28 14:16:08 -0300 |
| commit | 0e8089c20e43e92e9351a71e92396b83faf23632 (patch) | |
| tree | 3c8544c9c5f8bc4f48eea9f234e132a71206bd8a /spec/util/test_env.lua | |
| parent | 4ac4aad3bf7e37c6e1467f1885036850f903d70c (diff) | |
| download | luarocks-0e8089c20e43e92e9351a71e92396b83faf23632.tar.gz luarocks-0e8089c20e43e92e9351a71e92396b83faf23632.tar.bz2 luarocks-0e8089c20e43e92e9351a71e92396b83faf23632.zip | |
Make the mock server run on Windows
Diffstat (limited to 'spec/util/test_env.lua')
| -rw-r--r-- | spec/util/test_env.lua | 26 |
1 files changed, 21 insertions, 5 deletions
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 | |||
| 764 | function test_env.mock_server_init() | 768 | function 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) |
| 770 | end | 782 | end |
| 771 | 783 | ||
| 772 | function test_env.mock_server_done() | 784 | function 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 | ||
| 774 | end | 790 | end |
| 775 | 791 | ||
| 776 | --- | 792 | --- |
