diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2020-01-24 19:38:42 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2020-01-25 22:04:11 -0300 |
| commit | 0e3a09b6ed727533b0a6d545c61fcab5f02b6145 (patch) | |
| tree | 687940d6a0e574027b05e0237789d436fe561810 | |
| parent | 2e5748e5ade1566fa2e479aa4f38c0b46fe0ba79 (diff) | |
| download | luarocks-0e3a09b6ed727533b0a6d545c61fcab5f02b6145.tar.gz luarocks-0e3a09b6ed727533b0a6d545c61fcab5f02b6145.tar.bz2 luarocks-0e3a09b6ed727533b0a6d545c61fcab5f02b6145.zip | |
tests: drop LuaSec dependency on tests, use fixtures instead
| -rw-r--r-- | spec/build_spec.lua | 44 | ||||
| -rw-r--r-- | spec/fixtures/build_only_deps-0.1-1.rockspec | 18 | ||||
| -rw-r--r-- | spec/fixtures/build_only_deps-0.1-1.src.rock | bin | 0 -> 547 bytes | |||
| -rw-r--r-- | spec/fixtures/fixturedep.c | 4 | ||||
| -rw-r--r-- | spec/install_spec.lua | 21 | ||||
| -rw-r--r-- | spec/pack_spec.lua | 1 | ||||
| -rw-r--r-- | spec/util/test_env.lua | 42 |
7 files changed, 77 insertions, 53 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index d64ace4d..14837d89 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
| @@ -20,11 +20,11 @@ local extra_rocks = { | |||
| 20 | "/lpeg-1.0.0-1.rockspec", | 20 | "/lpeg-1.0.0-1.rockspec", |
| 21 | "/lpeg-1.0.0-1.src.rock", | 21 | "/lpeg-1.0.0-1.src.rock", |
| 22 | "/luafilesystem-1.6.3-1.src.rock", | 22 | "/luafilesystem-1.6.3-1.src.rock", |
| 23 | "/luasec-0.6-1.rockspec", | ||
| 24 | "/luasocket-3.0rc1-2.src.rock", | 23 | "/luasocket-3.0rc1-2.src.rock", |
| 25 | "/luasocket-3.0rc1-2.rockspec", | 24 | "/luasocket-3.0rc1-2.rockspec", |
| 26 | "/stdlib-41.0.0-1.src.rock", | 25 | "/stdlib-41.0.0-1.src.rock", |
| 27 | "/validate-args-1.5.4-1.rockspec" | 26 | "/validate-args-1.5.4-1.rockspec", |
| 27 | "spec/fixtures/a_rock-1.0-1.src.rock", | ||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | local c_module_source = [[ | 30 | local c_module_source = [[ |
| @@ -290,10 +290,13 @@ describe("LuaRocks build #integration", function() | |||
| 290 | end) | 290 | end) |
| 291 | end | 291 | end |
| 292 | 292 | ||
| 293 | it("luasec only deps", function() | 293 | it("only deps", function() |
| 294 | assert.is_true(run.luarocks_bool("build luasec " .. test_env.openssl_dirs .. " --only-deps")) | 294 | local rockspec = testing_paths.fixtures_dir .. "/build_only_deps-0.1-1.rockspec" |
| 295 | assert.is_false(run.luarocks_bool("show luasec")) | 295 | |
| 296 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec/0.6-1/luasec-0.6-1.rockspec")) | 296 | assert.is_true(run.luarocks_bool("build " .. rockspec .. " --only-deps")) |
| 297 | assert.is_false(run.luarocks_bool("show build_only_deps")) | ||
| 298 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/build_only_deps/0.1-1/build_only_deps-0.1-1.rockspec")) | ||
| 299 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/1.0-1/a_rock-1.0-1.rockspec")) | ||
| 297 | end) | 300 | end) |
| 298 | 301 | ||
| 299 | it("only deps of a given rockspec", function() | 302 | it("only deps of a given rockspec", function() |
| @@ -351,16 +354,6 @@ describe("LuaRocks build #integration", function() | |||
| 351 | end, finally) | 354 | end, finally) |
| 352 | end) | 355 | end) |
| 353 | 356 | ||
| 354 | it("with https", function() | ||
| 355 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
| 356 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs)) | ||
| 357 | |||
| 358 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | ||
| 359 | assert.is.truthy(run.luarocks("show validate-args")) | ||
| 360 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) | ||
| 361 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
| 362 | end) | ||
| 363 | |||
| 364 | it("fails if given an argument with an invalid patch", function() | 357 | it("fails if given an argument with an invalid patch", function() |
| 365 | assert.is_false(run.luarocks_bool("build " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) | 358 | assert.is_false(run.luarocks_bool("build " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) |
| 366 | end) | 359 | end) |
| @@ -899,15 +892,19 @@ describe("LuaRocks build #unit", function() | |||
| 899 | end) | 892 | end) |
| 900 | 893 | ||
| 901 | it("automatically extracts the modules and libraries if they are not given and builds against any external dependencies", function() | 894 | it("automatically extracts the modules and libraries if they are not given and builds against any external dependencies", function() |
| 902 | local ssllib = "ssl" | 895 | local fdir = testing_paths.fixtures_dir |
| 903 | if test_env.TEST_TARGET_OS == "windows" then | 896 | if test_env.TEST_TARGET_OS == "windows" then |
| 904 | if test_env.MINGW then | 897 | if test_env.MINGW then |
| 905 | ssllib = "eay32" | 898 | os.execute("gcc -shared -o " .. fdir .. "/libfixturedep.dll -Wl,--out-implib," .. fdir .."/libfixturedep.a " .. fdir .. "/fixturedep.c") |
| 906 | else | 899 | else |
| 907 | ssllib = "ssleay32" | 900 | os.execute("cl " .. fdir .. "\\fixturedep.c /link /export:fixturedep_fn /out:" .. fdir .. "\\fixturedep.dll /implib:" .. fdir .. "\\fixturedep.lib") |
| 908 | end | 901 | end |
| 902 | elseif test_env.TEST_TARGET_OS == "linux" then | ||
| 903 | os.execute("gcc -shared -o " .. fdir .. "/libfixturedep.so " .. fdir .. "/fixturedep.c") | ||
| 904 | elseif test_env.TEST_TARGET_OS == "osx" then | ||
| 905 | os.execute("cc -dynamiclib -o " .. fdir .. "/libfixturedep.dylib " .. fdir .. "/fixturedep.c") | ||
| 909 | end | 906 | end |
| 910 | 907 | ||
| 911 | local rockspec = { | 908 | local rockspec = { |
| 912 | rockspec_format = "3.0", | 909 | rockspec_format = "3.0", |
| 913 | package = "c_module", | 910 | package = "c_module", |
| @@ -916,8 +913,8 @@ describe("LuaRocks build #unit", function() | |||
| 916 | url = "http://example.com/c_module" | 913 | url = "http://example.com/c_module" |
| 917 | }, | 914 | }, |
| 918 | external_dependencies = { | 915 | external_dependencies = { |
| 919 | OPENSSL = { | 916 | FIXTUREDEP = { |
| 920 | library = ssllib -- Use OpenSSL since it is available on all testing platforms | 917 | library = "fixturedep" |
| 921 | } | 918 | } |
| 922 | }, | 919 | }, |
| 923 | build = { | 920 | build = { |
| @@ -927,8 +924,7 @@ describe("LuaRocks build #unit", function() | |||
| 927 | write_file("c_module.c", c_module_source, finally) | 924 | write_file("c_module.c", c_module_source, finally) |
| 928 | 925 | ||
| 929 | rockspecs.from_persisted_table("c_module-1.0-1.rockspec", rockspec) | 926 | rockspecs.from_persisted_table("c_module-1.0-1.rockspec", rockspec) |
| 930 | rockspec.variables["OPENSSL_INCDIR"] = test_env.OPENSSL_INCDIR | 927 | rockspec.variables["FIXTUREDEP_LIBDIR"] = testing_paths.fixtures_dir |
| 931 | rockspec.variables["OPENSSL_LIBDIR"] = test_env.OPENSSL_LIBDIR | ||
| 932 | assert.truthy(build_builtin.run(rockspec)) | 928 | assert.truthy(build_builtin.run(rockspec)) |
| 933 | end) | 929 | end) |
| 934 | 930 | ||
diff --git a/spec/fixtures/build_only_deps-0.1-1.rockspec b/spec/fixtures/build_only_deps-0.1-1.rockspec new file mode 100644 index 00000000..02d2b47e --- /dev/null +++ b/spec/fixtures/build_only_deps-0.1-1.rockspec | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | package = "build_only_deps" | ||
| 2 | version = "0.1-1" | ||
| 3 | source = { | ||
| 4 | url = "file://./a_rock.lua" | ||
| 5 | } | ||
| 6 | description = { | ||
| 7 | summary = "Fixture to test --only-deps", | ||
| 8 | } | ||
| 9 | dependencies = { | ||
| 10 | "lua >= 5.1", | ||
| 11 | "a_rock 1.0", | ||
| 12 | } | ||
| 13 | build = { | ||
| 14 | type = "builtin", | ||
| 15 | modules = { | ||
| 16 | dummy = "a_rock.lua", | ||
| 17 | } | ||
| 18 | } | ||
diff --git a/spec/fixtures/build_only_deps-0.1-1.src.rock b/spec/fixtures/build_only_deps-0.1-1.src.rock new file mode 100644 index 00000000..74b2d1e6 --- /dev/null +++ b/spec/fixtures/build_only_deps-0.1-1.src.rock | |||
| Binary files differ | |||
diff --git a/spec/fixtures/fixturedep.c b/spec/fixtures/fixturedep.c new file mode 100644 index 00000000..e3fcdd51 --- /dev/null +++ b/spec/fixtures/fixturedep.c | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | |||
| 2 | int fixturedep_fn() { | ||
| 3 | return 0; | ||
| 4 | } | ||
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 7370fef5..5ee913f0 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
| @@ -12,7 +12,6 @@ local extra_rocks = { | |||
| 12 | "/cprint-0.1-2.src.rock", | 12 | "/cprint-0.1-2.src.rock", |
| 13 | "/cprint-0.1-2.rockspec", | 13 | "/cprint-0.1-2.rockspec", |
| 14 | "/lpeg-0.12-1.src.rock", | 14 | "/lpeg-0.12-1.src.rock", |
| 15 | "/luasec-0.6-1.rockspec", | ||
| 16 | "/luassert-1.7.0-1.src.rock", | 15 | "/luassert-1.7.0-1.src.rock", |
| 17 | "/luasocket-3.0rc1-2.src.rock", | 16 | "/luasocket-3.0rc1-2.src.rock", |
| 18 | "/luasocket-3.0rc1-2.rockspec", | 17 | "/luasocket-3.0rc1-2.rockspec", |
| @@ -25,6 +24,9 @@ local extra_rocks = { | |||
| 25 | "/luafilesystem-1.6.3-1.src.rock", | 24 | "/luafilesystem-1.6.3-1.src.rock", |
| 26 | "/sailor-0.5-3.src.rock", | 25 | "/sailor-0.5-3.src.rock", |
| 27 | "/sailor-0.5-4.src.rock", | 26 | "/sailor-0.5-4.src.rock", |
| 27 | "spec/fixtures/a_repo/has_build_dep-1.0-1.all.rock", | ||
| 28 | "spec/fixtures/a_repo/a_build_dep-1.0-1.all.rock", | ||
| 29 | "spec/fixtures/a_repo/a_rock-1.0-1.src.rock", | ||
| 28 | } | 30 | } |
| 29 | 31 | ||
| 30 | describe("luarocks install #integration", function() | 32 | describe("luarocks install #integration", function() |
| @@ -77,8 +79,8 @@ describe("luarocks install #integration", function() | |||
| 77 | end) | 79 | end) |
| 78 | 80 | ||
| 79 | it("installs a package with a dependency", function() | 81 | it("installs a package with a dependency", function() |
| 80 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs)) | 82 | assert.is_true(run.luarocks_bool("install has_build_dep")) |
| 81 | assert.is_true(run.luarocks_bool("show luasocket")) | 83 | assert.is_true(run.luarocks_bool("show a_rock")) |
| 82 | end) | 84 | end) |
| 83 | 85 | ||
| 84 | it("installs a package without its documentation", function() | 86 | it("installs a package without its documentation", function() |
| @@ -135,14 +137,11 @@ describe("luarocks install #integration", function() | |||
| 135 | end) | 137 | end) |
| 136 | 138 | ||
| 137 | describe("more complex tests", function() | 139 | describe("more complex tests", function() |
| 138 | it('luasec with skipping dependency checks', function() | 140 | it('skipping dependency checks', function() |
| 139 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.openssl_dirs .. " --nodeps")) | 141 | assert.is_true(run.luarocks_bool("install has_build_dep --nodeps")) |
| 140 | assert.is_true(run.luarocks_bool("show luasec")) | 142 | assert.is_true(run.luarocks_bool("show has_build_dep")) |
| 141 | if env_variables.TYPE_TEST_ENV == "minimal" then | 143 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock")) |
| 142 | assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) | 144 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/has_build_dep")) |
| 143 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasocket")) | ||
| 144 | end | ||
| 145 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec")) | ||
| 146 | end) | 145 | end) |
| 147 | 146 | ||
| 148 | it('handle relative path in --tree #632', function() | 147 | it('handle relative path in --tree #632', function() |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index bea47811..f0c128a3 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
| @@ -6,7 +6,6 @@ local testing_paths = test_env.testing_paths | |||
| 6 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 7 | 7 | ||
| 8 | local extra_rocks = { | 8 | local extra_rocks = { |
| 9 | "/luasec-0.6-1.rockspec", | ||
| 10 | "/luassert-1.7.0-1.src.rock", | 9 | "/luassert-1.7.0-1.src.rock", |
| 11 | "/luasocket-3.0rc1-2.src.rock", | 10 | "/luasocket-3.0rc1-2.src.rock", |
| 12 | "/luasocket-3.0rc1-2.rockspec", | 11 | "/luasocket-3.0rc1-2.rockspec", |
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index e3aad1b1..d4591c91 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
| @@ -263,10 +263,10 @@ function test_env.set_args() | |||
| 263 | if package.config:sub(1,1) == "\\" then | 263 | if package.config:sub(1,1) == "\\" then |
| 264 | test_env.TEST_TARGET_OS = "windows" | 264 | test_env.TEST_TARGET_OS = "windows" |
| 265 | if test_env.APPVEYOR then | 265 | if test_env.APPVEYOR then |
| 266 | test_env.OPENSSL_INCDIR = "C:\\OpenSSL-Win32\\include" | 266 | test_env.OPENSSL_INCDIR = "C:\\OpenSSL-v111-Win32\\include" |
| 267 | test_env.OPENSSL_LIBDIR = "C:\\OpenSSL-Win32\\lib" | 267 | test_env.OPENSSL_LIBDIR = "C:\\OpenSSL-v111-Win32\\lib" |
| 268 | if test_env.MINGW then | 268 | if test_env.MINGW then |
| 269 | test_env.OPENSSL_LIBDIR = "C:\\OpenSSL-Win32\\bin" | 269 | test_env.OPENSSL_LIBDIR = "C:\\OpenSSL-v111-Win32\\bin" |
| 270 | end | 270 | end |
| 271 | end | 271 | end |
| 272 | else | 272 | else |
| @@ -374,27 +374,35 @@ end | |||
| 374 | -- @return make_manifest boolean: true if new rocks downloaded | 374 | -- @return make_manifest boolean: true if new rocks downloaded |
| 375 | local function download_rocks(urls, save_path) | 375 | local function download_rocks(urls, save_path) |
| 376 | local luarocks_repo = "https://luarocks.org/" | 376 | local luarocks_repo = "https://luarocks.org/" |
| 377 | local any_downloads = false | ||
| 378 | 377 | ||
| 379 | local to_download = {} | 378 | local to_download = {} |
| 379 | local fixtures = {} | ||
| 380 | for _, url in ipairs(urls) do | 380 | for _, url in ipairs(urls) do |
| 381 | -- check if already downloaded | 381 | if url:match("^spec/fixtures") then |
| 382 | if not test_env.exists(save_path .. "/" .. url) then | 382 | table.insert(fixtures, (url:gsub("^spec/fixtures", test_env.testing_paths.fixtures_dir))) |
| 383 | table.insert(to_download, luarocks_repo .. url) | 383 | else |
| 384 | any_downloads = true | 384 | -- check if already downloaded |
| 385 | if not test_env.exists(save_path .. "/" .. url) then | ||
| 386 | table.insert(to_download, luarocks_repo .. url) | ||
| 387 | end | ||
| 385 | end | 388 | end |
| 386 | end | 389 | end |
| 387 | if not any_downloads then | 390 | |
| 388 | return false | 391 | if #fixtures > 0 then |
| 392 | os.execute("cp " .. table.concat(fixtures, " ") .. " " .. save_path) | ||
| 389 | end | 393 | end |
| 390 | local cmd | 394 | |
| 391 | if test_env.TEST_TARGET_OS == "windows" then | 395 | if #to_download > 0 then |
| 392 | cmd = test_env.testing_paths.win_tools .. "/wget --no-check-certificate -cP " .. save_path | 396 | local cmd |
| 393 | else | 397 | if test_env.TEST_TARGET_OS == "windows" then |
| 394 | cmd = "wget -cP " .. save_path | 398 | cmd = test_env.testing_paths.win_tools .. "/wget --no-check-certificate -cP " .. save_path |
| 399 | else | ||
| 400 | cmd = "wget -cP " .. save_path | ||
| 401 | end | ||
| 402 | assert(execute_bool(cmd.." "..table.concat(to_download, " "))) | ||
| 395 | end | 403 | end |
| 396 | assert(execute_bool(cmd.." "..table.concat(to_download, " "))) | 404 | |
| 397 | return true | 405 | return (#fixtures > 0) or (#to_download > 0) |
| 398 | end | 406 | end |
| 399 | 407 | ||
| 400 | --- Create a file containing a string. | 408 | --- Create a file containing a string. |
