diff options
| author | Mike Vink <mike@pionative.com> | 2025-02-03 21:29:42 +0100 |
|---|---|---|
| committer | Mike Vink <mike@pionative.com> | 2025-02-03 21:29:42 +0100 |
| commit | 5155816b7b925dec5d5feb1568b1d7ceb00938b9 (patch) | |
| tree | deca28ea15e79f6f804c3d90d2ba757881638af5 /spec/lint_spec.lua | |
Diffstat (limited to 'spec/lint_spec.lua')
| -rw-r--r-- | spec/lint_spec.lua | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua new file mode 100644 index 0000000..919e4e7 --- /dev/null +++ b/spec/lint_spec.lua @@ -0,0 +1,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) |
