Skip to content

Commit

Permalink
[CI] helpers/tmp_path - use './tmp' for temp file root only on macOS (#…
Browse files Browse the repository at this point in the history
…3154)

* [CI] helpers/tmp_path - use './tmp' for temp file root only on macOS

See PR #3153

* Create ./tmp if it doesn't exist
  • Loading branch information
MSP-Greg committed May 14, 2023
1 parent 28db9e6 commit 898dc44
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/helpers/tmp_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,24 @@ def clean_tmp_paths

private

# With some macOS configurations, the following error may be raised when
# creating a UNIXSocket:
#
# too long unix socket path (106 bytes given but 104 bytes max) (ArgumentError)
#
PUMA_TMPDIR =
begin
if RUBY_PLATFORM.include? 'darwin'
dir_temp = File.absolute_path("#{__dir__}/../../tmp")
Dir.mkdir dir_temp unless Dir.exist? dir_temp
'./tmp'
else
nil
end
end

def tmp_path(extension=nil)
path = Tempfile.create(['', extension], './tmp') { |f| f.path }
path = Tempfile.create(['', extension], PUMA_TMPDIR) { |f| f.path }
tmp_paths << path
path
end
Expand Down

0 comments on commit 898dc44

Please sign in to comment.