From 1f4a567867633d87ff1d5d102ffc890339b9adb0 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 17 Feb 2024 00:18:05 -0300 Subject: feat(init): add --no-gitignore, --no-wrapper-scripts, --wrapper-dir Closes #1513. --- spec/init_spec.lua | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'spec') diff --git a/spec/init_spec.lua b/spec/init_spec.lua index dadeb300..be10b5b1 100644 --- a/spec/init_spec.lua +++ b/spec/init_spec.lua @@ -36,6 +36,69 @@ describe("luarocks init #integration", function() end, finally) end) + it("with --no-gitignore", function() + test_env.run_in_tmp(function(tmpdir) + local myproject = tmpdir .. "/myproject" + lfs.mkdir(myproject) + lfs.chdir(myproject) + + assert(run.luarocks("init --no-gitignore")) + if is_win then + assert.truthy(lfs.attributes(myproject .. "/lua.bat")) + assert.truthy(lfs.attributes(myproject .. "/luarocks.bat")) + else + assert.truthy(lfs.attributes(myproject .. "/lua")) + assert.truthy(lfs.attributes(myproject .. "/luarocks")) + end + assert.truthy(lfs.attributes(myproject .. "/lua_modules")) + assert.truthy(lfs.attributes(myproject .. "/.luarocks")) + assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua")) + assert.falsy(lfs.attributes(myproject .. "/.gitignore")) + assert.truthy(lfs.attributes(myproject .. "/myproject-dev-1.rockspec")) + end, finally) + end) + + it("with --no-wrapper-scripts", function() + test_env.run_in_tmp(function(tmpdir) + local myproject = tmpdir .. "/myproject" + lfs.mkdir(myproject) + lfs.chdir(myproject) + + assert(run.luarocks("init --no-wrapper-scripts")) + assert.falsy(lfs.attributes(myproject .. "/lua.bat")) + assert.falsy(lfs.attributes(myproject .. "/luarocks.bat")) + assert.falsy(lfs.attributes(myproject .. "/lua")) + assert.falsy(lfs.attributes(myproject .. "/luarocks")) + assert.truthy(lfs.attributes(myproject .. "/lua_modules")) + assert.truthy(lfs.attributes(myproject .. "/.luarocks")) + assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua")) + assert.truthy(lfs.attributes(myproject .. "/.gitignore")) + assert.truthy(lfs.attributes(myproject .. "/myproject-dev-1.rockspec")) + end, finally) + end) + + it("with --wrapper-dir", function() + test_env.run_in_tmp(function(tmpdir) + local myproject = tmpdir .. "/myproject" + lfs.mkdir(myproject) + lfs.chdir(myproject) + + assert(run.luarocks("init --wrapper-dir=./bin")) + if is_win then + assert.truthy(lfs.attributes(myproject .. "/bin/lua.bat")) + assert.truthy(lfs.attributes(myproject .. "/bin/luarocks.bat")) + else + assert.truthy(lfs.attributes(myproject .. "/bin/lua")) + assert.truthy(lfs.attributes(myproject .. "/bin/luarocks")) + end + assert.truthy(lfs.attributes(myproject .. "/lua_modules")) + assert.truthy(lfs.attributes(myproject .. "/.luarocks")) + assert.truthy(lfs.attributes(myproject .. "/.luarocks/config-" .. test_env.lua_version .. ".lua")) + assert.truthy(lfs.attributes(myproject .. "/.gitignore")) + assert.truthy(lfs.attributes(myproject .. "/myproject-dev-1.rockspec")) + end, finally) + end) + it("lua wrapper works", function() test_env.run_in_tmp(function(tmpdir) local myproject = tmpdir .. "/myproject" -- cgit v1.2.3-55-g6feb