diff options
author | robooo <robo.karasek@gmail.com> | 2016-07-07 21:58:19 +0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2016-07-07 16:58:19 -0300 |
commit | 5af7e0d7c2dcf65e41ae8523f3771e9528be32a7 (patch) | |
tree | bcd14624e0566a23da2e708675197d212cecf35d /spec/write_rockspec_spec.lua | |
parent | b5b285a678fe78b80d452cc9eb7565b8bf087b81 (diff) | |
download | luarocks-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/write_rockspec_spec.lua')
-rw-r--r-- | spec/write_rockspec_spec.lua | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua new file mode 100644 index 00000000..d6e32f15 --- /dev/null +++ b/spec/write_rockspec_spec.lua | |||
@@ -0,0 +1,74 @@ | |||
1 | local test_env = require("test/test_environment") | ||
2 | local lfs = require("lfs") | ||
3 | |||
4 | test_env.unload_luarocks() | ||
5 | local write_rockspec = require("luarocks.write_rockspec") | ||
6 | |||
7 | expose("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | ||
8 | |||
9 | before_each(function() | ||
10 | test_env.setup_specs(extra_rocks) | ||
11 | run = test_env.run | ||
12 | end) | ||
13 | |||
14 | describe("LuaRocks write_rockspec basic tests", function() | ||
15 | it("LuaRocks write_rockspec with no flags/arguments", function() | ||
16 | assert.is_true(run.luarocks_bool("write_rockspec")) | ||
17 | os.remove("luarocks-scm-1.rockspec") | ||
18 | end) | ||
19 | |||
20 | it("LuaRocks write_rockspec with invalid argument", function() | ||
21 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) | ||
22 | end) | ||
23 | |||
24 | it("LuaRocks write_rockspec invalid zip", function() | ||
25 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) | ||
26 | end) | ||
27 | end) | ||
28 | |||
29 | describe("LuaRocks write_rockspec more complex tests", function() | ||
30 | it("LuaRocks write_rockspec git luarocks", function() | ||
31 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks")) | ||
32 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
33 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
34 | end) | ||
35 | |||
36 | it("LuaRocks write_rockspec git luarocks --tag=v2.3.0", function() | ||
37 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks --tag=v2.3.0")) | ||
38 | assert.is.truthy(lfs.attributes("luarocks-2.3.0-1.rockspec")) | ||
39 | assert.is_true(os.remove("luarocks-2.3.0-1.rockspec")) | ||
40 | end) | ||
41 | |||
42 | it("LuaRocks write_rockspec git luarocks with format flag", function() | ||
43 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2")) | ||
44 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
45 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
46 | end) | ||
47 | |||
48 | it("LuaRocks write_rockspec git luarocks with full flags", function() | ||
49 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --lua-version=5.1,5.2 --license=\"MIT/X11\" " | ||
50 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) | ||
51 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
52 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
53 | end) | ||
54 | |||
55 | it("LuaRocks write_rockspec rockspec via http", function() | ||
56 | assert.is_true(run.luarocks_bool("write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1")) | ||
57 | assert.is.truthy(lfs.attributes("luarocks-2.1.0-1.rockspec")) | ||
58 | assert.is_true(os.remove("luarocks-2.1.0-1.rockspec")) | ||
59 | end) | ||
60 | |||
61 | it("LuaRocks write_rockspec base dir, luassert.tar.gz via https", function() | ||
62 | assert.is_true(run.luarocks_bool("write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1")) | ||
63 | assert.is.truthy(lfs.attributes("luassert-1.2-1.rockspec")) | ||
64 | assert.is_true(os.remove("luassert-1.2-1.rockspec")) | ||
65 | end) | ||
66 | |||
67 | it("LuaRocks write_rockspec git luafcgi with many flags", function() | ||
68 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " | ||
69 | .. "--lua-version=5.1,5.2")) | ||
70 | assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags? | ||
71 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) | ||
72 | end) | ||
73 | end) | ||
74 | end) \ No newline at end of file | ||