diff options
Diffstat (limited to 'spec/write_rockspec_spec.lua')
-rw-r--r-- | spec/write_rockspec_spec.lua | 107 |
1 files changed, 69 insertions, 38 deletions
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 9ee86ada..e4a7fa73 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua | |||
@@ -1,8 +1,9 @@ | |||
1 | local test_env = require("spec.util.test_env") | 1 | local test_env = require("spec.util.test_env") |
2 | local git_repo = require("spec.util.git_repo") | ||
2 | local lfs = require("lfs") | 3 | local lfs = require("lfs") |
3 | local run = test_env.run | 4 | local run = test_env.run |
4 | 5 | ||
5 | test_env.unload_luarocks() | 6 | local extra_rocks = test_env.mock_server_extra_rocks() |
6 | 7 | ||
7 | describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | 8 | describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() |
8 | 9 | ||
@@ -10,63 +11,93 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | |||
10 | test_env.setup_specs() | 11 | test_env.setup_specs() |
11 | end) | 12 | end) |
12 | 13 | ||
13 | describe("LuaRocks write_rockspec basic tests", function() | 14 | it("runs with no flags/arguments", function() |
14 | it("LuaRocks write_rockspec with no flags/arguments", function() | 15 | local d = lfs.currentdir() |
15 | assert.is_true(run.luarocks_bool("write_rockspec")) | 16 | finally(function() |
16 | os.remove("luarocks-dev-1.rockspec") | 17 | os.remove("testrock-dev-1.rockspec") |
18 | lfs.chdir(d) | ||
17 | end) | 19 | end) |
20 | lfs.chdir("..") | ||
21 | assert.is_true(run.luarocks_bool("write_rockspec")) | ||
22 | end) | ||
18 | 23 | ||
19 | it("LuaRocks write_rockspec with invalid argument", function() | 24 | it("fails with invalid argument", function() |
20 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) | 25 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) |
26 | end) | ||
27 | |||
28 | it("fails with invalid zip", function() | ||
29 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) | ||
30 | end) | ||
31 | |||
32 | describe("from #git #unix", function() | ||
33 | local git | ||
34 | |||
35 | setup(function() | ||
36 | git = git_repo.start() | ||
21 | end) | 37 | end) |
22 | 38 | ||
23 | it("LuaRocks write_rockspec invalid zip", function() | 39 | teardown(function() |
24 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) | 40 | git:stop() |
25 | end) | 41 | end) |
26 | end) | ||
27 | 42 | ||
28 | describe("LuaRocks write_rockspec more complex tests", function() | 43 | it("runs", function() |
29 | it("LuaRocks write_rockspec git luarocks", function() | 44 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
30 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/luarocks/testrock")) | 45 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock")) |
31 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 46 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
32 | assert.is_true(os.remove("testrock-dev-1.rockspec")) | ||
33 | end) | 47 | end) |
34 | 48 | ||
35 | it("LuaRocks write_rockspec git luarocks --tag=v2.3.0", function() | 49 | it("runs with --tag", function() |
36 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/luarocks/testrock --tag=v2.3.0")) | 50 | finally(function() os.remove("testrock-2.3.0-1.rockspec") end) |
51 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --tag=v2.3.0")) | ||
37 | assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec")) | 52 | assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec")) |
38 | assert.is_true(os.remove("testrock-2.3.0-1.rockspec")) | 53 | -- TODO check contents |
39 | end) | 54 | end) |
40 | 55 | ||
41 | it("LuaRocks write_rockspec git luarocks with format flag", function() | 56 | it("runs with format flag", function() |
42 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/luarocks/testrock --rockspec-format=1.1 --lua-version=5.1,5.2")) | 57 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
58 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --rockspec-format=1.1 --lua-version=5.1,5.2")) | ||
43 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 59 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
44 | assert.is_true(os.remove("testrock-dev-1.rockspec")) | 60 | -- TODO check contents |
45 | end) | 61 | end) |
46 | 62 | ||
47 | it("LuaRocks write_rockspec git luarocks with full flags", function() | 63 | it("runs with full flags", function() |
48 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/luarocks/testrock --lua-version=5.1,5.2 --license=\"MIT/X11\" " | 64 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
65 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --lua-version=5.1,5.2 --license=\"MIT/X11\" " | ||
49 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) | 66 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) |
50 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 67 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
51 | assert.is_true(os.remove("testrock-dev-1.rockspec")) | 68 | -- TODO check contents |
52 | end) | 69 | end) |
53 | 70 | ||
54 | it("LuaRocks write_rockspec rockspec via http", function() | 71 | it("with various flags", function() |
55 | assert.is_true(run.luarocks_bool("write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1")) | 72 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
56 | assert.is.truthy(lfs.attributes("luarocks-2.1.0-1.rockspec")) | 73 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2")) |
57 | assert.is_true(os.remove("luarocks-2.1.0-1.rockspec")) | 74 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
75 | -- TODO check contents | ||
58 | end) | 76 | end) |
59 | 77 | end) | |
60 | it("LuaRocks write_rockspec base dir, luassert.tar.gz via https", function() | 78 | |
61 | assert.is_true(run.luarocks_bool("write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1")) | 79 | describe("from tarball #mock", function() |
62 | assert.is.truthy(lfs.attributes("luassert-1.2-1.rockspec")) | 80 | |
63 | assert.is_true(os.remove("luassert-1.2-1.rockspec")) | 81 | setup(function() |
82 | test_env.setup_specs(extra_rocks) | ||
83 | test_env.mock_server_init() | ||
64 | end) | 84 | end) |
65 | 85 | teardown(function() | |
66 | it("LuaRocks write_rockspec git luafcgi with many flags", function() | 86 | test_env.mock_server_done() |
67 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/arcapos/luafcgi --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2")) | 87 | end) |
68 | assert.is.truthy(lfs.attributes("luafcgi-dev-1.rockspec")) -- TODO maybe read it content and find arguments from flags? | 88 | |
69 | assert.is_true(os.remove("luafcgi-dev-1.rockspec")) | 89 | it("via http", function() |
90 | finally(function() os.remove("an_upstream_tarball-0.1-1.rockspec") end) | ||
91 | assert.is_true(run.luarocks_bool("write_rockspec http://localhost:8080/file/an_upstream_tarball-0.1.tar.gz --lua-version=5.1")) | ||
92 | assert.is.truthy(lfs.attributes("an_upstream_tarball-0.1-1.rockspec")) | ||
93 | -- TODO check contents | ||
94 | end) | ||
95 | |||
96 | it("with a different basedir", function() | ||
97 | finally(function() os.remove("renamed_upstream_tarball-0.1-1.rockspec") end) | ||
98 | assert.is_true(run.luarocks_bool("write_rockspec http://localhost:8080/file/renamed_upstream_tarball-0.1.tar.gz --lua-version=5.1")) | ||
99 | assert.is.truthy(lfs.attributes("renamed_upstream_tarball-0.1-1.rockspec")) | ||
100 | -- TODO check contents | ||
70 | end) | 101 | end) |
71 | end) | 102 | end) |
72 | end) | 103 | end) |