allow ConfigureOp#log_and_test_command to be passed standard input data - close #111
This commit is contained in:
parent
a1bb9d81fd
commit
efa77066bf
@ -17,6 +17,10 @@ configure do
|
|||||||
end
|
end
|
||||||
op.complete(status, success_message: "good!", fail_message: fail_message, fail: should_fail)
|
op.complete(status, success_message: "good!", fail_message: fail_message, fail: should_fail)
|
||||||
end
|
end
|
||||||
|
custom_check("Checking sed -E flag") do |op|
|
||||||
|
stdout, stderr, status = op.log_and_test_command(%w[sed -E -e s/ab+/rep/], stdin: "abbbc")
|
||||||
|
op.complete(stdout =~ /repc/ ? 0 : 1, success_message: "good", fail_message: "fail")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
build do
|
build do
|
||||||
|
@ -280,12 +280,19 @@ module Rscons
|
|||||||
|
|
||||||
# Execute a test command and log the result.
|
# Execute a test command and log the result.
|
||||||
#
|
#
|
||||||
|
# @param command [Array<String>]
|
||||||
|
# Command to execute.
|
||||||
|
# @param options [Hash]
|
||||||
|
# Optional arguments.
|
||||||
|
# @option options [String] :stdin
|
||||||
|
# Data to send to standard input stream of the executed command.
|
||||||
|
#
|
||||||
# @return [String, String, Process::Status]
|
# @return [String, String, Process::Status]
|
||||||
# stdout, stderr, status
|
# stdout, stderr, status
|
||||||
def log_and_test_command(command)
|
def log_and_test_command(command, options = {})
|
||||||
begin
|
begin
|
||||||
@log_fh.puts("Command: #{command.join(" ")}")
|
@log_fh.puts("Command: #{command.join(" ")}")
|
||||||
stdout, stderr, status = Open3.capture3(*command)
|
stdout, stderr, status = Open3.capture3(*command, stdin_data: options[:stdin])
|
||||||
@log_fh.puts("Exit status: #{status.to_i}")
|
@log_fh.puts("Exit status: #{status.to_i}")
|
||||||
@log_fh.write(stdout)
|
@log_fh.write(stdout)
|
||||||
@log_fh.write(stderr)
|
@log_fh.write(stderr)
|
||||||
|
@ -2189,6 +2189,14 @@ EOF
|
|||||||
expect(result.status).to eq 0
|
expect(result.status).to eq 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "allows passing standard input data to the executed command" do
|
||||||
|
test_dir "configure"
|
||||||
|
result = run_rscons(rsconscript: "custom_config_check.rb", op: "configure")
|
||||||
|
expect(result.stderr).to eq ""
|
||||||
|
expect(result.stdout).to match /Checking sed -E flag\.\.\. good/
|
||||||
|
expect(result.status).to eq 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user