From 0a5c5eee15072b712d0cee4cce8d642d1177ff76 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 2 Sep 2019 14:10:26 -0300 Subject: fs: fix Lua wrapper for interactive mode --- spec/init_spec.lua | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'spec') diff --git a/spec/init_spec.lua b/spec/init_spec.lua index 9d68187c..d8a8e899 100644 --- a/spec/init_spec.lua +++ b/spec/init_spec.lua @@ -35,6 +35,45 @@ describe("Luarocks init test #integration", function() 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" + lfs.mkdir(myproject) + lfs.chdir(myproject) + + assert(run.luarocks("init")) + if is_win then + assert.truthy(lfs.attributes(myproject .. "/lua.bat")) + assert.truthy(lfs.attributes(myproject .. "/luarocks.bat")) + local pd = assert(io.popen([[echo print(_VERSION) | lua.bat]], "r")) + local output = pd:read("*a") + pd:close() + assert.match("5", output, 1, true) + local fd = io.open("hello.lua", "w") + fd:write("print('hello' .. _VERSION)") + fd:close() + pd = assert(io.popen([[lua.bat hello.lua]], "r")) + output = pd:read("*a") + pd:close() + assert.match("hello", output, 1, true) + else + assert.truthy(lfs.attributes(myproject .. "/lua")) + assert.truthy(lfs.attributes(myproject .. "/luarocks")) + local pd = assert(io.popen([[echo "print('hello ' .. _VERSION)" | ./lua]], "r")) + local output = pd:read("*a") + pd:close() + assert.match("hello", output, 1, true) + local fd = io.open("hello.lua", "w") + fd:write("print('hello' .. _VERSION)") + fd:close() + pd = assert(io.popen([[./lua ./hello.lua]], "r")) + output = pd:read("*a") + pd:close() + assert.match("hello", output, 1, true) + end + end, finally) + end) it("LuaRocks init with given arguments", function() test_env.run_in_tmp(function(tmpdir) -- cgit v1.2.3-55-g6feb