Skip to content

Commit

Permalink
Add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardiff committed Sep 3, 2024
1 parent f95fe2b commit 3557cab
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/compiler/crystal/commands/external_command_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "../../../spec_helper"

describe Crystal::Command do
it "exec external commands" do
with_temp_executable "crystal-external" do |path|
with_tempfile "crystal-external.cr" do |source_file|
File.write source_file, <<-CRYSTAL
puts ENV["CRYSTAL"]?
puts PROGRAM_NAME
puts ARGV
CRYSTAL

Process.run(ENV["CRYSTAL_SPEC_COMPILER_BIN"]? || "bin/crystal", ["build", source_file, "-o", path])
end

File.exists?(path).should be_true

process = Process.new(ENV["CRYSTAL_SPEC_COMPILER_BIN"]? || "bin/crystal",
["external", "foo", "bar"],
output: :pipe,
env: {"PATH" => File.dirname(path)}
)
output = process.output.gets_to_end
status = process.wait
status.success?.should be_true

Check failure on line 25 in spec/compiler/crystal/commands/external_command_spec.cr

View workflow job for this annotation

GitHub Actions / LLVM 13.0.0

got: false

Check failure on line 25 in spec/compiler/crystal/commands/external_command_spec.cr

View workflow job for this annotation

GitHub Actions / LLVM 14.0.0

got: false

Check failure on line 25 in spec/compiler/crystal/commands/external_command_spec.cr

View workflow job for this annotation

GitHub Actions / LLVM 15.0.6

got: false

Check failure on line 25 in spec/compiler/crystal/commands/external_command_spec.cr

View workflow job for this annotation

GitHub Actions / LLVM 16.0.3

got: false

Check failure on line 25 in spec/compiler/crystal/commands/external_command_spec.cr

View workflow job for this annotation

GitHub Actions / LLVM 17.0.6

got: false

Check failure on line 25 in spec/compiler/crystal/commands/external_command_spec.cr

View workflow job for this annotation

GitHub Actions / LLVM 18.1.4

got: false
lines = output.lines
lines[0].should match /crystal/
lines[1].should match /crystal-external/
lines[2].should eq %(["foo", "bar"])
end
end
end

0 comments on commit 3557cab

Please sign in to comment.