Skip to content

Commit

Permalink
Use compile-time conditional for if flag? [2]
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Apr 13, 2020
1 parent 1b5d1bb commit 67e81fb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions spec/std/process_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,11 @@ describe Process do

it "redirects output to /dev/null" do
# This doesn't test anything but no output should be seen while running tests
if {{flag?(:win32)}}
command = "cmd.exe"
args = {"/c", "dir"}
else
command = "/bin/ls"
args = [] of String
end
command, args = {% if flag?(:win32) %}
{"cmd.exe", {"/c", "dir"}}
{% else %}
{"/bin/ls", [] of String}
{% end %}
Process.run(command, args, output: Process::Redirect::Close).exit_code.should eq(0)
end

Expand Down Expand Up @@ -155,7 +153,11 @@ describe Process do

it "sets working directory" do
parent = File.dirname(Dir.current)
command = {{flag?(:win32)}} ? "cmd /c echo %cd%" : "pwd"
command = {% if flag?(:win32) %}
"cmd /c echo %cd%"
{% else %}
"pwd"
{% end %}
value = Process.run(command, shell: true, chdir: parent, output: Process::Redirect::Pipe) do |proc|
proc.output.gets_to_end
end
Expand Down

0 comments on commit 67e81fb

Please sign in to comment.