From bdfe731a601f3d12ffafbf504c9b06d70d5aa819 Mon Sep 17 00:00:00 2001 From: George Roman Date: Mon, 18 Jun 2018 18:57:47 +0300 Subject: Tests: replace small fixture files with inline content --- spec/build_spec.lua | 99 ++++++++++++++-- spec/fetch_spec.lua | 125 ++++++++++++++++++--- spec/fixtures/autodetect/bla.lua | 1 - spec/fixtures/c_module-1.0-1.rockspec | 11 -- spec/fixtures/c_module.c | 9 -- spec/fixtures/inconsistent_versions-1.0-1.rockspec | 8 -- spec/fixtures/invalid_checksum-1.0-1.rockspec | 9 -- spec/fixtures/invalid_rockspec_name.rockspec | 8 -- .../invalid_rockspec_version-1.0-1.rockspec | 9 -- spec/fixtures/invalid_url-1.0-1.rockspec | 8 -- spec/fixtures/missing_external-0.1-1.rockspec | 24 ---- .../missing_mandatory_field-1.0-1.rockspec | 5 - spec/fixtures/no_build_table-0.1-1.rockspec | 12 -- spec/fixtures/not_a_zipfile-1.0-1.src.rock | 1 - spec/fixtures/type_mismatch_string-1.0-1.rockspec | 4 - spec/fixtures/type_mismatch_table-1.0-1.rockspec | 5 - spec/fixtures/type_mismatch_version-1.0-1.rockspec | 4 - spec/fixtures/unknown_field-1.0-1.rockspec | 6 - spec/install_spec.lua | 15 ++- spec/lint_spec.lua | 57 +++++++++- 20 files changed, 269 insertions(+), 151 deletions(-) delete mode 100644 spec/fixtures/autodetect/bla.lua delete mode 100644 spec/fixtures/c_module-1.0-1.rockspec delete mode 100644 spec/fixtures/c_module.c delete mode 100644 spec/fixtures/inconsistent_versions-1.0-1.rockspec delete mode 100644 spec/fixtures/invalid_checksum-1.0-1.rockspec delete mode 100644 spec/fixtures/invalid_rockspec_name.rockspec delete mode 100644 spec/fixtures/invalid_rockspec_version-1.0-1.rockspec delete mode 100644 spec/fixtures/invalid_url-1.0-1.rockspec delete mode 100644 spec/fixtures/missing_external-0.1-1.rockspec delete mode 100644 spec/fixtures/missing_mandatory_field-1.0-1.rockspec delete mode 100644 spec/fixtures/no_build_table-0.1-1.rockspec delete mode 100644 spec/fixtures/not_a_zipfile-1.0-1.src.rock delete mode 100644 spec/fixtures/type_mismatch_string-1.0-1.rockspec delete mode 100644 spec/fixtures/type_mismatch_table-1.0-1.rockspec delete mode 100644 spec/fixtures/type_mismatch_version-1.0-1.rockspec delete mode 100644 spec/fixtures/unknown_field-1.0-1.rockspec diff --git a/spec/build_spec.lua b/spec/build_spec.lua index ae559654..74efccd5 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -1,7 +1,9 @@ local test_env = require("spec.util.test_env") local lfs = require("lfs") +local get_tmp_path = test_env.get_tmp_path local run = test_env.run local testing_paths = test_env.testing_paths +local write_file = test_env.write_file test_env.unload_luarocks() @@ -40,12 +42,35 @@ describe("LuaRocks build tests #integration", function() end) it("LuaRocks build with no arguments behaves as luarocks make", function() - local tmpdir = test_env.get_tmp_path() - lfs.mkdir(tmpdir) local olddir = lfs.currentdir() + local tmpdir = get_tmp_path() + lfs.mkdir(tmpdir) lfs.chdir(tmpdir) - test_env.copy(testing_paths.fixtures_dir .. "/c_module-1.0-1.rockspec", tmpdir .. "/c_module-1.0-1.rockspec") - test_env.copy(testing_paths.fixtures_dir .. "/c_module.c", tmpdir .. "/c_module.c") + + write_file("c_module-1.0-1.rockspec", [[ + package = "c_module" + version = "1.0-1" + source = { + url = "http://example.com/c_module" + } + build = { + type = "builtin", + modules = { + c_module = { "c_module.c" } + } + } + ]], finally) + write_file("c_module.c", [[ + #include + #include + + int luaopen_c_module(lua_State* L) { + lua_newtable(L); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "c_module"); + return 1; + } + ]], finally) assert.is_true(run.luarocks_bool("build")) if test_env.TEST_TARGET_OS == "windows" then @@ -245,6 +270,32 @@ describe("LuaRocks build tests #integration", function() end) describe("rockspec format 3.0 #rs3", function() + local tmpdir + local olddir + + before_each(function() + tmpdir = get_tmp_path() + olddir = lfs.currentdir() + lfs.mkdir(tmpdir) + lfs.chdir(tmpdir) + + lfs.mkdir("autodetect") + write_file("autodetect/bla.lua", "return {}", finally) + write_file("c_module.c", [[ + + ]], finally) + end) + + after_each(function() + if olddir then + lfs.chdir(olddir) + if tmpdir then + lfs.rmdir("autodetect") + lfs.rmdir(tmpdir) + end + end + end) + it("defaults to build.type == 'builtin'", function() local rockspec = "a_rock-1.0-1.rockspec" test_env.write_file(rockspec, [[ @@ -277,7 +328,7 @@ describe("LuaRocks build tests #integration", function() package = "autodetect" version = "1.0-1" source = { - url = "file://]] .. testing_paths.fixtures_dir .. [[/autodetect/bla.lua" + url = "file://autodetect/bla.lua" } description = { summary = "An example rockspec", @@ -299,7 +350,7 @@ describe("LuaRocks build tests #integration", function() package = "autodetect" version = "1.0-1" source = { - url = "file://]] .. testing_paths.fixtures_dir .. [[/autodetect/bla.lua" + url = "file://autodetect/bla.lua" } description = { summary = "An example rockspec", @@ -319,7 +370,7 @@ describe("LuaRocks build tests #integration", function() package = "autodetect" version = "1.0-1" source = { - url = "file://]] .. testing_paths.fixtures_dir .. [[/c_module.c" + url = "file://c_module.c" } description = { summary = "An example rockspec", @@ -348,9 +399,39 @@ describe("LuaRocks build tests #integration", function() teardown(function() test_env.mock_server_done() end) - + it("fails when missing external dependency", function() - assert.is_false(run.luarocks_bool("build " .. testing_paths.fixtures_dir .. "/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) + local tmpdir = get_tmp_path() + local olddir = lfs.currentdir() + lfs.mkdir(tmpdir) + lfs.chdir(tmpdir) + + write_file("missing_external-0.1-1.rockspec", [[ + package = "missing_external" + version = "0.1-1" + source = { + url = "https://example.com/build.lua" + } + external_dependencies = { + INEXISTENT = { + library = "inexistentlib*", + header = "inexistentheader*.h", + } + } + dependencies = { + "lua >= 5.1" + } + build = { + type = "builtin", + modules = { + build = "build.lua" + } + } + ]], finally) + assert.is_false(run.luarocks_bool("build missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) + + lfs.chdir(olddir) + lfs.rmdir(tmpdir) end) it("builds with external dependency", function() diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 9a10b58d..ce4cfb56 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua @@ -4,11 +4,13 @@ local git_repo = require("spec.util.git_repo") test_env.unload_luarocks() test_env.setup_specs() local fetch = require("luarocks.fetch") +local fs = require("luarocks.fs") local path = require("luarocks.path") local rockspecs = require("luarocks.rockspecs") local lfs = require("lfs") -local testing_paths = test_env.testing_paths local get_tmp_path = test_env.get_tmp_path +local testing_paths = test_env.testing_paths +local write_file = test_env.write_file describe("Luarocks fetch test #unit #mock", function() local are_same_files = function(file1, file2) @@ -121,7 +123,6 @@ describe("Luarocks fetch test #unit #mock", function() end) describe("fetch.find_base_dir", function() - it("extracts the archive given by the file argument and returns the inferred and the actual root directory in the archive", function() local url = "http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz" local file, tmpdir = assert(fetch.fetch_url_at_temp_dir(url, "test")) @@ -185,6 +186,26 @@ describe("Luarocks fetch test #unit #mock", function() end) describe("fetch.load_local_rockspec", function() + local tmpdir + local olddir + + before_each(function() + tmpdir = get_tmp_path() + olddir = lfs.currentdir() + lfs.mkdir(tmpdir) + lfs.chdir(tmpdir) + fs.change_dir(tmpdir) + end) + + after_each(function() + if olddir then + lfs.chdir(olddir) + if tmpdir then + lfs.rmdir(tmpdir) + end + end + end) + it("returns a table representing the rockspec from the given file skipping some checks if the quick argument is enabled", function() local rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/a_rock-1.0-1.rockspec", true) assert.same(rockspec.name, "a_rock") @@ -192,20 +213,35 @@ describe("Luarocks fetch test #unit #mock", function() assert.same(rockspec.source.url, "http://localhost:8080/file/a_rock.lua") assert.same(rockspec.description, { summary = "An example rockspec" }) - rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/missing_mandatory_field-1.0-1.rockspec", true) + write_file("missing_mandatory_field-1.0-1.rockspec", [[ + package="missing_mandatory_field" + version="1.0-1" + source = { + url = "http://example.com/foo.tar.gz" + } + ]], finally) + rockspec = fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec", true) assert.same(rockspec.name, "missing_mandatory_field") assert.same(rockspec.version, "1.0-1") assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") - rockspec = fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/unknown_field-1.0-1.rockspec", true) + write_file("unknown_field-1.0-1.rockspec", [[ + package="unknown_field" + version="1.0-1" + source = { + url = "http://example.com/foo.tar.gz" + } + unknown="foo" + ]], finally) + rockspec = fetch.load_local_rockspec("unknown_field-1.0-1.rockspec", true) assert.same(rockspec.name, "unknown_field") assert.same(rockspec.version, "1.0-1") assert.same(rockspec.source.url, "http://example.com/foo.tar.gz") -- The previous calls fail if the detailed checking is done path.use_tree(testing_paths.testing_tree) - assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/missing_mandatory_field-1.0-1.rockspec")) - assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/unknown_field-1.0-1.rockspec")) + assert.falsy(fetch.load_local_rockspec("missing_mandatory_field-1.0-1.rockspec")) + assert.falsy(fetch.load_local_rockspec("unknown_field-1.0-1.rockspec")) end) it("returns a table representing the rockspec from the given file", function() @@ -222,24 +258,47 @@ describe("Luarocks fetch test #unit #mock", function() end) it("returns false if the rockspec version is not supported", function() - assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_version.rockspec")) + assert.falsy(fetch.load_local_rockspec("invalid_version.rockspec")) end) it("returns false if the rockspec doesn't pass the type checking", function() - assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/type_mismatch_string-1.0-1.rockspec")) + write_file("type_mismatch_string-1.0-1.rockspec", [[ + package="type_mismatch_version" + version=1.0 + ]], finally) + assert.falsy(fetch.load_local_rockspec("type_mismatch_string-1.0-1.rockspec")) end) it("returns false if the rockspec file name is not right", function() - assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/invalid_rockspec_name.rockspec")) + write_file("invalid_rockspec_name.rockspec", [[ + package="invalid_rockspec_name" + version="1.0-1" + source = { + url = "http://example.com/foo.tar.gz" + } + build = { + + } + ]], finally) + assert.falsy(fetch.load_local_rockspec("invalid_rockspec_name.rockspec")) end) it("returns false if the version in the rockspec file name doesn't match the version declared in the rockspec", function() - assert.falsy(fetch.load_local_rockspec(testing_paths.fixtures_dir .. "/inconsistent_versions-1.0-1.rockspec")) + write_file("inconsistent_versions-1.0-1.rockspec", [[ + package="inconsistent_versions" + version="1.0-2" + source = { + url = "http://example.com/foo.tar.gz" + } + build = { + + } + ]], finally) + assert.falsy(fetch.load_local_rockspec("inconsistent_versions-1.0-1.rockspec")) end) end) describe("fetch.load_rockspec", function() - it("returns a table containing the requested rockspec by downloading it into a temporary directory", function() path.use_tree(testing_paths.testing_tree) local rockspec = fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec") @@ -279,6 +338,25 @@ describe("Luarocks fetch test #unit #mock", function() end) describe("fetch.get_sources", function() + local tmpdir + local olddir + + before_each(function() + tmpdir = get_tmp_path() + olddir = lfs.currentdir() + lfs.mkdir(tmpdir) + lfs.chdir(tmpdir) + fs.change_dir(tmpdir) + end) + + after_each(function() + if olddir then + lfs.chdir(olddir) + if tmpdir then + lfs.rmdir(tmpdir) + end + end + end) it("downloads the sources for building a rock and returns the resulting source filename and its parent directory", function() local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/a_rock-1.0-1.rockspec")) @@ -311,12 +389,33 @@ describe("Luarocks fetch test #unit #mock", function() end) it("returns false and does nothing if the rockspec source url is invalid", function() - local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/invalid_url-1.0-1.rockspec")) + write_file("invalid_url-1.0-1.rockspec", [[ + package="invalid_url" + version="1.0-1" + source = { + url = "http://localhost:8080/file/nonexistent" + } + build = { + + } + ]], finally) + local rockspec = assert(fetch.load_rockspec("invalid_url-1.0-1.rockspec")) assert.falsy(fetch.get_sources(rockspec, false)) end) it("returns false and does nothing if the downloaded rockspec has an invalid md5 checksum", function() - local rockspec = assert(fetch.load_rockspec("http://localhost:8080/file/invalid_checksum-1.0-1.rockspec")) + write_file("invalid_checksum-1.0-1.rockspec", [[ + package="invalid_checksum" + version="1.0-1" + source = { + url = "http://localhost:8080/file/a_rock.lua", + md5 = "invalid" + } + build = { + + } + ]], finally) + local rockspec = assert(fetch.load_rockspec("invalid_checksum-1.0-1.rockspec")) assert.falsy(fetch.get_sources(rockspec, false)) end) end) diff --git a/spec/fixtures/autodetect/bla.lua b/spec/fixtures/autodetect/bla.lua deleted file mode 100644 index a5647075..00000000 --- a/spec/fixtures/autodetect/bla.lua +++ /dev/null @@ -1 +0,0 @@ -return {} diff --git a/spec/fixtures/c_module-1.0-1.rockspec b/spec/fixtures/c_module-1.0-1.rockspec deleted file mode 100644 index 2913ecf6..00000000 --- a/spec/fixtures/c_module-1.0-1.rockspec +++ /dev/null @@ -1,11 +0,0 @@ -package = "c_module" -version = "1.0-1" -source = { - url = "http://example.com/c_module" -} -build = { - type = "builtin", - modules = { - c_module = { "c_module.c" } - } -} diff --git a/spec/fixtures/c_module.c b/spec/fixtures/c_module.c deleted file mode 100644 index 4c27dda8..00000000 --- a/spec/fixtures/c_module.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include - -int luaopen_c_module(lua_State* L) { - lua_newtable(L); - lua_pushinteger(L, 1); - lua_setfield(L, -2, "c_module"); - return 1; -} diff --git a/spec/fixtures/inconsistent_versions-1.0-1.rockspec b/spec/fixtures/inconsistent_versions-1.0-1.rockspec deleted file mode 100644 index c8c1eee2..00000000 --- a/spec/fixtures/inconsistent_versions-1.0-1.rockspec +++ /dev/null @@ -1,8 +0,0 @@ -package="inconsistent_versions" -version="1.0-2" -source = { - url = "http://example.com/foo.tar.gz" -} -build = { - -} diff --git a/spec/fixtures/invalid_checksum-1.0-1.rockspec b/spec/fixtures/invalid_checksum-1.0-1.rockspec deleted file mode 100644 index 256cb1fe..00000000 --- a/spec/fixtures/invalid_checksum-1.0-1.rockspec +++ /dev/null @@ -1,9 +0,0 @@ -package="invalid_checksum" -version="1.0-1" -source = { - url = "http://localhost:8080/file/a_rock.lua", - md5 = "invalid" -} -build = { - -} diff --git a/spec/fixtures/invalid_rockspec_name.rockspec b/spec/fixtures/invalid_rockspec_name.rockspec deleted file mode 100644 index ab70c75d..00000000 --- a/spec/fixtures/invalid_rockspec_name.rockspec +++ /dev/null @@ -1,8 +0,0 @@ -package="invalid_rockspec_name" -version="1.0-1" -source = { - url = "http://example.com/foo.tar.gz" -} -build = { - -} diff --git a/spec/fixtures/invalid_rockspec_version-1.0-1.rockspec b/spec/fixtures/invalid_rockspec_version-1.0-1.rockspec deleted file mode 100644 index f644b3d9..00000000 --- a/spec/fixtures/invalid_rockspec_version-1.0-1.rockspec +++ /dev/null @@ -1,9 +0,0 @@ -rockspec_format="3.1" -package="invalid_rockspec_version" -version="1.0-1" -source = { - url = "http://example.com/foo.tar.gz" -} -build = { - -} diff --git a/spec/fixtures/invalid_url-1.0-1.rockspec b/spec/fixtures/invalid_url-1.0-1.rockspec deleted file mode 100644 index a74b0281..00000000 --- a/spec/fixtures/invalid_url-1.0-1.rockspec +++ /dev/null @@ -1,8 +0,0 @@ -package="invalid_url" -version="1.0-1" -source = { - url = "http://localhost:8080/file/nonexistent" -} -build = { - -} diff --git a/spec/fixtures/missing_external-0.1-1.rockspec b/spec/fixtures/missing_external-0.1-1.rockspec deleted file mode 100644 index 5f8e6219..00000000 --- a/spec/fixtures/missing_external-0.1-1.rockspec +++ /dev/null @@ -1,24 +0,0 @@ -package = "missing_external" -version = "0.1-1" -source = { - -- any valid URL - url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" -} -description = { - summary = "Missing external dependency", -} -external_dependencies = { - INEXISTENT = { - library = "inexistentlib*", - header = "inexistentheader*.h", - } -} -dependencies = { - "lua >= 5.1" -} -build = { - type = "builtin", - modules = { - build = "build.lua" - } -} diff --git a/spec/fixtures/missing_mandatory_field-1.0-1.rockspec b/spec/fixtures/missing_mandatory_field-1.0-1.rockspec deleted file mode 100644 index 56dac987..00000000 --- a/spec/fixtures/missing_mandatory_field-1.0-1.rockspec +++ /dev/null @@ -1,5 +0,0 @@ -package="missing_mandatory_field" -version="1.0-1" -source = { - url = "http://example.com/foo.tar.gz" -} diff --git a/spec/fixtures/no_build_table-0.1-1.rockspec b/spec/fixtures/no_build_table-0.1-1.rockspec deleted file mode 100644 index 5d79e9a0..00000000 --- a/spec/fixtures/no_build_table-0.1-1.rockspec +++ /dev/null @@ -1,12 +0,0 @@ -package = "no_build_table" -version = "0.1-1" -source = { - -- any valid URL - url = "https://raw.github.com/keplerproject/luarocks/master/src/luarocks/build.lua" -} -description = { - summary = "A rockspec with no build field", -} -dependencies = { - "lua >= 5.1" -} diff --git a/spec/fixtures/not_a_zipfile-1.0-1.src.rock b/spec/fixtures/not_a_zipfile-1.0-1.src.rock deleted file mode 100644 index e36f8bbe..00000000 --- a/spec/fixtures/not_a_zipfile-1.0-1.src.rock +++ /dev/null @@ -1 +0,0 @@ -I am not a .zip file! diff --git a/spec/fixtures/type_mismatch_string-1.0-1.rockspec b/spec/fixtures/type_mismatch_string-1.0-1.rockspec deleted file mode 100644 index 7a607cfd..00000000 --- a/spec/fixtures/type_mismatch_string-1.0-1.rockspec +++ /dev/null @@ -1,4 +0,0 @@ - -package="type_mismatch_version" -version=1.0 - diff --git a/spec/fixtures/type_mismatch_table-1.0-1.rockspec b/spec/fixtures/type_mismatch_table-1.0-1.rockspec deleted file mode 100644 index f348b798..00000000 --- a/spec/fixtures/type_mismatch_table-1.0-1.rockspec +++ /dev/null @@ -1,5 +0,0 @@ - -package="type_mismatch_table" -version="1.0-1" - -source = "not a table" diff --git a/spec/fixtures/type_mismatch_version-1.0-1.rockspec b/spec/fixtures/type_mismatch_version-1.0-1.rockspec deleted file mode 100644 index 5e30dae6..00000000 --- a/spec/fixtures/type_mismatch_version-1.0-1.rockspec +++ /dev/null @@ -1,4 +0,0 @@ - -package="type_mismatch_version" -version="1.0" - diff --git a/spec/fixtures/unknown_field-1.0-1.rockspec b/spec/fixtures/unknown_field-1.0-1.rockspec deleted file mode 100644 index bcad2d53..00000000 --- a/spec/fixtures/unknown_field-1.0-1.rockspec +++ /dev/null @@ -1,6 +0,0 @@ -package="unknown_field" -version="1.0-1" -source = { - url = "http://example.com/foo.tar.gz" -} -unknown="foo" diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 3525cda3..f18b7c89 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -3,6 +3,8 @@ local lfs = require("lfs") local run = test_env.run local testing_paths = test_env.testing_paths local env_variables = test_env.env_variables +local get_tmp_path = test_env.get_tmp_path +local write_file = test_env.write_file test_env.unload_luarocks() @@ -55,7 +57,18 @@ describe("luarocks install #integration", function() end) it("fails not a zip file", function() - assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/not_a_zipfile-1.0-1.src.rock")) + local olddir = lfs.currentdir() + local tmpdir = get_tmp_path() + lfs.mkdir(tmpdir) + lfs.chdir(tmpdir) + + write_file("not_a_zipfile-1.0-1.src.rock", [[ + I am not a .zip file! + ]], finally) + assert.is_false(run.luarocks_bool("install not_a_zipfile-1.0-1.src.rock")) + + lfs.chdir(olddir) + lfs.rmdir(tmpdir) end) it("only-deps of lxsh show there is no lxsh", function() diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index e7af97fa..4bc93e95 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua @@ -1,8 +1,11 @@ local test_env = require("spec.util.test_env") local run = test_env.run +local get_tmp_path = test_env.get_tmp_path local testing_paths = test_env.testing_paths +local write_file = test_env.write_file test_env.unload_luarocks() +local lfs = require("lfs") local extra_rocks = { "/validate-args-1.5.4-1.rockspec" @@ -30,20 +33,66 @@ describe("LuaRocks lint tests #integration", function() end) describe("LuaRocks lint mismatch set", function() + local tmpdir + local olddir + + before_each(function() + tmpdir = get_tmp_path() + olddir = lfs.currentdir() + lfs.mkdir(tmpdir) + lfs.chdir(tmpdir) + end) + + after_each(function() + if olddir then + lfs.chdir(olddir) + if tmpdir then + lfs.rmdir(tmpdir) + end + end + end) + it("LuaRocks lint mismatch string", function() - assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/type_mismatch_string-1.0-1.rockspec")) + write_file("type_mismatch_string-1.0-1.rockspec", [[ + package="type_mismatch_version" + version=1.0 + ]], finally) + assert.is_false(run.luarocks_bool("lint type_mismatch_string-1.0-1.rockspec")) end) it("LuaRocks lint mismatch version", function() - assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/type_mismatch_version-1.0-1.rockspec")) + write_file("type_mismatch_version-1.0-1.rockspec", [[ + package="type_mismatch_version" + version="1.0" + ]], finally) + assert.is_false(run.luarocks_bool("lint type_mismatch_version-1.0-1.rockspec")) end) it("LuaRocks lint mismatch table", function() - assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/type_mismatch_table-1.0-1.rockspec")) + write_file("type_mismatch_table-1.0-1.rockspec", [[ + package="type_mismatch_table" + version="1.0-1" + + source = "not a table" + ]], finally) + assert.is_false(run.luarocks_bool("lint type_mismatch_table-1.0-1.rockspec")) end) it("LuaRocks lint mismatch no build table", function() - assert.is_false(run.luarocks_bool("lint " .. testing_paths.fixtures_dir .. "/no_build_table-1.0-1.rockspec")) + write_file("no_build_table-1.0-1.rockspec", [[ + package = "no_build_table" + version = "0.1-1" + source = { + url = "http://example.com/foo/tar.gz" + } + description = { + summary = "A rockspec with no build field", + } + dependencies = { + "lua >= 5.1" + } + ]], finally) + assert.is_false(run.luarocks_bool("lint no_build_table-1.0-1.rockspec")) end) end) end) -- cgit v1.2.3-55-g6feb