aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorPeter Melnichenko <mpeterval@gmail.com>2016-11-04 12:48:01 +0300
committerPeter Melnichenko <mpeterval@gmail.com>2016-11-04 12:48:01 +0300
commit6606ae90f54bc142a2129f491b0aad8e7352b18d (patch)
treeb0b82ac5307cf4d4c254199faf129e896b7fe909 /spec
parentdcf9bf6248e4ead25eb1981631021a72a7875a19 (diff)
parentbfab09559cdbbc7e163490129ac7d3c4060b905d (diff)
downloadluarocks-6606ae90f54bc142a2129f491b0aad8e7352b18d.tar.gz
luarocks-6606ae90f54bc142a2129f491b0aad8e7352b18d.tar.bz2
luarocks-6606ae90f54bc142a2129f491b0aad8e7352b18d.zip
Merge branch 'master' into luarocks-3
Diffstat (limited to 'spec')
-rw-r--r--spec/make_spec.lua69
-rw-r--r--spec/persist.lua55
2 files changed, 123 insertions, 1 deletions
diff --git a/spec/make_spec.lua b/spec/make_spec.lua
index ae79a29c..89036d26 100644
--- a/spec/make_spec.lua
+++ b/spec/make_spec.lua
@@ -2,11 +2,11 @@ local test_env = require("test/test_environment")
2local lfs = require("lfs") 2local lfs = require("lfs")
3local run = test_env.run 3local 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
5 6
6test_env.unload_luarocks() 7test_env.unload_luarocks()
7 8
8local extra_rocks = { 9local extra_rocks = {
9 "lpeg-1.0.0-1.rockspec",
10 "/luasocket-3.0rc1-2.src.rock", 10 "/luasocket-3.0rc1-2.src.rock",
11 "/luasocket-3.0rc1-2.rockspec", 11 "/luasocket-3.0rc1-2.rockspec",
12 "/lxsh-0.8.6-2.src.rock", 12 "/lxsh-0.8.6-2.src.rock",
@@ -98,4 +98,71 @@ describe("LuaRocks make tests #blackbox #b_make", function()
98 assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) 98 assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock"))
99 end) 99 end)
100 end) 100 end)
101
102 describe("LuaRocks make upgrading rockspecs with mixed deploy types", function()
103 setup(function()
104 test_env.copy_dir(testing_paths.testing_dir .. "/testfiles/mixed_deploy_type", "mdt")
105 end)
106
107 teardown(function()
108 test_env.remove_dir("mdt")
109 os.remove("mdt."..test_env.lib_extension)
110 end)
111
112 it("modules with same name from lua/ and lib/ when upgrading", function()
113 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec"))
114 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
115 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
116
117 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec"))
118 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension))
119 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
120 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
121 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
122 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua"))
123 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file"))
124 end)
125
126 it("modules with same name from lua/ and lib/ when upgrading with --keep", function()
127 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec"))
128 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
129 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
130
131 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec --keep"))
132 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension))
133 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
134 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
135 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
136 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua"))
137 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file"))
138 end)
139
140 it("modules with same name from lua/ and lib/ when downgrading", function()
141 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec"))
142 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension))
143 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
144
145 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec"))
146 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension))
147 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
148 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt."..test_env.lib_extension))
149 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file"))
150 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
151 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
152 end)
153
154 it("modules with same name from lua/ and lib/ when downgrading with --keep", function()
155 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.2.0-1.rockspec"))
156 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension))
157 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
158
159 assert.is_true(run.luarocks_bool("make mdt/mixed_deploy_type-0.1.0-1.rockspec --keep"))
160 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt."..test_env.lib_extension))
161 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
162 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt.lua"))
163 assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mdt_file"))
164 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt.lua"))
165 assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/mixed_deploy_type_0_1_0_1-mdt_file"))
166 end)
167 end)
101end) 168end)
diff --git a/spec/persist.lua b/spec/persist.lua
new file mode 100644
index 00000000..6b69dab4
--- /dev/null
+++ b/spec/persist.lua
@@ -0,0 +1,55 @@
1local test_env = require("test/test_environment")
2
3test_env.unload_luarocks()
4local persist = require("luarocks.persist")
5
6describe("Luarocks persist test #whitebox #w_persist", function()
7 describe("persist.save_from_table_to_string", function()
8 it("simple table", function()
9 assert.are.same([[
10bar = 1234
11foo = "string"
12]], persist.save_from_table_to_string({foo = "string", bar = 1234}))
13 end)
14
15 it("nested tables", function()
16 assert.are.same([[
17bar = {
18 baz = "string"
19}
20foo = {
21 1, 2, 3, 4
22}
23]], persist.save_from_table_to_string({foo = {1, 2, 3, 4}, bar = {baz = "string"}}))
24 end)
25
26 it("strings with quotes", function()
27 assert.are.same([[
28bar = "a \\backslash?"
29foo = "a \"quote\"?"
30]], persist.save_from_table_to_string({foo = 'a "quote"?', bar = 'a \\backslash?'}))
31 end)
32
33 it("multiline strings", function()
34 assert.are.same([===[
35bar = [==[
36]]
37]=]]==]
38foo = [[
39First line
40Second line]]
41]===], persist.save_from_table_to_string({foo = "First line\nSecond line", bar = "]]\n]=]"}))
42 end)
43
44 it("multiline strings ending with brackets", function()
45 assert.are.same([===[
46bar = [==[
47]]
48]=]==]
49foo = [=[
50First line
51Second line [1]]=]
52]===], persist.save_from_table_to_string({foo = "First line\nSecond line [1]", bar = "]]\n]="}))
53 end)
54 end)
55end)