Refactor run_spec to use process exit instead of empty stderr (#584)

Bonus: It also allows run_spec to pass if using bin/crystal wrapper
This commit is contained in:
Brian J. Cardiff 2020-08-15 12:09:53 -03:00 committed by GitHub
parent dfe7dca08f
commit a819d4792b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,12 +5,12 @@ private def run(code)
require "./src/kemal" require "./src/kemal"
#{code} #{code}
CR CR
String.build do |stdout|
stderr = String.build do |io| stdout = IO::Memory.new
Process.new("crystal", ["eval"], input: IO::Memory.new(code), output: stdout, error: io).wait stderr = IO::Memory.new
end status = Process.new("crystal", ["eval"], input: IO::Memory.new(code), output: stdout, error: stderr).wait
fail(stderr) unless stderr.empty? fail(stderr.to_s) unless status.success?
end stdout.to_s
end end
describe "Run" do describe "Run" do