From 4d94d108157c9ea02d14d0b475db98da1c10a0c6 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 19 Nov 2023 11:38:00 +0900 Subject: [PATCH 1/2] Assert exit code of commands --- spec/lrama/integration_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/lrama/integration_spec.rb b/spec/lrama/integration_spec.rb index 5f0c7b45..b0853fec 100644 --- a/spec/lrama/integration_spec.rb +++ b/spec/lrama/integration_spec.rb @@ -25,14 +25,16 @@ def test_parser(parser_name, input, expected, lrama_command_args: [], debug: fal exec_command("#{flex} --header-file=#{lexer_h_path} -o #{lexer_c_path} #{lexer_file_path}") exec_command("gcc -Wall -I#{tmpdir} #{parser_c_path} #{lexer_c_path} -o #{obj_path}") - out = err = nil + out = err = status = nil Open3.popen3(obj_path, input) do |stdin, stdout, stderr, wait_thr| out = stdout.read err = stderr.read + status = wait_thr.value end STDERR.puts err if debug && !err.empty? + expect(status.success?).to be(true), status.to_s expect(out).to eq(expected) end From 1b660c1f193a1a59ceecd0d7e885920b180682a5 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 19 Nov 2023 11:38:57 +0900 Subject: [PATCH 2/2] Print stdout for debug --- spec/lrama/integration_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/lrama/integration_spec.rb b/spec/lrama/integration_spec.rb index b0853fec..4d11b3ff 100644 --- a/spec/lrama/integration_spec.rb +++ b/spec/lrama/integration_spec.rb @@ -33,7 +33,10 @@ def test_parser(parser_name, input, expected, lrama_command_args: [], debug: fal status = wait_thr.value end - STDERR.puts err if debug && !err.empty? + if debug + STDERR.puts out + STDERR.puts err + end expect(status.success?).to be(true), status.to_s expect(out).to eq(expected) end