1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
local test_env = require("spec.util.test_env")
local run = test_env.run
local testing_paths = test_env.testing_paths
test_env.unload_luarocks()
describe("LuaRocks doc tests #integration", function()
before_each(function()
test_env.setup_specs(extra_rocks)
end)
describe("LuaRocks doc basic tests", function()
it("LuaRocks doc with no flags/arguments", function()
assert.is_false(run.luarocks_bool("doc"))
end)
it("LuaRocks doc with invalid argument", function()
assert.is_false(run.luarocks_bool("doc invalid"))
end)
it("LuaRocks doc with no homepage and no doc folder", function()
test_env.run_in_tmp(function(tmpdir)
test_env.write_file("test-1.0-1.rockspec", [[
package = "test"
version = "1.0-1"
source = {
url = "file://test.lua"
}
build = {
type = "builtin",
modules = {
test = "test.lua"
}
}
]], finally)
test_env.write_file("test.lua", "return {}", finally)
assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec"))
assert.is_false(run.luarocks_bool("doc test --home"))
end, finally)
end)
it("LuaRocks doc with no doc folder but with homepage", function()
test_env.run_in_tmp(function(tmpdir)
test_env.write_file("test-1.0-1.rockspec", [[
package = "test"
version = "1.0-1"
source = {
url = "file://test.lua"
}
description = {
homepage = "http://www.example.com"
}
build = {
type = "builtin",
modules = {
test = "test.lua"
}
}
]], finally)
test_env.write_file("test.lua", "return {}", finally)
assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec"))
local output = assert.is.truthy(run.luarocks("doc test"))
assert.is.truthy(output:find("documentation directory not found"))
end, finally)
end)
end)
describe("#namespaces", function()
it("retrieves docs for a namespaced package from the command-line", function()
assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
assert(run.luarocks_bool("build a_rock --keep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ))
assert.match("a_rock 2.0", run.luarocks("doc a_user/a_rock"))
end)
end)
describe("LuaRocks doc tests with flags", function()
it("LuaRocks doc of installed package", function()
test_env.run_in_tmp(function(tmpdir)
test_env.write_file("test-1.0-1.rockspec", [[
package = "test"
version = "1.0-1"
source = {
url = "file://test.lua"
}
build = {
type = "builtin",
modules = {
test = "test.lua"
}
}
]], finally)
test_env.write_file("test.lua", "return {}", finally)
assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec"))
lfs.mkdir(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc")
test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc.md", "", finally)
test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/readme.md", "", finally)
assert.is_true(run.luarocks_bool("doc test"))
end, finally)
end)
it("LuaRocks doc with --list", function()
test_env.run_in_tmp(function(tmpdir)
test_env.write_file("test-1.0-1.rockspec", [[
package = "test"
version = "1.0-1"
source = {
url = "file://test.lua"
}
build = {
type = "builtin",
modules = {
test = "test.lua"
}
}
]], finally)
test_env.write_file("test.lua", "return {}", finally)
assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec"))
lfs.mkdir(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc")
test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc1.md", "", finally)
test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc2.md", "", finally)
local output = assert.is.truthy(run.luarocks("doc test --list"))
assert.is.truthy(output:find("doc1%.md"))
assert.is.truthy(output:find("doc2%.md"))
end, finally)
end)
it("LuaRocks doc with --local", function()
assert.is_true(run.luarocks_bool("install --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock"))
assert.is_true(run.luarocks_bool("doc --server=" .. testing_paths.fixtures_dir .. "/a_repo a_rock --local"))
end)
it("LuaRocks doc with --porcelain", function()
test_env.run_in_tmp(function(tmpdir)
test_env.write_file("test-1.0-1.rockspec", [[
package = "test"
version = "1.0-1"
source = {
url = "file://test.lua"
}
build = {
type = "builtin",
modules = {
test = "test.lua"
}
}
]], finally)
test_env.write_file("test.lua", "return {}", finally)
assert.is_true(run.luarocks_bool("install test-1.0-1.rockspec"))
lfs.mkdir(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc")
test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc1.md", "", finally)
test_env.write_file(testing_paths.testing_sys_rocks .. "/test/1.0-1/doc/doc2.md", "", finally)
assert.is_true(run.luarocks_bool("doc test --porcelain"))
end, finally)
end)
end)
end)
|