Skip to content

Commit 2d2d45d

Browse files
committed
Add tests for handling file paths in CommandLine script execution
1 parent 239205a commit 2d2d45d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/command_line_test.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,30 @@ defmodule ElixirScript.CommandLineTest do
4545
assert [_, result] = Regex.run(regex, output), "Regex failed on: " <> output
4646
assert result == "bar"
4747
end
48+
49+
test "handles file paths in script argument" do
50+
file_path = Path.join(System.tmp_dir(), "cli_test.exs")
51+
File.write!(file_path, "\"CLI file result\"")
52+
on_exit(fn -> File.rm!(file_path) end)
53+
54+
expect(ElixirScript.ScriptRunnerMock, :run, fn ^file_path, [github_token: nil] ->
55+
"CLI file result"
56+
end)
57+
58+
capture_io(fn ->
59+
CommandLine.main(["--script", file_path])
60+
end)
61+
end
62+
63+
test "passes relative file paths unchanged to script runner" do
64+
expect(ElixirScript.ScriptRunnerMock, :run, fn "./scripts/test.exs", _ ->
65+
"test output"
66+
end)
67+
68+
capture_io(fn ->
69+
CommandLine.main(["--script", "./scripts/test.exs"])
70+
end)
71+
end
4872
end
4973

5074
describe "parse_args!/1" do

0 commit comments

Comments
 (0)