Skip to content

Commit

Permalink
Update test/csv/csv-filter/test_csv_filter.rb
Browse files Browse the repository at this point in the history
Co-authored-by: Sutou Kouhei <[email protected]>
  • Loading branch information
BurdetteLamar and kou authored Dec 16, 2024
1 parent f6a7b29 commit e929d19
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/csv/csv-filter/test_csv_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,22 @@ def csv_filepath(csv_in_s, dirpath, option_sym)
# Return stdout and stderr from CLI execution.
def execute_in_cli(filepath, cli_options_s = '')
debug('cli_options_s', cli_options_s)
command = "cat #{filepath} | ruby bin/csv-filter #{cli_options_s}"
capture_subprocess_io do
system(command)
top_dir = File.join(__dir__, "..", "..", "..")
command_line = [
Gem.ruby,
"-I",
File.join(top_dir, "lib"),
File.join(top_dir, "bin", "csv-filter"),
*options,
filepath,
]
Tempfile.create("stdout", mode: "rw") do |stdout|
Tempfile.create("stderr", mode: "rw") do |stderr|
status = system(*command_line, {1 => stdout, 2 => stderr})
stdout.rewind
stderr.rewind
[status, stdout.read, stderr.read]
end
end
end

Expand Down

0 comments on commit e929d19

Please sign in to comment.