Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

luarocks: prefers a hadcoded interpreter for 3.9.2 #23

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
TestMatrix:
strategy:
matrix:
lua-version: ["5.4", "luajit"]
os: ["ubuntu-latest", "macos-latest"]
lua-version: ["5.4", "luajit-2.1"]
os: ["ubuntu-latest", "macos-13"]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@master

- uses: leafo/gh-actions-lua@master
- uses: hishamhm/gh-actions-lua@master
with:
luaVersion: ${{ matrix.lua-version }}

Expand All @@ -58,6 +58,7 @@ jobs:
busted -o htest --exclude-tags=ssh,gpg,git,unit --verbose -Xhelper "lua_dir=$(luarocks config variables.LUA_DIR),ci,env=full"

- name: Coverage
if: startsWith(matrix.os, 'ubuntu')
run: |
eval $(luarocks path)
luacov -c testrun/luacov.config
Expand All @@ -72,7 +73,7 @@ jobs:
steps:
- uses: actions/checkout@master

- uses: leafo/gh-actions-lua@v8.0.0
- uses: hishamhm/gh-actions-lua@master
with:
luaVersion: "5.4"

Expand All @@ -81,4 +82,3 @@ jobs:
./configure
./makedist dev
./smoke_test.sh luarocks-dev.tar.gz

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)
3 changes: 3 additions & 0 deletions src/luarocks/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ function cmd.run_command(description, commands, external_namespace, ...)
-- Now that the config is fully loaded, reinitialize fs using the full
-- feature set.
fs.init()
if cfg.variables.FORCE_HARDCODED and cfg.variables.LUA_INTERPRETER then
lua_found = true
end

-- if the Lua interpreter wasn't explicitly found before cfg.init,
-- try again now.
Expand Down
4 changes: 4 additions & 0 deletions src/luarocks/core/cfg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,10 @@ function cfg.init(detected, warning)
end
end

if hardcoded.FORCE_HARDCODED then
util.deep_merge(cfg.variables, hardcoded)
end

----------------------------------------
-- Config files are loaded.
-- Let's finish up the cfg table.
Expand Down
Loading