diff options
author | George Roman <george.roman.99@gmail.com> | 2018-07-27 22:29:11 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-31 15:50:22 -0300 |
commit | c02b5989301312dfee02c195497e119bd0c73b85 (patch) | |
tree | 703609129b94dc7d29761aa91558f294dd263956 | |
parent | 0e04e372cb118ca997f7ede59041df934cd939f1 (diff) | |
download | luarocks-c02b5989301312dfee02c195497e119bd0c73b85.tar.gz luarocks-c02b5989301312dfee02c195497e119bd0c73b85.tar.bz2 luarocks-c02b5989301312dfee02c195497e119bd0c73b85.zip |
Tests: refactor and add fixtures for the doc tests
-rw-r--r-- | spec/doc_spec.lua | 158 | ||||
-rw-r--r-- | spec/fixtures/a_repo/a_rock-1.0-1.rockspec | 1 |
2 files changed, 122 insertions, 37 deletions
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index c7cacc94..bf5214d4 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua | |||
@@ -4,13 +4,7 @@ local testing_paths = test_env.testing_paths | |||
4 | 4 | ||
5 | test_env.unload_luarocks() | 5 | test_env.unload_luarocks() |
6 | 6 | ||
7 | local extra_rocks = { | ||
8 | "/luarepl-0.4-1.src.rock", | ||
9 | "/c3-1.0-1.src.rock" | ||
10 | } | ||
11 | |||
12 | describe("LuaRocks doc tests #integration", function() | 7 | describe("LuaRocks doc tests #integration", function() |
13 | |||
14 | before_each(function() | 8 | before_each(function() |
15 | test_env.setup_specs(extra_rocks) | 9 | test_env.setup_specs(extra_rocks) |
16 | end) | 10 | end) |
@@ -19,23 +13,57 @@ describe("LuaRocks doc tests #integration", function() | |||
19 | it("LuaRocks doc with no flags/arguments", function() | 13 | it("LuaRocks doc with no flags/arguments", function() |
20 | assert.is_false(run.luarocks_bool("doc")) | 14 | assert.is_false(run.luarocks_bool("doc")) |
21 | end) | 15 | end) |
16 | |||
22 | it("LuaRocks doc with invalid argument", function() | 17 | it("LuaRocks doc with invalid argument", function() |
23 | assert.is_false(run.luarocks_bool("doc invalid")) | 18 | assert.is_false(run.luarocks_bool("doc invalid")) |
24 | end) | 19 | end) |
25 | it("LuaRocks doc with no homepage", function() | 20 | |
26 | assert.is_true(run.luarocks_bool("install c3")) | 21 | it("LuaRocks doc with no homepage and no doc folder", function() |
27 | assert.is_false(run.luarocks_bool("doc c3 --home")) | 22 | test_env.run_in_tmp(function(tmpdir) |
28 | end) | 23 | test_env.write_file("test-1.0-1.rockspec", [[ |
29 | it("LuaRocks doc with no home page and no doc folder", function() | 24 | package = "test" |
30 | assert.is_true(run.luarocks_bool("install c3")) | 25 | version = "1.0-1" |
31 | test_env.remove_dir(testing_paths.testing_sys_rocks .. "/c3/1.0-1/doc") | 26 | source = { |
32 | assert.is_false(run.luarocks_bool("doc c3")) | 27 | url = "file://test.lua" |
28 | } | ||
29 | build = { | ||
30 | type = "builtin", | ||
31 | modules = { | ||
32 | test = "test.lua" | ||
33 | } | ||
34 | } | ||
35 | ]], finally) | ||
36 | test_env.write_file("test.lua", "return {}", finally) | ||
37 | |||
38 | assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec")) | ||
39 | assert.is_false(run.luarocks_bool("doc test --home")) | ||
40 | end, finally) | ||
33 | end) | 41 | end) |
34 | it("LuaRocks doc with no doc folder opening descript.homepage", function() | 42 | |
35 | assert.is_true(run.luarocks_bool("install luarepl")) | 43 | it("LuaRocks doc with no doc folder but with homepage", function() |
36 | test_env.remove_dir(testing_paths.testing_sys_rocks .. "/luarepl/0.4-1/doc") | 44 | test_env.run_in_tmp(function(tmpdir) |
37 | local output = run.luarocks("doc luarepl") | 45 | test_env.write_file("test-1.0-1.rockspec", [[ |
38 | assert.is.truthy(output:find("Local documentation directory not found")) | 46 | package = "test" |
47 | version = "1.0-1" | ||
48 | source = { | ||
49 | url = "file://test.lua" | ||
50 | } | ||
51 | description = { | ||
52 | homepage = "http://www.example.com" | ||
53 | } | ||
54 | build = { | ||
55 | type = "builtin", | ||
56 | modules = { | ||
57 | test = "test.lua" | ||
58 | } | ||
59 | } | ||
60 | ]], finally) | ||
61 | test_env.write_file("test.lua", "return {}", finally) | ||
62 | |||
63 | assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec")) | ||
64 | local output = assert.is.truthy(run.luarocks("doc test")) | ||
65 | assert.is.truthy(output:find("documentation directory not found")) | ||
66 | end, finally) | ||
39 | end) | 67 | end) |
40 | end) | 68 | end) |
41 | 69 | ||
@@ -48,30 +76,86 @@ describe("LuaRocks doc tests #integration", function() | |||
48 | end) | 76 | end) |
49 | 77 | ||
50 | describe("LuaRocks doc tests with flags", function() | 78 | describe("LuaRocks doc tests with flags", function() |
51 | it("LuaRocks doc of installed luarepl", function() | 79 | it("LuaRocks doc of installed package", function() |
52 | assert.is_true(run.luarocks_bool("install luarepl")) | 80 | test_env.run_in_tmp(function(tmpdir) |
53 | assert.is_true(run.luarocks_bool("doc luarepl")) | 81 | test_env.write_file("test-1.0-1.rockspec", [[ |
54 | end) | 82 | package = "test" |
83 | version = "1.0-1" | ||
84 | source = { | ||
85 | url = "file://test.lua" | ||
86 | } | ||
87 | build = { | ||
88 | type = "builtin", | ||
89 | modules = { | ||
90 | test = "test.lua" | ||
91 | } | ||
92 | } | ||
93 | ]], finally) | ||
94 | test_env.write_file("test.lua", "return {}", finally) | ||
55 | 95 | ||
56 | it("LuaRocks doc of luacov and access its home page", function() | 96 | assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec")) |
57 | assert.is_true(run.luarocks_bool("install luacov")) | 97 | lfs.mkdir(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc") |
58 | assert.is_true(run.luarocks_bool("doc luacov --home")) | 98 | test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc.md", "", finally) |
99 | test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/readme.md", "", finally) | ||
100 | assert.is_true(run.luarocks_bool("doc test")) | ||
101 | end, finally) | ||
59 | end) | 102 | end) |
60 | 103 | ||
61 | it("LuaRocks doc of luacov and list doc folder", function() | 104 | it("LuaRocks doc with --list", function() |
62 | assert.is_true(run.luarocks_bool("install luacov")) | 105 | test_env.run_in_tmp(function(tmpdir) |
63 | local output = assert.is.truthy(run.luarocks("doc luacov --list")) | 106 | test_env.write_file("test-1.0-1.rockspec", [[ |
64 | assert.is.truthy(output:find("/lib/luarocks/rocks%-.*/luacov/0.11.0%-1/doc/", 1)) | 107 | package = "test" |
108 | version = "1.0-1" | ||
109 | source = { | ||
110 | url = "file://test.lua" | ||
111 | } | ||
112 | build = { | ||
113 | type = "builtin", | ||
114 | modules = { | ||
115 | test = "test.lua" | ||
116 | } | ||
117 | } | ||
118 | ]], finally) | ||
119 | test_env.write_file("test.lua", "return {}", finally) | ||
120 | |||
121 | assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec")) | ||
122 | lfs.mkdir(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc") | ||
123 | test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc1.md", "", finally) | ||
124 | test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc2.md", "", finally) | ||
125 | local output = assert.is.truthy(run.luarocks("doc test --list")) | ||
126 | assert.is.truthy(output:find("doc1%.md")) | ||
127 | assert.is.truthy(output:find("doc2%.md")) | ||
128 | end, finally) | ||
65 | end) | 129 | end) |
66 | 130 | ||
67 | it("LuaRocks doc of luacov local", function() | 131 | it("LuaRocks doc with --local", function() |
68 | assert.is_true(run.luarocks_bool("install luacov")) | 132 | assert.is_true(run.luarocks_bool("install --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock")) |
69 | assert.is_true(run.luarocks_bool("doc luacov --local")) | 133 | assert.is_true(run.luarocks_bool("doc --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock --local")) |
70 | end) | 134 | end) |
71 | 135 | ||
72 | it("LuaRocks doc of luacov porcelain", function() | 136 | it("LuaRocks doc with --porcelain", function() |
73 | assert.is_true(run.luarocks_bool("install luacov")) | 137 | test_env.run_in_tmp(function(tmpdir) |
74 | assert.is_true(run.luarocks_bool("doc luacov --porcelain")) | 138 | test_env.write_file("test-1.0-1.rockspec", [[ |
139 | package = "test" | ||
140 | version = "1.0-1" | ||
141 | source = { | ||
142 | url = "file://test.lua" | ||
143 | } | ||
144 | build = { | ||
145 | type = "builtin", | ||
146 | modules = { | ||
147 | test = "test.lua" | ||
148 | } | ||
149 | } | ||
150 | ]], finally) | ||
151 | test_env.write_file("test.lua", "return {}", finally) | ||
152 | |||
153 | assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec")) | ||
154 | lfs.mkdir(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc") | ||
155 | test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc1.md", "", finally) | ||
156 | test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc2.md", "", finally) | ||
157 | assert.is_true(run.luarocks_bool("doc test --porcelain")) | ||
158 | end, finally) | ||
75 | end) | 159 | end) |
76 | end) | 160 | end) |
77 | end) | 161 | end) |
diff --git a/spec/fixtures/a_repo/a_rock-1.0-1.rockspec b/spec/fixtures/a_repo/a_rock-1.0-1.rockspec index 9f15e87a..69d78209 100644 --- a/spec/fixtures/a_repo/a_rock-1.0-1.rockspec +++ b/spec/fixtures/a_repo/a_rock-1.0-1.rockspec | |||
@@ -5,6 +5,7 @@ source = { | |||
5 | } | 5 | } |
6 | description = { | 6 | description = { |
7 | summary = "An example rockspec", | 7 | summary = "An example rockspec", |
8 | homepage = "http://www.example.com" | ||
8 | } | 9 | } |
9 | dependencies = { | 10 | dependencies = { |
10 | "lua >= 5.1" | 11 | "lua >= 5.1" |