Skip to content

Commit

Permalink
Try to work-around flakyness of the test caused by buffering issues. (f…
Browse files Browse the repository at this point in the history
…astlane#21792)

We don't have a simple way to disable the buffering in the terminal that is cross platform but quoting the parameter to echo does the job.
  • Loading branch information
lacostej committed Feb 28, 2024
1 parent 947cb26 commit 7c88f14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions fastlane_core/spec/command_executor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
expect(Process).to receive(:wait)
end

result = FastlaneCore::CommandExecutor.execute(command: 'echo foo')
result = FastlaneCore::CommandExecutor.execute(command: "echo 'foo'")

expect(result).to eq('foo')
end
Expand All @@ -31,7 +31,7 @@
# PTY uses "$?" to get exitcode, which is filled in by Process.wait(),
# so we have to spawn a real process unless we want to mock methods
# on nil.
child_process_id = Process.spawn('echo foo', out: File::NULL)
child_process_id = Process.spawn("echo 'foo'", out: File::NULL)
expect(Process).to receive(:wait).with(child_process_id)

block.yield(fake_std_in, fake_std_out, child_process_id)
Expand All @@ -58,18 +58,18 @@
expect(fake_std_out).to receive(:close)

expect(PTY).to receive(:spawn) do |command, &block|
expect(command).to eq('echo foo')
expect(command).to eq("echo 'foo'")

# PTY uses "$?" to get exitcode, which is filled in by Process.wait(),
# so we have to spawn a real process unless we want to mock methods
# on nil.
child_process_id = Process.spawn('echo foo', out: File::NULL)
child_process_id = Process.spawn("echo 'foo'", out: File::NULL)
expect(Process).to receive(:wait).with(child_process_id)

block.yield(fake_std_in, fake_std_out, child_process_id)
end

result = FastlaneCore::CommandExecutor.execute(command: 'echo foo')
result = FastlaneCore::CommandExecutor.execute(command: "echo 'foo'")

# We are implicitly also checking that the error was not rethrown because that would
# have crashed the test
Expand Down
6 changes: 3 additions & 3 deletions fastlane_core/spec/fastlane_pty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
it 'executes a simple command successfully' do
@all_lines = []

exit_status = FastlaneCore::FastlanePty.spawn('echo foo') do |command_stdout, command_stdin, pid|
exit_status = FastlaneCore::FastlanePty.spawn("echo 'foo'") do |command_stdout, command_stdin, pid|
command_stdout.each do |line|
@all_lines << line.chomp
end
Expand All @@ -16,7 +16,7 @@
it 'doesn t return -1 if an exception was raised in the block in PTY.spawn' do
exception = StandardError.new
expect {
exit_status = FastlaneCore::FastlanePty.spawn('echo foo') do |command_stdout, command_stdin, pid|
exit_status = FastlaneCore::FastlanePty.spawn("echo 'foo'") do |command_stdout, command_stdin, pid|
raise exception
end
}.to raise_error(FastlaneCore::FastlanePtyError) { |error|
Expand All @@ -31,7 +31,7 @@

exception = StandardError.new
expect {
exit_status = FastlaneCore::FastlanePty.spawn('echo foo') do |command_stdout, command_stdin, pid|
exit_status = FastlaneCore::FastlanePty.spawn("echo 'foo'") do |command_stdout, command_stdin, pid|
raise exception
end
}.to raise_error(FastlaneCore::FastlanePtyError) { |error|
Expand Down

0 comments on commit 7c88f14

Please sign in to comment.