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 dffe05a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spec/std/process_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ 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)}}
{% if flag?(:win32) %}
command = "cmd.exe"
args = {"/c", "dir"}
else
{% else %}
command = "/bin/ls"
args = [] of String
end
{% end %}
Process.run(command, args, output: Process::Redirect::Close).exit_code.should eq(0)
end

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

it "sets working directory" do
parent = File.dirname(Dir.current)
command = {{flag?(:win32)}} ? "cmd /c echo %cd%" : "pwd"
{% if flag?(:win32) %}
command = "cmd /c echo %cd%"
{% else %}
command = "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 dffe05a

Please sign in to comment.