From 7cafa62d20246ea17ff1d80bb75c930e8c44feef Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 13 Mar 2024 13:49:22 -0300 Subject: tests: replace new_version with quick tests --- spec/new_version_spec.lua | 85 ------------------ spec/quick/new_version.q | 213 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 213 insertions(+), 85 deletions(-) delete mode 100644 spec/new_version_spec.lua create mode 100644 spec/quick/new_version.q diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua deleted file mode 100644 index 18271176..00000000 --- a/spec/new_version_spec.lua +++ /dev/null @@ -1,85 +0,0 @@ -local test_env = require("spec.util.test_env") -local lfs = require("lfs") -local run = test_env.run -local testing_paths = test_env.testing_paths - -local extra_rocks = { - "/abelhas-1.1-1.rockspec", - "/lpeg-${LPEG}.rockspec" -} - -describe("luarocks new_version #integration", function() - - lazy_setup(function() - test_env.setup_specs(extra_rocks) - end) - - describe("basic tests", function() - it("with no flags/arguments", function() - finally(function() - lfs.chdir(testing_paths.testrun_dir) - test_env.remove_dir("empty") - end) - assert(lfs.mkdir("empty")) - assert(lfs.chdir("empty")) - assert.is_false(run.luarocks_bool("new_version")) - end) - - it("with invalid", function() - assert.is_false(run.luarocks_bool("new_version invalid")) - end) - - it("with invalid url", function() - assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.1")) - assert.is_true(run.luarocks_bool("new_version abelhas-1.1-1.rockspec 1.1 http://luainvalid")) - assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec")) - test_env.remove_files(lfs.currentdir(), "abelhas%-") - end) - end) - - describe("more complex tests", function() - it("of luacov", function() - assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}")) - assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec 0.2")) - assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec")) - test_env.remove_files(lfs.currentdir(), "luacov%-") - end) - - it("url of abelhas", function() - assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.1")) - assert.is_true(run.luarocks_bool("new_version abelhas-1.1-1.rockspec 1.2 http://example.com/abelhas-1.2.tar.gz")) - assert.is.truthy(lfs.attributes("abelhas-1.2-1.rockspec")) - test_env.remove_files(lfs.currentdir(), "abelhas%-") - end) - - it("of luacov with tag", function() - assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}")) - assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec --tag v0.3")) - assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec")) - test_env.remove_files(lfs.currentdir(), "luacov%-") - end) - - it("updating md5", function() - assert.is_true(run.luarocks_bool("download --rockspec lpeg ${LPEG_V}")) - assert.is_true(run.luarocks_bool("new_version lpeg-${LPEG}.rockspec 0.2 https://luarocks.org/manifests/gvvaughan/lpeg-1.0.0-1.rockspec")) - test_env.remove_files(lfs.currentdir(), "lpeg%-") - end) - end) - - describe("remote tests #mock", function() - lazy_setup(function() - test_env.setup_specs(extra_rocks, "mock") - test_env.mock_server_init() - end) - lazy_teardown(function() - test_env.mock_server_done() - end) - it("with remote spec", function() - assert.is_true(run.luarocks_bool("new_version http://localhost:8080/file/a_rock-1.0-1.rockspec")) - assert.is.truthy(lfs.attributes("a_rock-1.0-1.rockspec")) - assert.is.truthy(lfs.attributes("a_rock-1.0-2.rockspec")) - test_env.remove_files(lfs.currentdir(), "luasocket%-") - end) - end) - -end) diff --git a/spec/quick/new_version.q b/spec/quick/new_version.q new file mode 100644 index 00000000..98426db4 --- /dev/null +++ b/spec/quick/new_version.q @@ -0,0 +1,213 @@ +SUITE: luarocks new_version + +================================================================================ +TEST: fails without a context + +RUN: luarocks new_version +EXIT: 1 + + + +================================================================================ +TEST: fails with invalid arg + +RUN: luarocks new_version i_dont_exist +EXIT: 1 + + + +================================================================================ +TEST: updates a version + +FILE: myexample-0.1-1.rockspec +-------------------------------------------------------------------------------- +package = "myexample" +version = "0.1-1" +source = { + url = "git+https://localhost/myexample.git", + tag = "v0.1" +} +description = { + summary = "xxx", + detailed = "xxx" +} +build = { + type = "builtin", + modules = { + foo = "src/foo.lua" + } +} +-------------------------------------------------------------------------------- + +RUN: luarocks new_version myexample-0.1-1.rockspec 0.2 + +FILE_CONTENTS: myexample-0.2-1.rockspec +-------------------------------------------------------------------------------- +package = "myexample" +version = "0.2-1" +source = { + url = "git+https://localhost/myexample.git", + tag = "v0.2" +} +description = { + summary = "xxx", + detailed = "xxx" +} +build = { + type = "builtin", + modules = { + foo = "src/foo.lua" + } +} +-------------------------------------------------------------------------------- + + + +================================================================================ +TEST: updates via tag + +FILE: myexample-0.1-1.rockspec +-------------------------------------------------------------------------------- +package = "myexample" +version = "0.1-1" +source = { + url = "git+https://localhost/myexample.git", + tag = "v0.1" +} +description = { + summary = "xxx", + detailed = "xxx" +} +build = { + type = "builtin", + modules = { + foo = "src/foo.lua" + } +} +-------------------------------------------------------------------------------- + +RUN: luarocks new_version myexample-0.1-1.rockspec --tag v0.2 + +FILE_CONTENTS: myexample-0.2-1.rockspec +-------------------------------------------------------------------------------- +package = "myexample" +version = "0.2-1" +source = { + url = "git+https://localhost/myexample.git", + tag = "v0.2" +} +description = { + summary = "xxx", + detailed = "xxx" +} +build = { + type = "builtin", + modules = { + foo = "src/foo.lua" + } +} +-------------------------------------------------------------------------------- + + + +================================================================================ +TEST: updates URL + +FILE: myexample-0.1-1.rockspec +-------------------------------------------------------------------------------- +package = "myexample" +version = "0.1-1" +source = { + url = "https://localhost/myexample-0.1.tar.gz", +} +description = { + summary = "xxx", + detailed = "xxx" +} +build = { + type = "builtin", + modules = { + foo = "src/foo.lua" + } +} +-------------------------------------------------------------------------------- + +RUN: luarocks new_version myexample-0.1-1.rockspec 0.2 https://localhost/newpath/myexample-0.2.tar.gz + +FILE_CONTENTS: myexample-0.2-1.rockspec +-------------------------------------------------------------------------------- +package = "myexample" +version = "0.2-1" +source = { + url = "https://localhost/newpath/myexample-0.2.tar.gz" +} +description = { + summary = "xxx", + detailed = "xxx" +} +build = { + type = "builtin", + modules = { + foo = "src/foo.lua" + } +} +-------------------------------------------------------------------------------- + + + +================================================================================ +TEST: updates MD5 + +FILE: test-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "1.0-1" +source = { + url = "file://%{url(%{fixtures_dir})}/an_upstream_tarball-0.1.tar.gz", + md5 = "dca2ac30ce6c27cbd8dac4dd8f447630", +} +build = { + type = "builtin", + modules = { + my_module = "src/my_module.lua" + }, + install = { + bin = { + "src/my_module.lua" + } + } +} +-------------------------------------------------------------------------------- + +RUN: luarocks new_version test-1.0-1.rockspec 2.0 file://%{url(%{fixtures_dir})}/busted_project-0.1.tar.gz + +FILE_CONTENTS: test-2.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "2.0-1" +source = { + url = "file://%{url(%{fixtures_dir})}/busted_project-0.1.tar.gz", + md5 = "adfdfb8f1caa2b1f935a578fb07536eb", +} +build = { + type = "builtin", + modules = { + my_module = "src/my_module.lua" + }, + install = { + bin = { + "src/my_module.lua" + } + } +} +-------------------------------------------------------------------------------- + + + +================================================================================ +TEST: takes a URL, downloads and bumps revision by default + +RUN: luarocks new_version file://%{url(%{fixtures_dir})}/a_rock-1.0-1.rockspec + +EXISTS: a_rock-1.0-1.rockspec +EXISTS: a_rock-1.0-2.rockspec -- cgit v1.2.3-55-g6feb