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
|
local test_env = require("spec.util.test_env")
local run = test_env.run
local get_tmp_path = test_env.get_tmp_path
local write_file = test_env.write_file
local lfs = require("lfs")
local extra_rocks = {
"/say-1.3-1.rockspec"
}
describe("luarocks lint #integration", function()
before_each(function()
test_env.setup_specs(extra_rocks)
end)
it("with no flags/arguments", function()
assert.is_false(run.luarocks_bool("lint"))
end)
it("invalid argument", function()
assert.is_false(run.luarocks_bool("lint invalid"))
end)
it("OK", function()
assert.is_true(run.luarocks_bool("download --rockspec say 1.3-1"))
local output = run.luarocks("lint say-1.3-1.rockspec")
assert.are.same(output, "")
assert.is_true(os.remove("say-1.3-1.rockspec"))
end)
describe("mismatch set", function()
local tmpdir
local olddir
before_each(function()
tmpdir = get_tmp_path()
olddir = lfs.currentdir()
lfs.mkdir(tmpdir)
lfs.chdir(tmpdir)
end)
after_each(function()
if olddir then
lfs.chdir(olddir)
if tmpdir then
lfs.rmdir(tmpdir)
end
end
end)
it("mismatch string", function()
write_file("type_mismatch_string-1.0-1.rockspec", [[
package="type_mismatch_version"
version=1.0
]], finally)
assert.is_false(run.luarocks_bool("lint type_mismatch_string-1.0-1.rockspec"))
end)
it("mismatch version", function()
write_file("type_mismatch_version-1.0-1.rockspec", [[
package="type_mismatch_version"
version="1.0"
]], finally)
assert.is_false(run.luarocks_bool("lint type_mismatch_version-1.0-1.rockspec"))
end)
it("mismatch table", function()
write_file("type_mismatch_table-1.0-1.rockspec", [[
package="type_mismatch_table"
version="1.0-1"
source = "not a table"
]], finally)
assert.is_false(run.luarocks_bool("lint type_mismatch_table-1.0-1.rockspec"))
end)
it("mismatch no build table", function()
write_file("no_build_table-1.0-1.rockspec", [[
package = "no_build_table"
version = "0.1-1"
source = {
url = "http://example.com/foo/tar.gz"
}
description = {
summary = "A rockspec with no build field",
}
dependencies = {
"lua >= 5.1"
}
]], finally)
assert.is_false(run.luarocks_bool("lint no_build_table-1.0-1.rockspec"))
end)
it("no description field", function()
write_file("nodesc-1.0-1.rockspec", [[
package = "nodesc"
version = "0.1-1"
source = {
url = "http://example.com/foo/tar.gz"
}
dependencies = {
"lua >= 5.1"
}
]], finally)
assert.is_false(run.luarocks_bool("lint nodesc-1.0-1.rockspec"))
end)
end)
end)
|