aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-06-26 08:46:22 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-07-01 21:32:39 -0300
commit5d34b03293d7bbdc3376fc04c02634eaca7f6df7 (patch)
treed663d33affa5e25bf6c26c912a14de1fbec11c45
parent78c72078d4e1bc3c7d044c893adf230547bd0657 (diff)
downloadluarocks-5d34b03293d7bbdc3376fc04c02634eaca7f6df7.tar.gz
luarocks-5d34b03293d7bbdc3376fc04c02634eaca7f6df7.tar.bz2
luarocks-5d34b03293d7bbdc3376fc04c02634eaca7f6df7.zip
Tests: config: no need for special-casing Windows
-rw-r--r--spec/config_spec.lua56
-rw-r--r--spec/fetch_spec.lua1
2 files changed, 20 insertions, 37 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua
index e78c3de0..825245b7 100644
--- a/spec/config_spec.lua
+++ b/spec/config_spec.lua
@@ -22,20 +22,12 @@ describe("LuaRocks config tests #integration", function()
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 assert.are.same(hardcoded.LUA_INCDIR, output)
26 assert.are.same(output, hardcoded.LUA_INCDIR:gsub("\\","/"))
27 else
28 assert.are.same(output, hardcoded.LUA_INCDIR)
29 end
30 end) 26 end)
31 27
32 it("LuaRocks config library dir", function() 28 it("LuaRocks config library dir", function()
33 local output = run.luarocks("config --lua-libdir") 29 local output = run.luarocks("config --lua-libdir")
34 if test_env.TEST_TARGET_OS == "windows" then 30 assert.are.same(hardcoded.LUA_LIBDIR, output)
35 assert.are.same(output, hardcoded.LUA_LIBDIR:gsub("\\","/"))
36 else
37 assert.are.same(output, hardcoded.LUA_LIBDIR)
38 end
39 end) 31 end)
40 32
41 it("LuaRocks config lua version", function() 33 it("LuaRocks config lua version", function()
@@ -44,7 +36,7 @@ describe("LuaRocks config tests #integration", function()
44 if test_env.LUAJIT_V then 36 if test_env.LUAJIT_V then
45 lua_version = "5.1" 37 lua_version = "5.1"
46 end 38 end
47 assert.are.same(output, lua_version) 39 assert.are.same(lua_version, output)
48 end) 40 end)
49 41
50 it("LuaRocks config rock trees", function() 42 it("LuaRocks config rock trees", function()
@@ -68,8 +60,10 @@ describe("LuaRocks config tests #integration", function()
68 60
69 it("LuaRocks fail system config", function() 61 it("LuaRocks fail system config", function()
70 os.rename(configfile, configfile .. ".bak") 62 os.rename(configfile, configfile .. ".bak")
63 finally(function()
64 os.rename(configfile .. ".bak", configfile)
65 end)
71 assert.is_false(run.luarocks_bool("config --system-config")) 66 assert.is_false(run.luarocks_bool("config --system-config"))
72 os.rename(configfile .. ".bak", configfile)
73 end) 67 end)
74 68
75 it("LuaRocks system config", function() 69 it("LuaRocks system config", function()
@@ -77,18 +71,15 @@ describe("LuaRocks config tests #integration", function()
77 lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") 71 lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/")
78 lfs.mkdir(scdir) 72 lfs.mkdir(scdir)
79 73
80 if test_env.TEST_TARGET_OS == "windows" then 74 local sysconfig = io.open(configfile, "w+")
81 local output = run.luarocks("config --system-config") 75 sysconfig:write(" ")
82 assert.are.same(output, configfile) 76 sysconfig:close()
83 else 77 finally(function()
84 local sysconfig = io.open(configfile, "w+")
85 sysconfig:write(" ")
86 sysconfig:close()
87
88 local output = run.luarocks("config --system-config")
89 assert.are.same(output, configfile)
90 os.remove(configfile) 78 os.remove(configfile)
91 end 79 end)
80
81 local output = run.luarocks("config --system-config")
82 assert.are.same(configfile, output)
92 end) 83 end)
93 84
94 it("LuaRocks fail system config invalid", function() 85 it("LuaRocks fail system config invalid", function()
@@ -96,20 +87,13 @@ describe("LuaRocks config tests #integration", function()
96 lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") 87 lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/")
97 lfs.mkdir(scdir) 88 lfs.mkdir(scdir)
98 89
99 if test_env.TEST_TARGET_OS == "windows" then 90 local sysconfig = io.open(configfile, "w+")
100 test_env.copy(configfile, "configfile_temp") 91 sysconfig:write("if if if")
101 local sysconfig = io.open(configfile, "w+") 92 sysconfig:close()
102 sysconfig:write("if if if") 93 finally(function()
103 sysconfig:close()
104 assert.is_false(run.luarocks_bool("config --system-config"))
105 test_env.copy("configfile_temp", configfile)
106 else
107 local sysconfig = io.open(configfile, "w+")
108 sysconfig:write("if if if")
109 sysconfig:close()
110 assert.is_false(run.luarocks_bool("config --system-config"))
111 os.remove(configfile) 94 os.remove(configfile)
112 end 95 end)
96 assert.is_false(run.luarocks_bool("config --system-config"))
113 end) 97 end)
114 end) 98 end)
115end) 99end)
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua
index 83797480..cca4fbc7 100644
--- a/spec/fetch_spec.lua
+++ b/spec/fetch_spec.lua
@@ -4,7 +4,6 @@ local git_repo = require("spec.util.git_repo")
4test_env.unload_luarocks() 4test_env.unload_luarocks()
5test_env.setup_specs() 5test_env.setup_specs()
6local cfg = require("luarocks.core.cfg") 6local cfg = require("luarocks.core.cfg")
7local fs = require("luarocks.fs")
8local fetch = require("luarocks.fetch") 7local fetch = require("luarocks.fetch")
9local fs = require("luarocks.fs") 8local fs = require("luarocks.fs")
10local path = require("luarocks.path") 9local path = require("luarocks.path")