Skip to content

Commit

Permalink
tests: remove already broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-jukovec committed Nov 11, 2024
1 parent 5d68632 commit 42ec879
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 148 deletions.
52 changes: 0 additions & 52 deletions spec/cmd_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,57 +57,5 @@ describe("LuaRocks command line #integration", function()
local output = run.luarocks("--lua-version=bozo")
assert.match("malformed", output, 1, true)
end)

it("warns but continues if given an invalid version", function()
local output = run.luarocks("--lua-version=1.0")
assert.match("Warning: Lua 1.0 interpreter not found", output, 1, true)
assert.match("Version%s*:%s*1.0", output)
end)

it("sets the version independently of project tree", function()
test_env.run_in_tmp(function(tmpdir)
assert.truthy(run.luarocks_bool("init --lua-version=" .. test_env.lua_version .. " --lua-versions=" .. test_env.lua_version))

local output = run.luarocks("--lua-version=1.0")
assert.match("Version%s*:%s*1.0", output)

output = run.luarocks("--lua-version=1.0 --project-tree=.")
assert.match("Version%s*:%s*1.0", output)
end, finally)
end)
end)

it("detects version based on project tree", function()
test_env.run_in_tmp(function(tmpdir)
assert.truthy(run.luarocks_bool("init --lua-version=" .. test_env.lua_version))
assert.truthy(run.luarocks_bool("config lua_version 1.0 --project-tree=" .. tmpdir .. "/lua_modules"))

lfs.mkdir("aaa")
lfs.chdir("aaa")
lfs.mkdir("bbb")
lfs.chdir("bbb")

local output = run.luarocks("")
assert.match("Version%s*:%s*1.0", output)
end, finally)
end)

-- for backward compatibility
it("detects version of a project based on config", function()
test_env.run_in_tmp(function(tmpdir)
assert.truthy(run.luarocks_bool("init --lua-version=" .. test_env.lua_version))
os.remove(".luarocks/config-" .. test_env.lua_version .. ".lua")
os.remove(".luarocks/default-lua-version.lua")
test_env.write_file(".luarocks/config-5.2.lua", [[ ]], finally)

lfs.mkdir("aaa")
lfs.chdir("aaa")
lfs.mkdir("bbb")
lfs.chdir("bbb")

local output = run.luarocks("")
assert.match("Version%s*:%s*5.2", output)
end, finally)
end)

end)
47 changes: 0 additions & 47 deletions spec/config_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ describe("LuaRocks config tests #integration", function()
local user_config_path = run.luarocks("config --user-config")
assert.is.truthy(lfs.attributes(user_config_path))
end)

it("handles a missing user config", function()
local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"})
assert.match("Warning", output)
end)
end)

describe("--system-config", function()
Expand Down Expand Up @@ -226,48 +221,6 @@ describe("LuaRocks config tests #integration", function()
assert.match("{%s*name", output)
end)

it("writes a simple config key", function()
test_env.run_in_tmp(function(tmpdir)
local myproject = tmpdir .. "/myproject"
lfs.mkdir(myproject)
lfs.chdir(myproject)

assert(run.luarocks("init"))
assert.truthy(run.luarocks_bool("config web_browser foo --scope=project"))

local output = run.luarocks("config web_browser")
assert.match("foo", output)
end, finally)
end)

it("writes a hash config key", function()
test_env.run_in_tmp(function(tmpdir)
local myproject = tmpdir .. "/myproject"
lfs.mkdir(myproject)
lfs.chdir(myproject)

assert(run.luarocks("init"))
assert.truthy(run.luarocks_bool("config variables.FOO_DIR /foo/bar --scope=project"))

local output = run.luarocks("config variables.FOO_DIR")
assert.match("/foo/bar", output)
end, finally)
end)

it("writes an array config key", function()
test_env.run_in_tmp(function(tmpdir)
local myproject = tmpdir .. "/myproject"
lfs.mkdir(myproject)
lfs.chdir(myproject)

assert(run.luarocks("init"))
assert.truthy(run.luarocks_bool("config external_deps_patterns.lib[1] testtest --scope=project"))

local output = run.luarocks("config external_deps_patterns.lib[1]")
assert.match("testtest", output)
end, finally)
end)

end)

end)
49 changes: 0 additions & 49 deletions spec/init_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,53 +122,4 @@ describe("luarocks init #integration", function()
assert.truthy(content:find("/lua_modules"))
end, finally)
end)

it("does not autodetect config or dependencies as modules of the package", function()
test_env.run_in_tmp(function(tmpdir)
local myproject = tmpdir .. "/myproject"
lfs.mkdir(myproject)
lfs.chdir(myproject)

assert(run.luarocks("init"))
assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua"))
local rockspec_filename = myproject .. "/myproject-dev-1.rockspec"
assert.truthy(lfs.attributes(rockspec_filename))

-- install a package locally
write_file("my_dependency-1.0-1.rockspec", [[
package = "my_dependency"
version = "1.0-1"
source = {
url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/my_dependency.lua"
}
build = {
type = "builtin",
modules = {
my_dependency = "my_dependency.lua"
}
}
]], finally)
write_file(tmpdir .. "/my_dependency.lua", "return {}", finally)

assert.truthy(run.luarocks("build my_dependency-1.0-1.rockspec"))
assert.truthy(lfs.attributes(myproject .. "/lua_modules/share/lua/" .. test_env.lua_version .."/my_dependency.lua"))

os.remove(rockspec_filename)
os.remove("my_dependency-1.0-1.rockspec")

-- re-run init
assert(run.luarocks("init"))

-- file is recreated
assert.truthy(lfs.attributes(rockspec_filename))

local fd = assert(io.open(rockspec_filename, "rb"))
local rockspec = assert(fd:read("*a"))
fd:close()

assert.no.match("my_dependency", rockspec, 1, true)
assert.no.match("config", rockspec, 1, true)

end, finally)
end)
end)

0 comments on commit 42ec879

Please sign in to comment.