diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2018-06-20 10:28:49 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-01 15:51:13 -0300 |
commit | 4c1c170b9d344b6c069c8e6df5798f6e0bd63966 (patch) | |
tree | 21b0061a4c41434239320db45749ec5b4086be4c /spec/config_spec.lua | |
parent | 50cd8ea8941d38678e8e6cf82065108dc3217d91 (diff) | |
download | luarocks-4c1c170b9d344b6c069c8e6df5798f6e0bd63966.tar.gz luarocks-4c1c170b9d344b6c069c8e6df5798f6e0bd63966.tar.bz2 luarocks-4c1c170b9d344b6c069c8e6df5798f6e0bd63966.zip |
cfg, cmd: major reorganization
* `--lua-dir` flag, specifying a prefix for the Lua installation to
be used. This reconfigures LuaRocks entirely, including allowing
a LuaRocks which is itself running using one Lua 5.x version to
manage packages for a different Lua 5.y version. The resulting
configuration can be checked with `luarocks config --lua-dir=<path>`.
* requiring `luarocks.core.cfg` no longer has side-effects
* configuration now needs to be initialized with `cfg.init([lua_data])`,
where `lua_data` is a table with the configuration of the VM:
* `lua_version` - e.g. `"5.3"`
* `luajit_version` - e.g. `"2.1.0-beta3"`
* `lua_interpreter` - e.g. `"lua5.3"`
* `lua_bindir` - e.g. `"/usr/local/bin"`
* `lua_libdir` - e.g. `"/usr/local/lib"`
* `lua_incdir` - e.g. `"/usr/local/include/lua-5.3"`
* `cfg.init` can be called multiple times, reconfiguring the global state.
This is important since `luarocks.loader` now calls it, and the `--lua-dir`
command line can override the configuration and reconfigure LuaRocks.
* `site_config_*` is no more: LuaRocks is no longer dependent on a properly-written
site_config file. Instead, it can *optionally* use `luarocks.core.hardcoded`
for hardcoded values, or detect its configuration at runtime, based on
OS detection, arg[-1] or command-line flags.
* reduction of moving parts in the configuration:
* `cfg.platforms` is no longer a globally-visible table; instead, `cfg`
provides an API of read-only functions: `is_platform`, `each_platform`,
`print_platforms`.
* `cfg.*_proxy` options are no longer configured via the config files,
but rather via the standard `*_proxy` environment variables.
* `"windows"` is now the more general platform name of the Windows family.
This is technically a breaking change but I don't expect it to cause
problems with real-world rockspecs.
* internal code reorganization in `luarocks.cmd` module
Diffstat (limited to 'spec/config_spec.lua')
-rw-r--r-- | spec/config_spec.lua | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 94757244..e78c3de0 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
@@ -3,7 +3,7 @@ local lfs = require("lfs") | |||
3 | local run = test_env.run | 3 | local run = test_env.run |
4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
5 | local env_variables = test_env.env_variables | 5 | local env_variables = test_env.env_variables |
6 | local site_config | 6 | local hardcoded |
7 | 7 | ||
8 | test_env.unload_luarocks() | 8 | test_env.unload_luarocks() |
9 | 9 | ||
@@ -11,30 +11,30 @@ describe("LuaRocks config tests #integration", function() | |||
11 | 11 | ||
12 | before_each(function() | 12 | before_each(function() |
13 | test_env.setup_specs() | 13 | test_env.setup_specs() |
14 | test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs | 14 | test_env.unload_luarocks() -- need to be required here, because hardcoded is created after first loading of specs |
15 | site_config = require("luarocks.core.site_config_" .. test_env.lua_version:gsub("%.", "_")) | 15 | hardcoded = require("luarocks.core.hardcoded") |
16 | end) | 16 | end) |
17 | 17 | ||
18 | describe("LuaRocks config - basic tests", function() | 18 | describe("LuaRocks config - basic tests", function() |
19 | it("LuaRocks config with no flags/arguments", function() | 19 | it("LuaRocks config with no flags/arguments", function() |
20 | assert.is_false(run.luarocks_bool("config")) | 20 | assert.match("rocks_servers", run.luarocks("config")) |
21 | end) | 21 | end) |
22 | 22 | ||
23 | it("LuaRocks config include dir", function() | 23 | it("LuaRocks config include dir", function() |
24 | local output = run.luarocks("config --lua-incdir") | 24 | local output = run.luarocks("config --lua-incdir") |
25 | if test_env.TEST_TARGET_OS == "windows" then | 25 | if test_env.TEST_TARGET_OS == "windows" then |
26 | assert.are.same(output, site_config.LUA_INCDIR:gsub("\\","/")) | 26 | assert.are.same(output, hardcoded.LUA_INCDIR:gsub("\\","/")) |
27 | else | 27 | else |
28 | assert.are.same(output, site_config.LUA_INCDIR) | 28 | assert.are.same(output, hardcoded.LUA_INCDIR) |
29 | end | 29 | end |
30 | end) | 30 | end) |
31 | 31 | ||
32 | it("LuaRocks config library dir", function() | 32 | it("LuaRocks config library dir", function() |
33 | local output = run.luarocks("config --lua-libdir") | 33 | local output = run.luarocks("config --lua-libdir") |
34 | if test_env.TEST_TARGET_OS == "windows" then | 34 | if test_env.TEST_TARGET_OS == "windows" then |
35 | assert.are.same(output, site_config.LUA_LIBDIR:gsub("\\","/")) | 35 | assert.are.same(output, hardcoded.LUA_LIBDIR:gsub("\\","/")) |
36 | else | 36 | else |
37 | assert.are.same(output, site_config.LUA_LIBDIR) | 37 | assert.are.same(output, hardcoded.LUA_LIBDIR) |
38 | end | 38 | end |
39 | end) | 39 | end) |
40 | 40 | ||