Skip to content

Commit

Permalink
fix: print luarocks test stdout and stderr to workflow log (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Sep 15, 2023
1 parent d297ea8 commit 471de81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lua/ltr/os.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ end

---@param cmd string
---@param on_failure fun(error_msg:string)?
---@param verbose boolean|nil If true, will print stdout and stderr
---@return string stdout, string stderr
function OS.execute(cmd, on_failure)
function OS.execute(cmd, on_failure, verbose)
on_failure = on_failure or error
local exec_out = 'exec_out.txt'
local exec_err = 'exec_err.txt'
Expand All @@ -44,6 +45,9 @@ function OS.execute(cmd, on_failure)
local stderr = OS.read_file(exec_err) or ''
if exit_code ~= 0 then
on_failure(cmd .. ' FAILED\nexit code: ' .. exit_code .. '\nstdout: ' .. stdout .. '\nstderr: ' .. stderr)
elseif verbose then
print(stdout)
print(stderr)
end
return stdout, stderr
end
Expand Down
2 changes: 1 addition & 1 deletion lua/luarocks-tag-release.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local function luarocks_tag_release(package_name, package_version, specrev, args
OS.execute('luarocks config --scope project lua_interpreter ' .. interpreter)
print('Done.')
print('Running tests...')
OS.execute('luarocks test')
OS.execute('luarocks test', error, true)
OS.execute('rm -r .luarocks luarocks', print)
end

Expand Down

0 comments on commit 471de81

Please sign in to comment.