Skip to content

Commit 054bd89

Browse files
committed
Enhance local E2E test running to also output logs
1 parent f36e291 commit 054bd89

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

test/e2e_test.exs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,15 @@ defmodule ElixirScript.E2eTest.EndToEndUtils do
102102
alias ElixirScript.ScriptRunner
103103

104104
def run_test(%Entry{name: name, file: nil, script: script, expected: expected}) do
105-
actual =
106-
run_script_and_capture_output(script)
107-
|> convert_to_github_actions_output()
105+
{output, io} = run_script_and_capture_output(script)
106+
actual = convert_to_github_actions_output(output)
108107

109108
unless is_nil(expected) do
110109
assert actual == expected,
111-
"E2E test '#{name}' failed.\n Expected: #{inspect(expected)}\n Actual: #{inspect(actual)}"
110+
"E2E test '#{name}' failed.\n" <>
111+
" EXPECTED:\n#{inspect(expected)}\n\n" <>
112+
" ACTUAL:\n#{inspect(actual)}\n\n" <>
113+
" LOGS:\n#{io}"
112114
end
113115
end
114116

@@ -119,13 +121,14 @@ defmodule ElixirScript.E2eTest.EndToEndUtils do
119121
# the return value back to the parent process. This ensures that only the intended return
120122
# value is used for the test assertion, regardless of any other IO produced during script execution.
121123
defp run_script_and_capture_output(script) do
122-
capture_io(fn ->
123-
actual = ScriptRunner.run(script)
124-
send(self(), {:actual, actual})
125-
end)
124+
io =
125+
capture_io(fn ->
126+
output = ScriptRunner.run(script)
127+
send(self(), {:output, output})
128+
end)
126129

127-
assert_received {:actual, actual}
128-
actual
130+
assert_received {:output, output}
131+
{output, io}
129132
end
130133

131134
# Converts the script output to match the GitHub Actions output format.

0 commit comments

Comments
 (0)