aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2021-04-06 17:47:09 -0300
committerHisham Muhammad <hisham@gobolinux.org>2021-04-06 17:47:09 -0300
commit81b28e34e02c3464dc2357bf3b6958f82d3ae823 (patch)
tree70833aa78d91e6bf92eaed35b606dcd8d0634c92 /spec
parent09ed8630f74333eff0bb04ed1dd392fead048347 (diff)
downloadluarocks-81b28e34e02c3464dc2357bf3b6958f82d3ae823.tar.gz
luarocks-81b28e34e02c3464dc2357bf3b6958f82d3ae823.tar.bz2
luarocks-81b28e34e02c3464dc2357bf3b6958f82d3ae823.zip
tests: add basic test for XDG_CONFIG_HOME
Diffstat (limited to 'spec')
-rw-r--r--spec/config_spec.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua
index a14b1ec0..885b022a 100644
--- a/spec/config_spec.lua
+++ b/spec/config_spec.lua
@@ -4,6 +4,7 @@ local run = test_env.run
4local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
5local env_variables = test_env.env_variables 5local env_variables = test_env.env_variables
6local write_file = test_env.write_file 6local write_file = test_env.write_file
7local get_tmp_path = test_env.get_tmp_path
7local hardcoded 8local hardcoded
8 9
9test_env.unload_luarocks() 10test_env.unload_luarocks()
@@ -48,6 +49,30 @@ describe("LuaRocks config tests #integration", function()
48 output = run.luarocks("config --tree=system", {LUAROCKS_CONFIG = "my_config.lua"}) 49 output = run.luarocks("config --tree=system", {LUAROCKS_CONFIG = "my_config.lua"})
49 assert.match([[deploy_lua_dir = "/example/luadir"]], output) 50 assert.match([[deploy_lua_dir = "/example/luadir"]], output)
50 end) 51 end)
52
53 it("#unix can find config via $XDG_CONFIG_HOME", function()
54 local tmpdir = get_tmp_path()
55 lfs.mkdir(tmpdir)
56 lfs.mkdir(tmpdir .. "/luarocks")
57 local tmp_config_file = tmpdir .. "/luarocks/config-" .. test_env.lua_version .. ".lua"
58 write_file(tmp_config_file, [[
59 rocks_trees = {
60 {
61 name = "system",
62 root = "/example/tree",
63 lua_dir = "/example/luadir",
64 },
65 }
66 ]])
67 finally(function()
68 os.remove(tmp_config_file)
69 lfs.rmdir(tmpdir .. "/luarocks")
70 lfs.rmdir(tmpdir)
71 end)
72
73 local output = run.luarocks("config --verbose", {XDG_CONFIG_HOME = tmpdir, LUAROCKS_CONFIG="invalid"})
74 assert.match([[deploy_lua_dir = "/example/luadir"]], output)
75 end)
51 end) 76 end)
52 77
53 describe("query flags", function() 78 describe("query flags", function()