Skip to content

Commit 1e7a30c

Browse files
committed
Use Tempfile for socket tests
There is a quite small limit on socket path. This leeds to test error such as the one bellow on deeply nested systems. ~~~ 1) ABRT #handle_exception logs error into syslog when can't communicate with ABRT daemon because no-one is listeing on the other side Failure/Error: expect(syslog).to receive(:err).with("%s", /can't communicate with ABRT daemon, is it running\? Connection refused -( connect\(2\) for)? "?#{socket_path}"?/) #<Double "syslog"> received :err with unexpected arguments expected: ("%s", /can't communicate with ABRT daemon, is it running\? Connection refused -( connect\(2\) for)? "?\/bui...ygem-abrt-0.5.0-build\/abrt-0.5.0\/usr\/share\/gems\/gems\/abrt-0.5.0\/spec\/abrt_handler_spec.rb"?/) got: ("%s", "can't communicate with ABRT daemon, is it running? too long unix socket path (114bytes given but 108bytes max)") Diff: @@ -1,3 +1,3 @@ ["%s", - /can't communicate with ABRT daemon, is it running\? Connection refused -( connect\(2\) for)? "?\/builddir\/build\/BUILD\/rubygem-abrt-0.5.0-build\/abrt-0.5.0\/usr\/share\/gems\/gems\/abrt-0.5.0\/spec\/abrt_handler_spec.rb"?/] + "can't communicate with ABRT daemon, is it running? too long unix socket path (114bytes given but 108bytes max)"] # ./spec/abrt_handler_spec.rb:140:in 'block (5 levels) in <top (required)>' ~~~
1 parent 2c8e8e6 commit 1e7a30c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

spec/abrt_handler_spec.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,16 @@
132132

133133
it "because no-one is listeing on the other side" do
134134
# This file is not correct UNIX socket, so it should be usable for the test.
135-
socket_path = __FILE__
136-
expect(abrt).to receive(:abrt_socket).and_wrap_original do |original_method, *args, &block|
137-
args << __FILE__
138-
original_method.call(*args)
135+
require 'tempfile'
136+
Tempfile.create do |tf|
137+
socket_path = tf.path
138+
expect(abrt).to receive(:abrt_socket).and_wrap_original do |original_method, *args, &block|
139+
args << tf.path
140+
original_method.call(*args)
141+
end
142+
expect(syslog).to receive(:err).with("%s", /can't communicate with ABRT daemon, is it running\? Connection refused -( connect\(2\) for)? "?#{socket_path}"?/)
143+
abrt.handle_exception exception
139144
end
140-
expect(syslog).to receive(:err).with("%s", /can't communicate with ABRT daemon, is it running\? Connection refused -( connect\(2\) for)? "?#{socket_path}"?/)
141-
abrt.handle_exception exception
142145
end
143146
end
144147
end

0 commit comments

Comments
 (0)