Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print luarocks test stdout and stderr to workflow log #115

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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