diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-01-08 16:26:48 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-01-08 16:26:48 -0200 |
| commit | d80124af9cd929b395b4d4c353b51ccc902a3f9e (patch) | |
| tree | a738a509039b286697819db762916cfda0384413 /test | |
| parent | 98a0bd9a97190be8ba10f14a3d67e42de827b04a (diff) | |
| download | luarocks-d80124af9cd929b395b4d4c353b51ccc902a3f9e.tar.gz luarocks-d80124af9cd929b395b4d4c353b51ccc902a3f9e.tar.bz2 luarocks-d80124af9cd929b395b4d4c353b51ccc902a3f9e.zip | |
Reorganize test suite files
Diffstat (limited to 'test')
26 files changed, 0 insertions, 1182 deletions
diff --git a/test/luarocks_site.lua b/test/luarocks_site.lua deleted file mode 100644 index cfa77dca..00000000 --- a/test/luarocks_site.lua +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | -- Config file of LuaRocks site for tests | ||
| 2 | upload = { | ||
| 3 | server = "http://localhost:8080", | ||
| 4 | tool_version = "1.0.0", | ||
| 5 | api_version = "1", | ||
| 6 | } \ No newline at end of file | ||
diff --git a/test/mock-server.lua b/test/mock-server.lua deleted file mode 100644 index dbbdea2c..00000000 --- a/test/mock-server.lua +++ /dev/null | |||
| @@ -1,97 +0,0 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | |||
| 3 | --- A simple LuaRocks mock-server for testing. | ||
| 4 | local restserver = require("restserver") | ||
| 5 | local server = restserver:new():port(8080) | ||
| 6 | |||
| 7 | server:add_resource("api/tool_version", { | ||
| 8 | { | ||
| 9 | method = "GET", | ||
| 10 | path = "/", | ||
| 11 | produces = "application/json", | ||
| 12 | handler = function(query) | ||
| 13 | local json = { version = query.current } | ||
| 14 | return restserver.response():status(200):entity(json) | ||
| 15 | end | ||
| 16 | } | ||
| 17 | }) | ||
| 18 | |||
| 19 | server:add_resource("api/1/{id:[0-9]+}/status", { | ||
| 20 | { | ||
| 21 | method = "GET", | ||
| 22 | path = "/", | ||
| 23 | produces = "application/json", | ||
| 24 | handler = function(query) | ||
| 25 | local json = { user_id = "123", created_at = "29.1.1993" } | ||
| 26 | return restserver.response():status(200):entity(json) | ||
| 27 | end | ||
| 28 | } | ||
| 29 | }) | ||
| 30 | |||
| 31 | server:add_resource("/api/1/{id:[0-9]+}/check_rockspec", { | ||
| 32 | { | ||
| 33 | method = "GET", | ||
| 34 | path = "/", | ||
| 35 | produces = "application/json", | ||
| 36 | handler = function(query) | ||
| 37 | local json = {} | ||
| 38 | return restserver.response():status(200):entity(json) | ||
| 39 | end | ||
| 40 | } | ||
| 41 | }) | ||
| 42 | |||
| 43 | server:add_resource("/api/1/{id:[0-9]+}/upload", { | ||
| 44 | { | ||
| 45 | method = "POST", | ||
| 46 | path = "/", | ||
| 47 | produces = "application/json", | ||
| 48 | handler = function(query) | ||
| 49 | local json = {module = "luasocket", version = {id = "1.0"}, module_url = "http://localhost/luasocket", manifests = "root", is_new = "is_new"} | ||
| 50 | return restserver.response():status(200):entity(json) | ||
| 51 | end | ||
| 52 | } | ||
| 53 | }) | ||
| 54 | |||
| 55 | server:add_resource("/api/1/{id:[0-9]+}/upload_rock/{id:[0-9]+}", { | ||
| 56 | { | ||
| 57 | method = "POST", | ||
| 58 | path = "/", | ||
| 59 | produces = "application/json", | ||
| 60 | handler = function(query) | ||
| 61 | local json = {"rock","module_url"} | ||
| 62 | return restserver.response():status(200):entity(json) | ||
| 63 | end | ||
| 64 | } | ||
| 65 | }) | ||
| 66 | |||
| 67 | server:add_resource("/file/{name:[^/]+}", { | ||
| 68 | { | ||
| 69 | method = "GET", | ||
| 70 | path = "/", | ||
| 71 | produces = "text/plain", | ||
| 72 | handler = function(query, name) | ||
| 73 | local fd = io.open("test/testfiles/"..name, "r") | ||
| 74 | if not fd then | ||
| 75 | return restserver.response():status(404) | ||
| 76 | end | ||
| 77 | local data = fd:read("*a") | ||
| 78 | fd:close() | ||
| 79 | return restserver.response():status(200):entity(data) | ||
| 80 | end | ||
| 81 | } | ||
| 82 | }) | ||
| 83 | |||
| 84 | -- SHUTDOWN this mock-server | ||
| 85 | server:add_resource("/shutdown", { | ||
| 86 | { | ||
| 87 | method = "GET", | ||
| 88 | path = "/", | ||
| 89 | handler = function(query) | ||
| 90 | os.exit() | ||
| 91 | return restserver.response():status(200):entity() | ||
| 92 | end | ||
| 93 | } | ||
| 94 | }) | ||
| 95 | |||
| 96 | -- This loads the restserver.xavante plugin | ||
| 97 | server:enable("restserver.xavante"):start() \ No newline at end of file | ||
diff --git a/test/test_environment.lua b/test/test_environment.lua deleted file mode 100644 index d347fa59..00000000 --- a/test/test_environment.lua +++ /dev/null | |||
| @@ -1,781 +0,0 @@ | |||
| 1 | local lfs = require("lfs") | ||
| 2 | local test_env = {} | ||
| 3 | |||
| 4 | local help_message = [[ | ||
| 5 | LuaRocks test-suite | ||
| 6 | |||
| 7 | INFORMATION | ||
| 8 | New test-suite for LuaRocks project, using unit testing framework Busted. | ||
| 9 | REQUIREMENTS | ||
| 10 | Be sure sshd is running on your system, or use '--exclude-tags=ssh', | ||
| 11 | to not execute tests which require sshd. | ||
| 12 | USAGE | ||
| 13 | busted [-Xhelper <arguments>] | ||
| 14 | ARGUMENTS | ||
| 15 | env=<type> Set type of environment to use ("minimal" or "full", | ||
| 16 | default: "minimal"). | ||
| 17 | noreset Don't reset environment after each test | ||
| 18 | clean Remove existing testing environment. | ||
| 19 | travis Add if running on TravisCI. | ||
| 20 | appveyor Add if running on Appveyor. | ||
| 21 | os=<type> Set OS ("linux", "osx", or "windows"). | ||
| 22 | lua_dir=<path> Path of Lua installation (default "/usr/local") | ||
| 23 | lua_interpreter=<lua> Name of the interpreter (default "lua") | ||
| 24 | ]] | ||
| 25 | |||
| 26 | local function help() | ||
| 27 | print(help_message) | ||
| 28 | os.exit(1) | ||
| 29 | end | ||
| 30 | |||
| 31 | local function title(str) | ||
| 32 | print() | ||
| 33 | print(("-"):rep(#str)) | ||
| 34 | print(str) | ||
| 35 | print(("-"):rep(#str)) | ||
| 36 | end | ||
| 37 | |||
| 38 | function test_env.exists(path) | ||
| 39 | return lfs.attributes(path, "mode") ~= nil | ||
| 40 | end | ||
| 41 | |||
| 42 | --- Quote argument for shell processing. Fixes paths on Windows. | ||
| 43 | -- Adds double quotes and escapes. Based on function in fs/win32.lua. | ||
| 44 | -- @param arg string: Unquoted argument. | ||
| 45 | -- @return string: Quoted argument. | ||
| 46 | local function Q(arg) | ||
| 47 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 48 | local drive_letter = "[%.a-zA-Z]?:?[\\/]" | ||
| 49 | -- Quote DIR for Windows | ||
| 50 | if arg:match("^"..drive_letter) then | ||
| 51 | arg = arg:gsub("/", "\\") | ||
| 52 | end | ||
| 53 | |||
| 54 | if arg == "\\" then | ||
| 55 | return '\\' -- CHDIR needs special handling for root dir | ||
| 56 | end | ||
| 57 | |||
| 58 | return '"' .. arg .. '"' | ||
| 59 | else | ||
| 60 | return "'" .. arg:gsub("'", "'\\''") .. "'" | ||
| 61 | end | ||
| 62 | end | ||
| 63 | |||
| 64 | function test_env.quiet(command) | ||
| 65 | if not test_env.VERBOSE then | ||
| 66 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 67 | return command .. " 1> NUL 2> NUL" | ||
| 68 | else | ||
| 69 | return command .. " 1> /dev/null 2> /dev/null" | ||
| 70 | end | ||
| 71 | else | ||
| 72 | return command | ||
| 73 | end | ||
| 74 | end | ||
| 75 | |||
| 76 | function test_env.copy(source, destination) | ||
| 77 | local r_source, err = io.open(source, "r") | ||
| 78 | local r_destination, err = io.open(destination, "w") | ||
| 79 | |||
| 80 | while true do | ||
| 81 | local block = r_source:read(8192) | ||
| 82 | if not block then break end | ||
| 83 | r_destination:write(block) | ||
| 84 | end | ||
| 85 | |||
| 86 | r_source:close() | ||
| 87 | r_destination:close() | ||
| 88 | end | ||
| 89 | |||
| 90 | --- Helper function for execute_bool and execute_output | ||
| 91 | -- @param command string: command to execute | ||
| 92 | -- @param print_command boolean: print command if 'true' | ||
| 93 | -- @param env_variables table: table of environment variables to export {FOO="bar", BAR="foo"} | ||
| 94 | -- @return final_command string: concatenated command to execution | ||
| 95 | function test_env.execute_helper(command, print_command, env_variables) | ||
| 96 | local final_command = "" | ||
| 97 | |||
| 98 | if print_command then | ||
| 99 | print("[EXECUTING]: " .. command) | ||
| 100 | end | ||
| 101 | |||
| 102 | if env_variables then | ||
| 103 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 104 | for k,v in pairs(env_variables) do | ||
| 105 | final_command = final_command .. "set " .. k .. "=" .. v .. "&" | ||
| 106 | end | ||
| 107 | final_command = final_command:sub(1, -2) .. "&" | ||
| 108 | else | ||
| 109 | final_command = "export " | ||
| 110 | for k,v in pairs(env_variables) do | ||
| 111 | final_command = final_command .. k .. "='" .. v .. "' " | ||
| 112 | end | ||
| 113 | -- remove last space and add ';' to separate exporting variables from command | ||
| 114 | final_command = final_command:sub(1, -2) .. "; " | ||
| 115 | end | ||
| 116 | end | ||
| 117 | |||
| 118 | final_command = final_command .. command .. " 2>&1" | ||
| 119 | |||
| 120 | return final_command | ||
| 121 | end | ||
| 122 | |||
| 123 | --- Execute command and returns true/false | ||
| 124 | -- @return true/false boolean: status of the command execution | ||
| 125 | local function execute_bool(command, print_command, env_variables) | ||
| 126 | command = test_env.execute_helper(command, print_command, env_variables) | ||
| 127 | |||
| 128 | local redirect_filename | ||
| 129 | local redirect = "" | ||
| 130 | if print_command ~= nil then | ||
| 131 | redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" | ||
| 132 | redirect = " > "..redirect_filename | ||
| 133 | os.remove(redirect_filename) | ||
| 134 | end | ||
| 135 | local ok = os.execute(command .. redirect) | ||
| 136 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | ||
| 137 | if redirect ~= "" then | ||
| 138 | if not ok then | ||
| 139 | local fd = io.open(redirect_filename, "r") | ||
| 140 | if fd then | ||
| 141 | print(fd:read("*a")) | ||
| 142 | fd:close() | ||
| 143 | end | ||
| 144 | end | ||
| 145 | os.remove(redirect_filename) | ||
| 146 | end | ||
| 147 | return ok | ||
| 148 | end | ||
| 149 | |||
| 150 | --- Execute command and returns output of command | ||
| 151 | -- @return output string: output the command execution | ||
| 152 | local function execute_output(command, print_command, env_variables) | ||
| 153 | command = test_env.execute_helper(command, print_command, env_variables) | ||
| 154 | |||
| 155 | local file = assert(io.popen(command)) | ||
| 156 | local output = file:read('*all') | ||
| 157 | file:close() | ||
| 158 | return output:gsub("\n","") -- output adding new line, need to be removed | ||
| 159 | end | ||
| 160 | |||
| 161 | --- Set test_env.LUA_V or test_env.LUAJIT_V based | ||
| 162 | -- on version of Lua used to run this script. | ||
| 163 | function test_env.set_lua_version() | ||
| 164 | if _G.jit then | ||
| 165 | test_env.LUAJIT_V = _G.jit.version:match("(2%.%d)%.%d") | ||
| 166 | test_env.lua_version = "5.1" | ||
| 167 | else | ||
| 168 | test_env.LUA_V = _VERSION:match("5%.%d") | ||
| 169 | test_env.lua_version = test_env.LUA_V | ||
| 170 | end | ||
| 171 | end | ||
| 172 | |||
| 173 | --- Set all arguments from input into global variables | ||
| 174 | function test_env.set_args() | ||
| 175 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | ||
| 176 | test_env.TYPE_TEST_ENV = "minimal" | ||
| 177 | test_env.OPENSSL_DIRS = "" | ||
| 178 | test_env.RESET_ENV = true | ||
| 179 | |||
| 180 | for _, argument in ipairs(arg) do | ||
| 181 | if argument:find("^env=") then | ||
| 182 | test_env.TYPE_TEST_ENV = argument:match("^env=(.*)$") | ||
| 183 | elseif argument == "noreset" then | ||
| 184 | test_env.RESET_ENV = false | ||
| 185 | elseif argument == "clean" then | ||
| 186 | test_env.TEST_ENV_CLEAN = true | ||
| 187 | elseif argument == "verbose" then | ||
| 188 | test_env.VERBOSE = true | ||
| 189 | elseif argument == "travis" then | ||
| 190 | test_env.TRAVIS = true | ||
| 191 | elseif argument == "appveyor" then | ||
| 192 | test_env.APPVEYOR = true | ||
| 193 | test_env.OPENSSL_DIRS = "OPENSSL_LIBDIR=C:\\OpenSSL-Win32\\lib OPENSSL_INCDIR=C:\\OpenSSL-Win32\\include" | ||
| 194 | elseif argument:find("^os=") then | ||
| 195 | test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") | ||
| 196 | elseif argument == "mingw" then | ||
| 197 | test_env.MINGW = true | ||
| 198 | elseif argument == "vs" then | ||
| 199 | test_env.MINGW = false | ||
| 200 | elseif argument:find("^lua_dir=") then | ||
| 201 | test_env.LUA_DIR = argument:match("^lua_dir=(.*)$") | ||
| 202 | elseif argument:find("^lua_interpreter=") then | ||
| 203 | test_env.LUA_INTERPRETER = argument:match("^lua_interpreter=(.*)$") | ||
| 204 | else | ||
| 205 | help() | ||
| 206 | end | ||
| 207 | end | ||
| 208 | |||
| 209 | if not test_env.TEST_TARGET_OS then | ||
| 210 | title("OS CHECK") | ||
| 211 | |||
| 212 | if execute_bool("sw_vers") then | ||
| 213 | test_env.TEST_TARGET_OS = "osx" | ||
| 214 | if test_env.TRAVIS then | ||
| 215 | test_env.OPENSSL_DIRS = "OPENSSL_LIBDIR=/usr/local/opt/openssl/lib OPENSSL_INCDIR=/usr/local/opt/openssl/include" | ||
| 216 | end | ||
| 217 | elseif execute_output("uname -s") == "Linux" then | ||
| 218 | test_env.TEST_TARGET_OS = "linux" | ||
| 219 | else | ||
| 220 | test_env.TEST_TARGET_OS = "windows" | ||
| 221 | end | ||
| 222 | end | ||
| 223 | return true | ||
| 224 | end | ||
| 225 | |||
| 226 | function test_env.copy_dir(source_path, target_path) | ||
| 227 | local testing_paths = test_env.testing_paths | ||
| 228 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 229 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) | ||
| 230 | else | ||
| 231 | execute_bool("cp -a ".. source_path .. "/. " .. target_path) | ||
| 232 | end | ||
| 233 | end | ||
| 234 | |||
| 235 | --- Remove directory recursively | ||
| 236 | -- @param path string: directory path to delete | ||
| 237 | function test_env.remove_dir(path) | ||
| 238 | if test_env.exists(path) then | ||
| 239 | for file in lfs.dir(path) do | ||
| 240 | if file ~= "." and file ~= ".." then | ||
| 241 | local full_path = path..'/'..file | ||
| 242 | |||
| 243 | if lfs.attributes(full_path, "mode") == "directory" then | ||
| 244 | test_env.remove_dir(full_path) | ||
| 245 | else | ||
| 246 | os.remove(full_path) | ||
| 247 | end | ||
| 248 | end | ||
| 249 | end | ||
| 250 | end | ||
| 251 | lfs.rmdir(path) | ||
| 252 | end | ||
| 253 | |||
| 254 | --- Remove subdirectories of a directory that match a pattern | ||
| 255 | -- @param path string: path to directory | ||
| 256 | -- @param pattern string: pattern matching basenames of subdirectories to be removed | ||
| 257 | function test_env.remove_subdirs(path, pattern) | ||
| 258 | if test_env.exists(path) then | ||
| 259 | for file in lfs.dir(path) do | ||
| 260 | if file ~= "." and file ~= ".." then | ||
| 261 | local full_path = path..'/'..file | ||
| 262 | |||
| 263 | if lfs.attributes(full_path, "mode") == "directory" and file:find(pattern) then | ||
| 264 | test_env.remove_dir(full_path) | ||
| 265 | end | ||
| 266 | end | ||
| 267 | end | ||
| 268 | end | ||
| 269 | end | ||
| 270 | |||
| 271 | --- Remove files matching a pattern | ||
| 272 | -- @param path string: directory where to delete files | ||
| 273 | -- @param pattern string: pattern matching basenames of files to be deleted | ||
| 274 | -- @return result_check boolean: true if one or more files deleted | ||
| 275 | function test_env.remove_files(path, pattern) | ||
| 276 | local result_check = false | ||
| 277 | if test_env.exists(path) then | ||
| 278 | for file in lfs.dir(path) do | ||
| 279 | if file ~= "." and file ~= ".." then | ||
| 280 | if file:find(pattern) then | ||
| 281 | if os.remove(path .. "/" .. file) then | ||
| 282 | result_check = true | ||
| 283 | end | ||
| 284 | end | ||
| 285 | end | ||
| 286 | end | ||
| 287 | end | ||
| 288 | return result_check | ||
| 289 | end | ||
| 290 | |||
| 291 | |||
| 292 | --- Function for downloading rocks and rockspecs | ||
| 293 | -- @param urls table: array of full names of rocks/rockspecs to download | ||
| 294 | -- @param save_path string: path to directory, where to download rocks/rockspecs | ||
| 295 | -- @return make_manifest boolean: true if new rocks downloaded | ||
| 296 | local function download_rocks(urls, save_path) | ||
| 297 | local luarocks_repo = "https://luarocks.org" | ||
| 298 | local make_manifest = false | ||
| 299 | |||
| 300 | for _, url in ipairs(urls) do | ||
| 301 | -- check if already downloaded | ||
| 302 | if not test_env.exists(save_path .. url) then | ||
| 303 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 304 | execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate") | ||
| 305 | else | ||
| 306 | execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) | ||
| 307 | end | ||
| 308 | make_manifest = true | ||
| 309 | end | ||
| 310 | end | ||
| 311 | return make_manifest | ||
| 312 | end | ||
| 313 | |||
| 314 | --- Create a file containing a string. | ||
| 315 | -- @param path string: path to file. | ||
| 316 | -- @param str string: content of the file. | ||
| 317 | local function write_file(path, str) | ||
| 318 | local file = assert(io.open(path, "w")) | ||
| 319 | file:write(str) | ||
| 320 | file:close() | ||
| 321 | end | ||
| 322 | |||
| 323 | --- Create md5sum of directory structure recursively, based on filename and size | ||
| 324 | -- @param path string: path to directory for generate md5sum | ||
| 325 | -- @return md5sum string: md5sum of directory | ||
| 326 | local function hash_environment(path) | ||
| 327 | if test_env.TEST_TARGET_OS == "linux" then | ||
| 328 | return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") | ||
| 329 | elseif test_env.TEST_TARGET_OS == "osx" then | ||
| 330 | return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") | ||
| 331 | elseif test_env.TEST_TARGET_OS == "windows" then | ||
| 332 | return execute_output("\"" .. Q(test_env.testing_paths.win_tools .. "/find") .. " " .. Q(path) | ||
| 333 | .. " -printf \"%s %p\"\" > temp_sum.txt && certUtil -hashfile temp_sum.txt && del temp_sum.txt") | ||
| 334 | end | ||
| 335 | end | ||
| 336 | |||
| 337 | --- Create environment variables needed for tests | ||
| 338 | -- @param testing_paths table: table with paths to testing directory | ||
| 339 | -- @return env_variables table: table with created environment variables | ||
| 340 | local function create_env(testing_paths) | ||
| 341 | local luaversion_short = _VERSION:gsub("Lua ", "") | ||
| 342 | |||
| 343 | if test_env.LUAJIT_V then | ||
| 344 | luaversion_short="5.1" | ||
| 345 | end | ||
| 346 | |||
| 347 | local env_variables = {} | ||
| 348 | env_variables.LUA_VERSION = luaversion_short | ||
| 349 | env_variables.LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config.lua" | ||
| 350 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 351 | env_variables.LUA_PATH = testing_paths.testing_lrprefix .. "\\lua\\?.lua;" | ||
| 352 | else | ||
| 353 | env_variables.LUA_PATH = testing_paths.testing_lrprefix .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
| 354 | end | ||
| 355 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
| 356 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | ||
| 357 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
| 358 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | ||
| 359 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" | ||
| 360 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | ||
| 361 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | ||
| 362 | env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" | ||
| 363 | |||
| 364 | return env_variables | ||
| 365 | end | ||
| 366 | |||
| 367 | --- Create md5sums of origin system and system-copy testing directory | ||
| 368 | -- @param testing_paths table: table with paths to testing directory | ||
| 369 | -- @return md5sums table: table of md5sums of system and system-copy testing directory | ||
| 370 | local function create_md5sums(testing_paths) | ||
| 371 | local md5sums = {} | ||
| 372 | md5sums.testing_tree_copy_md5 = hash_environment(testing_paths.testing_tree_copy) | ||
| 373 | md5sums.testing_sys_tree_copy_md5 = hash_environment(testing_paths.testing_sys_tree_copy) | ||
| 374 | |||
| 375 | return md5sums | ||
| 376 | end | ||
| 377 | |||
| 378 | local function make_run_function(cmd_name, exec_function, with_coverage, do_print) | ||
| 379 | local cmd_prefix = Q(test_env.testing_paths.lua) .. " " | ||
| 380 | |||
| 381 | if with_coverage then | ||
| 382 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " | ||
| 383 | end | ||
| 384 | |||
| 385 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 386 | cmd_prefix = cmd_prefix .. Q(test_env.testing_paths.testing_lrprefix .. "/" .. cmd_name .. ".lua") .. " " | ||
| 387 | else | ||
| 388 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | ||
| 389 | end | ||
| 390 | |||
| 391 | return function(cmd, new_vars) | ||
| 392 | local temp_vars = {} | ||
| 393 | for k, v in pairs(test_env.env_variables) do | ||
| 394 | temp_vars[k] = v | ||
| 395 | end | ||
| 396 | if new_vars then | ||
| 397 | for k, v in pairs(new_vars) do | ||
| 398 | temp_vars[k] = v | ||
| 399 | end | ||
| 400 | end | ||
| 401 | return exec_function(cmd_prefix .. cmd, do_print, temp_vars) | ||
| 402 | end | ||
| 403 | end | ||
| 404 | |||
| 405 | local function make_run_functions() | ||
| 406 | return { | ||
| 407 | luarocks = make_run_function("luarocks", execute_output, true, true), | ||
| 408 | luarocks_bool = make_run_function("luarocks", execute_bool, true, true), | ||
| 409 | luarocks_noprint = make_run_function("luarocks", execute_bool, true, false), | ||
| 410 | luarocks_nocov = make_run_function("luarocks", execute_bool, false, true), | ||
| 411 | luarocks_noprint_nocov = make_run_function("luarocks", execute_bool, false, false), | ||
| 412 | luarocks_admin = make_run_function("luarocks-admin", execute_output, true, true), | ||
| 413 | luarocks_admin_bool = make_run_function("luarocks-admin", execute_bool, true, true), | ||
| 414 | luarocks_admin_nocov = make_run_function("luarocks-admin", execute_bool, false, false) | ||
| 415 | } | ||
| 416 | end | ||
| 417 | |||
| 418 | --- Rebuild environment. | ||
| 419 | -- Remove old installed rocks and install new ones, | ||
| 420 | -- updating manifests and tree copies. | ||
| 421 | local function build_environment(rocks, env_variables) | ||
| 422 | title("BUILDING ENVIRONMENT") | ||
| 423 | local testing_paths = test_env.testing_paths | ||
| 424 | test_env.remove_dir(testing_paths.testing_tree) | ||
| 425 | test_env.remove_dir(testing_paths.testing_sys_tree) | ||
| 426 | test_env.remove_dir(testing_paths.testing_tree_copy) | ||
| 427 | test_env.remove_dir(testing_paths.testing_sys_tree_copy) | ||
| 428 | |||
| 429 | lfs.mkdir(testing_paths.testing_tree) | ||
| 430 | lfs.mkdir(testing_paths.testing_sys_tree) | ||
| 431 | |||
| 432 | test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_server)) | ||
| 433 | test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache)) | ||
| 434 | |||
| 435 | for _, rock in ipairs(rocks) do | ||
| 436 | 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 | ||
| 437 | test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock) .. "", env_variables) | ||
| 438 | test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) | ||
| 439 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 440 | execute_bool(testing_paths.win_tools .. "/mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | ||
| 441 | else | ||
| 442 | execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | ||
| 443 | end | ||
| 444 | end | ||
| 445 | end | ||
| 446 | |||
| 447 | test_env.copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) | ||
| 448 | test_env.copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) | ||
| 449 | end | ||
| 450 | |||
| 451 | --- Reset testing environment | ||
| 452 | local function reset_environment(testing_paths, md5sums) | ||
| 453 | local testing_tree_md5 = hash_environment(testing_paths.testing_tree) | ||
| 454 | local testing_sys_tree_md5 = hash_environment(testing_paths.testing_sys_tree) | ||
| 455 | |||
| 456 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then | ||
| 457 | test_env.remove_dir(testing_paths.testing_tree) | ||
| 458 | test_env.copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) | ||
| 459 | end | ||
| 460 | |||
| 461 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | ||
| 462 | test_env.remove_dir(testing_paths.testing_sys_tree) | ||
| 463 | test_env.copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) | ||
| 464 | end | ||
| 465 | end | ||
| 466 | |||
| 467 | local function create_paths(luaversion_full) | ||
| 468 | |||
| 469 | local testing_paths = {} | ||
| 470 | testing_paths.luadir = (test_env.LUA_DIR or "/usr/local") | ||
| 471 | testing_paths.lua = testing_paths.luadir .. "/bin/" .. (test_env.LUA_INTERPRETER or "lua") | ||
| 472 | |||
| 473 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 474 | testing_paths.luarocks_tmp = os.getenv("TEMP") | ||
| 475 | else | ||
| 476 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" | ||
| 477 | end | ||
| 478 | |||
| 479 | testing_paths.luarocks_dir = lfs.currentdir() | ||
| 480 | |||
| 481 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 482 | testing_paths.luarocks_dir = testing_paths.luarocks_dir:gsub("\\","/") | ||
| 483 | end | ||
| 484 | |||
| 485 | testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" | ||
| 486 | testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" | ||
| 487 | testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full | ||
| 488 | testing_paths.testing_tree = testing_paths.testing_dir .. "/testing-" .. luaversion_full | ||
| 489 | testing_paths.testing_tree_copy = testing_paths.testing_dir .. "/testing_copy-" .. luaversion_full | ||
| 490 | testing_paths.testing_sys_tree = testing_paths.testing_dir .. "/testing_sys-" .. luaversion_full | ||
| 491 | testing_paths.testing_sys_tree_copy = testing_paths.testing_dir .. "/testing_sys_copy-" .. luaversion_full | ||
| 492 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full | ||
| 493 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full | ||
| 494 | |||
| 495 | testing_paths.testing_rocks = testing_paths.testing_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version | ||
| 496 | testing_paths.testing_sys_rocks = testing_paths.testing_sys_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version | ||
| 497 | |||
| 498 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 499 | testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" | ||
| 500 | end | ||
| 501 | |||
| 502 | return testing_paths | ||
| 503 | end | ||
| 504 | |||
| 505 | --- Helper function to unload luarocks modules from global table package.loaded | ||
| 506 | -- Needed to load our local (testing) version of LuaRocks | ||
| 507 | function test_env.unload_luarocks() | ||
| 508 | for modname, _ in pairs(package.loaded) do | ||
| 509 | if modname:match("^luarocks%.") then | ||
| 510 | package.loaded[modname] = nil | ||
| 511 | end | ||
| 512 | end | ||
| 513 | end | ||
| 514 | |||
| 515 | --- Function for initially setup of environment, variables, md5sums for spec files | ||
| 516 | function test_env.setup_specs(extra_rocks) | ||
| 517 | -- if global variable about successful creation of testing environment doesn't exist, build environment | ||
| 518 | if not test_env.setup_done then | ||
| 519 | if test_env.TRAVIS then | ||
| 520 | if not test_env.exists(os.getenv("HOME") .. "/.ssh/id_rsa.pub") then | ||
| 521 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") | ||
| 522 | execute_bool("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") | ||
| 523 | execute_bool("chmod og-wx ~/.ssh/authorized_keys") | ||
| 524 | execute_bool("ssh-keyscan localhost >> ~/.ssh/known_hosts") | ||
| 525 | end | ||
| 526 | end | ||
| 527 | |||
| 528 | test_env.main() | ||
| 529 | package.path = test_env.env_variables.LUA_PATH | ||
| 530 | |||
| 531 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').arch)\"", false, test_env.env_variables) | ||
| 532 | test_env.lib_extension = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').lib_extension)\"", false, test_env.env_variables) | ||
| 533 | test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or "" | ||
| 534 | test_env.md5sums = create_md5sums(test_env.testing_paths) | ||
| 535 | test_env.setup_done = true | ||
| 536 | title("RUNNING TESTS") | ||
| 537 | end | ||
| 538 | |||
| 539 | if extra_rocks then | ||
| 540 | local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server) | ||
| 541 | if make_manifest then | ||
| 542 | test_env.run.luarocks_admin_nocov("make_manifest " .. test_env.testing_paths.testing_server) | ||
| 543 | end | ||
| 544 | end | ||
| 545 | |||
| 546 | if test_env.RESET_ENV then | ||
| 547 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | ||
| 548 | end | ||
| 549 | end | ||
| 550 | |||
| 551 | --- Test if required rock is installed and if not, install it. | ||
| 552 | -- Return `true` if the rock is already installed or has been installed successfully, | ||
| 553 | -- `false` if installation failed. | ||
| 554 | function test_env.need_rock(rock) | ||
| 555 | print("Check if " .. rock .. " is installed") | ||
| 556 | if test_env.run.luarocks_noprint_nocov(test_env.quiet("show " .. rock)) then | ||
| 557 | return true | ||
| 558 | else | ||
| 559 | return test_env.run.luarocks_noprint_nocov(test_env.quiet("install " .. rock)) | ||
| 560 | end | ||
| 561 | end | ||
| 562 | |||
| 563 | --- For each key-value pair in replacements table | ||
| 564 | -- replace %{key} in given string with value. | ||
| 565 | local function substitute(str, replacements) | ||
| 566 | return (str:gsub("%%%b{}", function(marker) | ||
| 567 | return replacements[marker:sub(3, -2)] | ||
| 568 | end)) | ||
| 569 | end | ||
| 570 | |||
| 571 | |||
| 572 | --- Create configs for luacov and several versions of Luarocks | ||
| 573 | -- configs needed for some tests. | ||
| 574 | local function create_configs() | ||
| 575 | -- testing_config.lua and testing_config_show_downloads.lua | ||
| 576 | local config_content = substitute([[ | ||
| 577 | rocks_trees = { | ||
| 578 | "%{testing_tree}", | ||
| 579 | { name = "system", root = "%{testing_sys_tree}" }, | ||
| 580 | } | ||
| 581 | rocks_servers = { | ||
| 582 | "%{testing_server}" | ||
| 583 | } | ||
| 584 | local_cache = "%{testing_cache}" | ||
| 585 | upload_server = "testing" | ||
| 586 | upload_user = "%{user}" | ||
| 587 | upload_servers = { | ||
| 588 | testing = { | ||
| 589 | rsync = "localhost/tmp/luarocks_testing", | ||
| 590 | }, | ||
| 591 | } | ||
| 592 | external_deps_dirs = { | ||
| 593 | "/usr/local", | ||
| 594 | "/usr", | ||
| 595 | -- These are used for a test that fails, so it | ||
| 596 | -- can point to invalid paths: | ||
| 597 | { | ||
| 598 | prefix = "/opt", | ||
| 599 | bin = "bin", | ||
| 600 | include = "include", | ||
| 601 | lib = { "lib", "lib64" }, | ||
| 602 | } | ||
| 603 | } | ||
| 604 | ]], { | ||
| 605 | user = os.getenv("USER"), | ||
| 606 | testing_sys_tree = test_env.testing_paths.testing_sys_tree, | ||
| 607 | testing_tree = test_env.testing_paths.testing_tree, | ||
| 608 | testing_server = test_env.testing_paths.testing_server, | ||
| 609 | testing_cache = test_env.testing_paths.testing_cache | ||
| 610 | }) | ||
| 611 | |||
| 612 | write_file(test_env.testing_paths.testing_dir .. "/testing_config.lua", config_content .. " \nweb_browser = \"true\"") | ||
| 613 | write_file(test_env.testing_paths.testing_dir .. "/testing_config_show_downloads.lua", config_content | ||
| 614 | .. "show_downloads = true \n rocks_servers={\"http://luarocks.org/repositories/rocks\"}") | ||
| 615 | |||
| 616 | -- testing_config_sftp.lua | ||
| 617 | config_content = substitute([[ | ||
| 618 | rocks_trees = { | ||
| 619 | "%{testing_tree}", | ||
| 620 | "%{testing_sys_tree}", | ||
| 621 | } | ||
| 622 | local_cache = "%{testing_cache}" | ||
| 623 | upload_server = "testing" | ||
| 624 | upload_user = "%{user}" | ||
| 625 | upload_servers = { | ||
| 626 | testing = { | ||
| 627 | sftp = "localhost/tmp/luarocks_testing", | ||
| 628 | }, | ||
| 629 | } | ||
| 630 | ]], { | ||
| 631 | user = os.getenv("USER"), | ||
| 632 | testing_sys_tree = test_env.testing_paths.testing_sys_tree, | ||
| 633 | testing_tree = test_env.testing_paths.testing_tree, | ||
| 634 | testing_cache = test_env.testing_paths.testing_cache | ||
| 635 | }) | ||
| 636 | |||
| 637 | write_file(test_env.testing_paths.testing_dir .. "/testing_config_sftp.lua", config_content) | ||
| 638 | |||
| 639 | -- luacov.config | ||
| 640 | config_content = substitute([[ | ||
| 641 | return { | ||
| 642 | statsfile = "%{testing_dir}/luacov.stats.out", | ||
| 643 | reportfile = "%{testing_dir}/luacov.report.out", | ||
| 644 | modules = { | ||
| 645 | ["luarocks"] = "src/bin/luarocks", | ||
| 646 | ["luarocks-admin"] = "src/bin/luarocks-admin", | ||
| 647 | ["luarocks.*"] = "src", | ||
| 648 | ["luarocks.*.*"] = "src", | ||
| 649 | ["luarocks.*.*.*"] = "src" | ||
| 650 | } | ||
| 651 | } | ||
| 652 | ]], { | ||
| 653 | testing_dir = test_env.testing_paths.testing_dir | ||
| 654 | }) | ||
| 655 | |||
| 656 | write_file(test_env.testing_paths.testing_dir .. "/luacov.config", config_content) | ||
| 657 | end | ||
| 658 | |||
| 659 | --- Remove testing directories. | ||
| 660 | local function clean() | ||
| 661 | print("Cleaning testing directory...") | ||
| 662 | test_env.remove_dir(test_env.testing_paths.luarocks_tmp) | ||
| 663 | test_env.remove_subdirs(test_env.testing_paths.testing_dir, "testing[_%-]") | ||
| 664 | test_env.remove_files(test_env.testing_paths.testing_dir, "testing_") | ||
| 665 | test_env.remove_files(test_env.testing_paths.testing_dir, "luacov") | ||
| 666 | test_env.remove_files(test_env.testing_paths.testing_dir, "upload_config") | ||
| 667 | print("Cleaning done!") | ||
| 668 | end | ||
| 669 | |||
| 670 | --- Install luarocks into testing prefix. | ||
| 671 | local function install_luarocks(install_env_vars) | ||
| 672 | local testing_paths = test_env.testing_paths | ||
| 673 | title("Installing LuaRocks") | ||
| 674 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 675 | local compiler_flag = test_env.MINGW and "/MW" or "" | ||
| 676 | assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " " .. compiler_flag .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars)) | ||
| 677 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core")) | ||
| 678 | else | ||
| 679 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix | ||
| 680 | assert(execute_bool(configure_cmd, false, install_env_vars)) | ||
| 681 | assert(execute_bool("make clean", false, install_env_vars)) | ||
| 682 | assert(execute_bool("make src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua", false, install_env_vars)) | ||
| 683 | assert(execute_bool("make dev", false, install_env_vars)) | ||
| 684 | end | ||
| 685 | print("LuaRocks installed correctly!") | ||
| 686 | end | ||
| 687 | |||
| 688 | function test_env.mock_server_extra_rocks(more) | ||
| 689 | local rocks = { | ||
| 690 | -- rocks needed for mock-server | ||
| 691 | "/copas-2.0.1-1.src.rock", | ||
| 692 | "/coxpcall-1.16.0-1.src.rock", | ||
| 693 | "/dkjson-2.5-2.src.rock", | ||
| 694 | "/luafilesystem-1.6.3-1.src.rock", | ||
| 695 | "/luasec-0.6-1.rockspec", | ||
| 696 | "/luasocket-3.0rc1-2.src.rock", | ||
| 697 | "/luasocket-3.0rc1-2.rockspec", | ||
| 698 | "/restserver-0.1-1.src.rock", | ||
| 699 | "/restserver-xavante-0.2-1.src.rock", | ||
| 700 | "/rings-1.3.0-1.src.rock", | ||
| 701 | "/wsapi-1.6.1-1.src.rock", | ||
| 702 | "/wsapi-xavante-1.6.1-1.src.rock", | ||
| 703 | "/xavante-2.4.0-1.src.rock" | ||
| 704 | } | ||
| 705 | if more then | ||
| 706 | for _, rock in ipairs(more) do | ||
| 707 | table.insert(rocks, rock) | ||
| 708 | end | ||
| 709 | end | ||
| 710 | return rocks | ||
| 711 | end | ||
| 712 | |||
| 713 | function test_env.mock_server_init() | ||
| 714 | local assert = require("luassert") | ||
| 715 | local testing_paths = test_env.testing_paths | ||
| 716 | assert.is_true(test_env.need_rock("restserver-xavante")) | ||
| 717 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) | ||
| 718 | os.execute(final_command) | ||
| 719 | end | ||
| 720 | |||
| 721 | function test_env.mock_server_done() | ||
| 722 | os.execute("curl localhost:8080/shutdown") | ||
| 723 | end | ||
| 724 | |||
| 725 | --- | ||
| 726 | -- Main function to create config files and testing environment | ||
| 727 | function test_env.main() | ||
| 728 | local testing_paths = test_env.testing_paths | ||
| 729 | |||
| 730 | if test_env.TEST_ENV_CLEAN then | ||
| 731 | clean() | ||
| 732 | end | ||
| 733 | |||
| 734 | lfs.mkdir(testing_paths.testing_cache) | ||
| 735 | lfs.mkdir(testing_paths.luarocks_tmp) | ||
| 736 | |||
| 737 | create_configs() | ||
| 738 | |||
| 739 | local install_env_vars = { | ||
| 740 | LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua" | ||
| 741 | } | ||
| 742 | |||
| 743 | install_luarocks(install_env_vars) | ||
| 744 | |||
| 745 | -- Preparation of rocks for building environment | ||
| 746 | local rocks = {} -- names of rocks, required for building environment | ||
| 747 | local urls = {} -- names of rock and rockspec files to be downloaded | ||
| 748 | table.insert(urls, "/luacov-0.11.0-1.rockspec") | ||
| 749 | table.insert(urls, "/luacov-0.11.0-1.src.rock") | ||
| 750 | |||
| 751 | if test_env.TYPE_TEST_ENV == "full" then | ||
| 752 | table.insert(urls, "/luafilesystem-1.6.3-1.src.rock") | ||
| 753 | table.insert(urls, "/luasocket-3.0rc1-1.src.rock") | ||
| 754 | table.insert(urls, "/luasocket-3.0rc1-1.rockspec") | ||
| 755 | table.insert(urls, "/luaposix-33.2.1-1.src.rock") | ||
| 756 | table.insert(urls, "/md5-1.2-1.src.rock") | ||
| 757 | table.insert(urls, "/lzlib-0.4.1.53-1.src.rock") | ||
| 758 | rocks = {"luafilesystem", "luasocket", "luaposix", "md5", "lzlib"} | ||
| 759 | |||
| 760 | if test_env.LUA_V ~= "5.1" then | ||
| 761 | table.insert(urls, "/luabitop-1.0.2-1.rockspec") | ||
| 762 | table.insert(urls, "/luabitop-1.0.2-1.src.rock") | ||
| 763 | table.insert(rocks, "luabitop") | ||
| 764 | end | ||
| 765 | end | ||
| 766 | |||
| 767 | table.insert(rocks, "luacov") -- luacov is needed for minimal or full environment | ||
| 768 | |||
| 769 | -- Download rocks needed for LuaRocks testing environment | ||
| 770 | lfs.mkdir(testing_paths.testing_server) | ||
| 771 | download_rocks(urls, testing_paths.testing_server) | ||
| 772 | build_environment(rocks, install_env_vars) | ||
| 773 | end | ||
| 774 | |||
| 775 | test_env.set_lua_version() | ||
| 776 | test_env.set_args() | ||
| 777 | test_env.testing_paths = create_paths(test_env.LUA_V or test_env.LUAJIT_V) | ||
| 778 | test_env.env_variables = create_env(test_env.testing_paths) | ||
| 779 | test_env.run = make_run_functions() | ||
| 780 | |||
| 781 | return test_env | ||
diff --git a/test/testfiles/a_rock-1.0-1.rockspec b/test/testfiles/a_rock-1.0-1.rockspec deleted file mode 100644 index 9f15e87a..00000000 --- a/test/testfiles/a_rock-1.0-1.rockspec +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | package = "a_rock" | ||
| 2 | version = "1.0-1" | ||
| 3 | source = { | ||
| 4 | url = "http://localhost:8080/file/a_rock.lua" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | summary = "An example rockspec", | ||
| 8 | } | ||
| 9 | dependencies = { | ||
| 10 | "lua >= 5.1" | ||
| 11 | } | ||
| 12 | build = { | ||
| 13 | type = "builtin", | ||
| 14 | modules = { | ||
| 15 | build = "a_rock.lua" | ||
| 16 | }, | ||
| 17 | } | ||
diff --git a/test/testfiles/a_rock.lua b/test/testfiles/a_rock.lua deleted file mode 100644 index a5647075..00000000 --- a/test/testfiles/a_rock.lua +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | return {} | ||
diff --git a/test/testfiles/invalid_patch-0.1-1.rockspec b/test/testfiles/invalid_patch-0.1-1.rockspec deleted file mode 100644 index c2ecd160..00000000 --- a/test/testfiles/invalid_patch-0.1-1.rockspec +++ /dev/null | |||
| @@ -1,29 +0,0 @@ | |||
| 1 | package = "invalid_patch" | ||
| 2 | version = "0.1-1" | ||
| 3 | source = { | ||
| 4 | -- any valid URL | ||
| 5 | url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" | ||
| 6 | } | ||
| 7 | description = { | ||
| 8 | summary = "A rockspec with an invalid patch", | ||
| 9 | } | ||
| 10 | dependencies = { | ||
| 11 | "lua >= 5.1" | ||
| 12 | } | ||
| 13 | build = { | ||
| 14 | type = "builtin", | ||
| 15 | modules = { | ||
| 16 | build = "build.lua" | ||
| 17 | }, | ||
| 18 | patches = { | ||
| 19 | ["I_am_an_invalid_patch.patch"] = | ||
| 20 | [[ | ||
| 21 | diff -Naur luadoc-3.0.1/src/luadoc/doclet/html.lua luadoc-3.0.1-new/src/luadoc/doclet/html.lua | ||
| 22 | --- luadoc-3.0.1/src/luadoc/doclet/html.lua2007-12-21 15:50:48.000000000 -0200 | ||
| 23 | +++ luadoc-3.0.1-new/src/luadoc/doclet/html.lua2008-02-28 01:59:53.000000000 -0300 | ||
| 24 | @@ -18,6 +18,7 @@ | ||
| 25 | - gabba gabba gabba | ||
| 26 | + gobo gobo gobo | ||
| 27 | ]] | ||
| 28 | } | ||
| 29 | } | ||
diff --git a/test/testfiles/invalid_validate-args-1.5.4-1.rockspec b/test/testfiles/invalid_validate-args-1.5.4-1.rockspec deleted file mode 100644 index 0b4d807d..00000000 --- a/test/testfiles/invalid_validate-args-1.5.4-1.rockspec +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | package = 'validate-args' | ||
| 2 | version = '1.5.4-1' | ||
| 3 | source = {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{++{ | ||
| 4 | url = "https://bitbucket.org/djerius/validate.args/downloads/validate-args-1.5.4.tar.gz" | ||
| 5 | } | ||
| 6 | |||
| 7 | description = { | ||
| 8 | summary = "Function argument validation", | ||
| 9 | detailed = [[ | ||
| 10 | validate.args is a Lua module that provides a framework for | ||
| 11 | validation of arguments to Lua functions as well as complex data | ||
| 12 | structures. The included validate.inplace module provides "live" | ||
| 13 | validation during assignment of values to elements in tables. ]], | ||
| 14 | license = "GPL-3", | ||
| 15 | |||
| 16 | } | ||
| 17 | |||
| 18 | dependencies = { | ||
| 19 | "lua >= 5.1" | ||
| 20 | } | ||
| 21 | |||
| 22 | build = { | ||
| 23 | |||
| 24 | type = "builtin", | ||
| 25 | |||
| 26 | modules = { | ||
| 27 | ["validate.args"] = "validate/args.lua", | ||
| 28 | ["validate.inplace"] = "validate/inplace.lua", | ||
| 29 | }, | ||
| 30 | |||
| 31 | copy_directories = { | ||
| 32 | "doc", "tests" | ||
| 33 | } | ||
| 34 | |||
| 35 | } | ||
diff --git a/test/testfiles/luajit-fail-1.0-1.rockspec b/test/testfiles/luajit-fail-1.0-1.rockspec deleted file mode 100644 index f8204600..00000000 --- a/test/testfiles/luajit-fail-1.0-1.rockspec +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | package = "luajit-fail" | ||
| 2 | version = "1.0-1" | ||
| 3 | source = { | ||
| 4 | url = "https://raw.githubusercontent.com/keplerproject/luarocks/master/test/testing.lua", | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | summary = "Test luajit dependency fail", | ||
| 8 | detailed = [[ | ||
| 9 | Fail luajit dependency when running with rockspec_format < 3.0. | ||
| 10 | ]], | ||
| 11 | homepage = "http://luarocks.org/", | ||
| 12 | license = "MIT/X license" | ||
| 13 | } | ||
| 14 | dependencies = { | ||
| 15 | "luajit >= 2.0" | ||
| 16 | } | ||
| 17 | build = { | ||
| 18 | type = "builtin", | ||
| 19 | modules = { | ||
| 20 | testing = "testing.lua" | ||
| 21 | } | ||
| 22 | } | ||
diff --git a/test/testfiles/luajit-success-1.0-1.rockspec b/test/testfiles/luajit-success-1.0-1.rockspec deleted file mode 100644 index 31c930c3..00000000 --- a/test/testfiles/luajit-success-1.0-1.rockspec +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | rockspec_format = "3.0" | ||
| 2 | package = "luajit-success" | ||
| 3 | version = "1.0-1" | ||
| 4 | source = { | ||
| 5 | url = "https://raw.githubusercontent.com/keplerproject/luarocks/master/test/testing.lua", | ||
| 6 | } | ||
| 7 | description = { | ||
| 8 | summary = "Test luajit dependency fail", | ||
| 9 | detailed = [[ | ||
| 10 | Use luajit dependency when running with rockspec_format >= 3.0. | ||
| 11 | ]], | ||
| 12 | homepage = "http://luarocks.org/", | ||
| 13 | license = "MIT/X license" | ||
| 14 | } | ||
| 15 | dependencies = { | ||
| 16 | "luajit >= 2.0" | ||
| 17 | } | ||
| 18 | build = { | ||
| 19 | type = "builtin", | ||
| 20 | modules = { | ||
| 21 | testing = "testing.lua" | ||
| 22 | } | ||
| 23 | } | ||
diff --git a/test/testfiles/missing_external-0.1-1.rockspec b/test/testfiles/missing_external-0.1-1.rockspec deleted file mode 100644 index 5f8e6219..00000000 --- a/test/testfiles/missing_external-0.1-1.rockspec +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | package = "missing_external" | ||
| 2 | version = "0.1-1" | ||
| 3 | source = { | ||
| 4 | -- any valid URL | ||
| 5 | url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" | ||
| 6 | } | ||
| 7 | description = { | ||
| 8 | summary = "Missing external dependency", | ||
| 9 | } | ||
| 10 | external_dependencies = { | ||
| 11 | INEXISTENT = { | ||
| 12 | library = "inexistentlib*", | ||
| 13 | header = "inexistentheader*.h", | ||
| 14 | } | ||
| 15 | } | ||
| 16 | dependencies = { | ||
| 17 | "lua >= 5.1" | ||
| 18 | } | ||
| 19 | build = { | ||
| 20 | type = "builtin", | ||
| 21 | modules = { | ||
| 22 | build = "build.lua" | ||
| 23 | } | ||
| 24 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mdt.c b/test/testfiles/mixed_deploy_type/mdt.c deleted file mode 100644 index a162ce23..00000000 --- a/test/testfiles/mixed_deploy_type/mdt.c +++ /dev/null | |||
| @@ -1,6 +0,0 @@ | |||
| 1 | #include "lua.h" | ||
| 2 | |||
| 3 | int luaopen_mdt(lua_State *L) { | ||
| 4 | lua_pushstring(L, "mdt.c"); | ||
| 5 | return 1; | ||
| 6 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mdt.lua b/test/testfiles/mixed_deploy_type/mdt.lua deleted file mode 100644 index c9ca9c68..00000000 --- a/test/testfiles/mixed_deploy_type/mdt.lua +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | return "mdt.lua" | ||
diff --git a/test/testfiles/mixed_deploy_type/mdt_file b/test/testfiles/mixed_deploy_type/mdt_file deleted file mode 100644 index 1a15f7d7..00000000 --- a/test/testfiles/mixed_deploy_type/mdt_file +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | return "mdt_file" | ||
diff --git a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec deleted file mode 100644 index 91b725da..00000000 --- a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.1.0-1.rockspec +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | package = "mixed_deploy_type" | ||
| 2 | version = "0.1.0-1" | ||
| 3 | source = { | ||
| 4 | url = "http://example.com" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | homepage = "http://example.com", | ||
| 8 | license = "*** please specify a license ***" | ||
| 9 | } | ||
| 10 | dependencies = {} | ||
| 11 | build = { | ||
| 12 | type = "builtin", | ||
| 13 | modules = { | ||
| 14 | mdt = "mdt/mdt.lua" | ||
| 15 | }, | ||
| 16 | install = { | ||
| 17 | lua = { | ||
| 18 | mdt_file = "mdt/mdt_file" | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
diff --git a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec b/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec deleted file mode 100644 index 9ca03180..00000000 --- a/test/testfiles/mixed_deploy_type/mixed_deploy_type-0.2.0-1.rockspec +++ /dev/null | |||
| @@ -1,21 +0,0 @@ | |||
| 1 | package = "mixed_deploy_type" | ||
| 2 | version = "0.2.0-1" | ||
| 3 | source = { | ||
| 4 | url = "http://example.com" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | homepage = "http://example.com", | ||
| 8 | license = "*** please specify a license ***" | ||
| 9 | } | ||
| 10 | dependencies = {} | ||
| 11 | build = { | ||
| 12 | type = "builtin", | ||
| 13 | modules = { | ||
| 14 | mdt = "mdt/mdt.c" | ||
| 15 | }, | ||
| 16 | install = { | ||
| 17 | lib = { | ||
| 18 | mdt_file = "mdt/mdt_file" | ||
| 19 | } | ||
| 20 | } | ||
| 21 | } | ||
diff --git a/test/testfiles/no_build_table-0.1-1.rockspec b/test/testfiles/no_build_table-0.1-1.rockspec deleted file mode 100644 index 5d79e9a0..00000000 --- a/test/testfiles/no_build_table-0.1-1.rockspec +++ /dev/null | |||
| @@ -1,12 +0,0 @@ | |||
| 1 | package = "no_build_table" | ||
| 2 | version = "0.1-1" | ||
| 3 | source = { | ||
| 4 | -- any valid URL | ||
| 5 | url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" | ||
| 6 | } | ||
| 7 | description = { | ||
| 8 | summary = "A rockspec with no build field", | ||
| 9 | } | ||
| 10 | dependencies = { | ||
| 11 | "lua >= 5.1" | ||
| 12 | } | ||
diff --git a/test/testfiles/not_a_zipfile-1.0-1.src.rock b/test/testfiles/not_a_zipfile-1.0-1.src.rock deleted file mode 100644 index e36f8bbe..00000000 --- a/test/testfiles/not_a_zipfile-1.0-1.src.rock +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | I am not a .zip file! | ||
diff --git a/test/testfiles/patch_create_delete-0.1-1.rockspec b/test/testfiles/patch_create_delete-0.1-1.rockspec deleted file mode 100644 index 069e2912..00000000 --- a/test/testfiles/patch_create_delete-0.1-1.rockspec +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | rockspec_format = "3.0" | ||
| 2 | package = "patch_create_delete" | ||
| 3 | version = "0.1-1" | ||
| 4 | source = { | ||
| 5 | -- any valid URL | ||
| 6 | url = "git://github.com/luarocks/luarocks" | ||
| 7 | } | ||
| 8 | description = { | ||
| 9 | summary = "A rockspec with a patch that creates and deletes files", | ||
| 10 | } | ||
| 11 | dependencies = { | ||
| 12 | "lua >= 5.1" | ||
| 13 | } | ||
| 14 | build = { | ||
| 15 | type = "builtin", | ||
| 16 | modules = { | ||
| 17 | ["luarocks.loader"] = "src/luarocks/loader.lua" | ||
| 18 | }, | ||
| 19 | patches = { | ||
| 20 | ["create_delete.patch"] = | ||
| 21 | [[ | ||
| 22 | diff -Naur luarocks/test/testfiles/patch_create_delete/a_file.txt luarocks-patch/test/testfiles/patch_create_delete/a_file.txt | ||
| 23 | --- luarocks/test/testfiles/patch_create_delete/a_file.txt 2017-10-04 15:39:44.179306674 -0300 | ||
| 24 | +++ luarocks-patch/test/testfiles/patch_create_delete/a_file.txt 1969-12-31 21:00:00.000000000 -0300 | ||
| 25 | @@ -1 +0,0 @@ | ||
| 26 | -I am a file. | ||
| 27 | diff -Naur luarocks/test/testfiles/patch_create_delete/another_file.txt luarocks-patch/test/testfiles/patch_create_delete/another_file.txt | ||
| 28 | --- luarocks/test/testfiles/patch_create_delete/another_file.txt 1969-12-31 21:00:00.000000000 -0300 | ||
| 29 | +++ luarocks-patch/test/testfiles/patch_create_delete/another_file.txt 2017-10-04 15:40:12.836306564 -0300 | ||
| 30 | @@ -0,0 +1 @@ | ||
| 31 | +I am another file. | ||
| 32 | ]] | ||
| 33 | } | ||
| 34 | } | ||
diff --git a/test/testfiles/patch_create_delete/a_file.txt b/test/testfiles/patch_create_delete/a_file.txt deleted file mode 100644 index 6539c24e..00000000 --- a/test/testfiles/patch_create_delete/a_file.txt +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | I am a file. | ||
diff --git a/test/testfiles/type_mismatch_string-1.0-1.rockspec b/test/testfiles/type_mismatch_string-1.0-1.rockspec deleted file mode 100644 index 7a607cfd..00000000 --- a/test/testfiles/type_mismatch_string-1.0-1.rockspec +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | |||
| 2 | package="type_mismatch_version" | ||
| 3 | version=1.0 | ||
| 4 | |||
diff --git a/test/testfiles/type_mismatch_table-1.0-1.rockspec b/test/testfiles/type_mismatch_table-1.0-1.rockspec deleted file mode 100644 index f348b798..00000000 --- a/test/testfiles/type_mismatch_table-1.0-1.rockspec +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | |||
| 2 | package="type_mismatch_table" | ||
| 3 | version="1.0-1" | ||
| 4 | |||
| 5 | source = "not a table" | ||
diff --git a/test/testfiles/type_mismatch_version-1.0-1.rockspec b/test/testfiles/type_mismatch_version-1.0-1.rockspec deleted file mode 100644 index 5e30dae6..00000000 --- a/test/testfiles/type_mismatch_version-1.0-1.rockspec +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | |||
| 2 | package="type_mismatch_version" | ||
| 3 | version="1.0" | ||
| 4 | |||
diff --git a/test/testfiles/with_external_dep-0.1-1.rockspec b/test/testfiles/with_external_dep-0.1-1.rockspec deleted file mode 100644 index 45fea4bd..00000000 --- a/test/testfiles/with_external_dep-0.1-1.rockspec +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | package = "with_external_dep" | ||
| 2 | version = "0.1-1" | ||
| 3 | source = { | ||
| 4 | url = "http://localhost:8080/file/with_external_dep.c" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | summary = "An example rockspec", | ||
| 8 | } | ||
| 9 | external_dependencies = { | ||
| 10 | FOO = { | ||
| 11 | header = "foo/foo.h" | ||
| 12 | } | ||
| 13 | } | ||
| 14 | dependencies = { | ||
| 15 | "lua >= 5.1" | ||
| 16 | } | ||
| 17 | build = { | ||
| 18 | type = "builtin", | ||
| 19 | modules = { | ||
| 20 | with_external_dep = { | ||
| 21 | sources = "with_external_dep.c", | ||
| 22 | incdirs = "$(FOO_INCDIR)", | ||
| 23 | } | ||
| 24 | } | ||
| 25 | } | ||
diff --git a/test/testfiles/with_external_dep.c b/test/testfiles/with_external_dep.c deleted file mode 100644 index 16435d8f..00000000 --- a/test/testfiles/with_external_dep.c +++ /dev/null | |||
| @@ -1,10 +0,0 @@ | |||
| 1 | #include <foo/foo.h> | ||
| 2 | #include <lua.h> | ||
| 3 | #include <lauxlib.h> | ||
| 4 | |||
| 5 | int luaopen_with_external_dep(lua_State* L) { | ||
| 6 | lua_newtable(L); | ||
| 7 | lua_pushinteger(L, FOO); | ||
| 8 | lua_setfield(L, -2, "foo"); | ||
| 9 | return 1; | ||
| 10 | } | ||
diff --git a/test/testfiles/with_external_dep/foo/foo.h b/test/testfiles/with_external_dep/foo/foo.h deleted file mode 100644 index eedd558f..00000000 --- a/test/testfiles/with_external_dep/foo/foo.h +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | #define FOO 42 | ||
diff --git a/test/testfiles/with_external_dep/foo/foo.h.gch b/test/testfiles/with_external_dep/foo/foo.h.gch deleted file mode 100644 index 66165c9e..00000000 --- a/test/testfiles/with_external_dep/foo/foo.h.gch +++ /dev/null | |||
| Binary files differ | |||
