diff options
-rw-r--r-- | src/luarocks/config_cmd.lua | 17 | ||||
-rw-r--r-- | test/testing.lua | 33 | ||||
-rwxr-xr-x | test/testing.sh | 1 |
3 files changed, 49 insertions, 2 deletions
diff --git a/src/luarocks/config_cmd.lua b/src/luarocks/config_cmd.lua index c066cfec..bf282a7a 100644 --- a/src/luarocks/config_cmd.lua +++ b/src/luarocks/config_cmd.lua | |||
@@ -6,6 +6,22 @@ local cfg = require("luarocks.cfg") | |||
6 | local util = require("luarocks.util") | 6 | local util = require("luarocks.util") |
7 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
8 | 8 | ||
9 | config_cmd.help_summary = "Query information about the LuaRocks configuration." | ||
10 | config_cmd.help_arguments = "<flag>" | ||
11 | config_cmd.help = [[ | ||
12 | --lua-incdir Path to Lua header files. | ||
13 | |||
14 | --lua-libdir Path to Lua library files. | ||
15 | |||
16 | --lua-ver Lua version (in major.minor format). e.g. 5.1 | ||
17 | |||
18 | --system-config Location of the system config file. | ||
19 | |||
20 | --user-config Location of the user config file. | ||
21 | |||
22 | --rock-trees Rocks trees in use. First the user tree, then the system tree. | ||
23 | ]] | ||
24 | |||
9 | local function config_file(conf) | 25 | local function config_file(conf) |
10 | print(dir.normalize(conf.file)) | 26 | print(dir.normalize(conf.file)) |
11 | if conf.ok then | 27 | if conf.ok then |
@@ -39,7 +55,6 @@ function config_cmd.run(...) | |||
39 | if flags["user-config"] then | 55 | if flags["user-config"] then |
40 | return config_file(conf.user) | 56 | return config_file(conf.user) |
41 | end | 57 | end |
42 | |||
43 | if flags["rock-trees"] then | 58 | if flags["rock-trees"] then |
44 | for _, tree in ipairs(cfg.rocks_trees) do | 59 | for _, tree in ipairs(cfg.rocks_trees) do |
45 | if type(tree) == "string" then | 60 | if type(tree) == "string" then |
diff --git a/test/testing.lua b/test/testing.lua index 48d4ac0e..50911fd4 100644 --- a/test/testing.lua +++ b/test/testing.lua | |||
@@ -50,6 +50,10 @@ local function glob(patt) | |||
50 | -- TODO | 50 | -- TODO |
51 | end | 51 | end |
52 | 52 | ||
53 | local function touch(filename) | ||
54 | -- TODO | ||
55 | end | ||
56 | |||
53 | local function rm(...) | 57 | local function rm(...) |
54 | for _, filename in ipairs {...} do | 58 | for _, filename in ipairs {...} do |
55 | filename = expand_variables(filename) | 59 | filename = expand_variables(filename) |
@@ -397,7 +401,7 @@ local tests = { | |||
397 | local found = run_get_contents '$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg' | 401 | local found = run_get_contents '$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg' |
398 | rm_rf "./lxsh-${verrev_lxsh}" | 402 | rm_rf "./lxsh-${verrev_lxsh}" |
399 | return found ~= "" | 403 | return found ~= "" |
400 | end, | 404 | end, |
401 | test_write_rockspec = function() return run "$luarocks write_rockspec git://github.com/keplerproject/luarocks" end, | 405 | test_write_rockspec = function() return run "$luarocks write_rockspec git://github.com/keplerproject/luarocks" end, |
402 | test_write_rockspec_lib = function() return run '$luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2' end, | 406 | test_write_rockspec_lib = function() return run '$luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2' end, |
403 | test_write_rockspec_format = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2' end, | 407 | test_write_rockspec_format = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2' end, |
@@ -406,6 +410,33 @@ local tests = { | |||
406 | fail_write_rockspec_args_url = function() return run "$luarocks write_rockspec http://example.com/invalid.zip" end, | 410 | fail_write_rockspec_args_url = function() return run "$luarocks write_rockspec http://example.com/invalid.zip" end, |
407 | test_write_rockspec_http = function() return run "$luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1" end, | 411 | test_write_rockspec_http = function() return run "$luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1" end, |
408 | test_write_rockspec_basedir = function() return run "$luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1" end, | 412 | test_write_rockspec_basedir = function() return run "$luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1" end, |
413 | |||
414 | fail_config_noflags = function() return run "$luarocks config; " end, | ||
415 | test_config_lua_incdir = function() return run "$luarocks config --lua-incdir; " end, | ||
416 | test_config_lua_libdir = function() return run "$luarocks config --lua-libdir; " end, | ||
417 | test_config_lua_ver = function() return run "$luarocks config --lua-ver; " end, | ||
418 | fail_config_system_config = function() | ||
419 | return rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
420 | and run "$luarocks config --system-config; " | ||
421 | end, | ||
422 | test_config_system_config = function() | ||
423 | local ok = mkdir "$testing_lrprefix/etc/luarocks" | ||
424 | and touch "$testing_lrprefix/etc/luarocks/config.lua" | ||
425 | and run "$luarocks config --system-config; " | ||
426 | rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
427 | return ok | ||
428 | end, | ||
429 | fail_config_system_config_invalid = function() | ||
430 | local ok = mkdir "$testing_lrprefix/etc/luarocks" | ||
431 | and run "echo 'if if if' > '$testing_lrprefix/etc/luarocks/config.lua' ;" | ||
432 | and run "$luarocks config --system-config" | ||
433 | rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
434 | return ok | ||
435 | end, | ||
436 | test_config_user_config = function() return run "$luarocks config --user-config; " end, | ||
437 | fail_config_user_config = function() return run "LUAROCKS_CONFIG='/missing_file.lua' $luarocks config --user-config; " end, | ||
438 | test_config_rock_trees = function() return run "$luarocks config --rock-trees;" end, | ||
439 | test_config_help = function() return run "$luarocks help config;" end, | ||
409 | test_doc = function() | 440 | test_doc = function() |
410 | return run "$luarocks install luarepl" | 441 | return run "$luarocks install luarepl" |
411 | and run "$luarocks doc luarepl" | 442 | and run "$luarocks doc luarepl" |
diff --git a/test/testing.sh b/test/testing.sh index c43b4d52..133597ee 100755 --- a/test/testing.sh +++ b/test/testing.sh | |||
@@ -509,6 +509,7 @@ fail_config_system_config_invalid() { mkdir -p "$testing_lrprefix/etc/luarocks"; | |||
509 | test_config_user_config() { $luarocks config --user-config; } | 509 | test_config_user_config() { $luarocks config --user-config; } |
510 | fail_config_user_config() { LUAROCKS_CONFIG="/missing_file.lua" $luarocks config --user-config; } | 510 | fail_config_user_config() { LUAROCKS_CONFIG="/missing_file.lua" $luarocks config --user-config; } |
511 | test_config_rock_trees() { $luarocks config --rock-trees; } | 511 | test_config_rock_trees() { $luarocks config --rock-trees; } |
512 | test_config_help() { $luarocks help config; } | ||
512 | 513 | ||
513 | test_doc() { $luarocks install luarepl; $luarocks doc luarepl; } | 514 | test_doc() { $luarocks install luarepl; $luarocks doc luarepl; } |
514 | 515 | ||