aboutsummaryrefslogtreecommitdiff
path: root/spec/unpack_spec.lua
diff options
context:
space:
mode:
authorrobooo <robo.karasek@gmail.com>2016-07-07 21:58:19 +0200
committerHisham Muhammad <hisham@gobolinux.org>2016-07-07 16:58:19 -0300
commit5af7e0d7c2dcf65e41ae8523f3771e9528be32a7 (patch)
treebcd14624e0566a23da2e708675197d212cecf35d /spec/unpack_spec.lua
parentb5b285a678fe78b80d452cc9eb7565b8bf087b81 (diff)
downloadluarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.tar.gz
luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.tar.bz2
luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.zip
New test-suite for LuaRocks (#581)
First version of new test-suite, using Busted framework based on Google Summer of Code project: https://summerofcode.withgoogle.com/projects/#5695811874717696 * Rewritten from Bash to Lua * Tests now check if they did what they were supposed to, beyond only checking success or failure of the `luarocks` command * Support for black-box (launching `luarocks` as an external command) and white-box (testing functions in modules directly) testing
Diffstat (limited to 'spec/unpack_spec.lua')
-rw-r--r--spec/unpack_spec.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua
new file mode 100644
index 00000000..efe902f5
--- /dev/null
+++ b/spec/unpack_spec.lua
@@ -0,0 +1,61 @@
1local test_env = require("test/test_environment")
2local lfs = require("lfs")
3
4test_env.unload_luarocks()
5local unpack = require("luarocks.unpack")
6
7local extra_rocks = {
8 "/cprint-0.1-2.src.rock",
9 "/cprint-0.1-2.rockspec"
10}
11
12expose("LuaRocks unpack tests #blackbox #b_unpack", function()
13
14 before_each(function()
15 test_env.setup_specs(extra_rocks)
16 testing_paths = test_env.testing_paths
17 run = test_env.run
18 platform = test_env.platform
19 end)
20
21 describe("LuaRocks unpack basic fail tests", function()
22 it("LuaRocks unpack with no flags/arguments", function()
23 assert.is_false(run.luarocks_bool("unpack"))
24 end)
25 it("LuaRocks unpack with invalid rockspec", function()
26 assert.is_false(run.luarocks_bool("unpack invalid.rockspec"))
27 end)
28 it("LuaRocks unpack with invalid patch", function()
29 assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec"))
30 end)
31 end)
32
33 describe("LuaRocks unpack more complex tests", function()
34 it("LuaRocks unpack download", function()
35 assert.is_true(run.luarocks_bool("unpack cprint"))
36 test_env.remove_dir("cprint-0.1-2")
37 end)
38 it("LuaRocks unpack src", function()
39 assert.is_true(run.luarocks_bool("download --source cprint"))
40 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock"))
41 os.remove("cprint-0.1-2.src.rock")
42 test_env.remove_dir("cprint-0.1-2")
43 end)
44 it("LuaRocks unpack src", function()
45 assert.is_true(run.luarocks_bool("download --rockspec cprint"))
46 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec"))
47 os.remove("cprint-0.1-2.rockspec")
48 os.remove("lua-cprint")
49 test_env.remove_dir("cprint-0.1-2")
50 end)
51 it("LuaRocks unpack binary", function()
52 assert.is_true(run.luarocks_bool("build cprint"))
53 assert.is_true(run.luarocks_bool("pack cprint"))
54 assert.is_true(run.luarocks_bool("unpack cprint-0.1-2." .. platform .. ".rock"))
55 test_env.remove_dir("cprint-0.1-2")
56 os.remove("cprint-0.1-2." .. platform .. ".rock")
57 end)
58 end)
59end)
60
61