Skip to content

Commit

Permalink
Check if HOME can change or not instead of ENV["CI"]
Browse files Browse the repository at this point in the history
  • Loading branch information
znz authored and ko1 committed Aug 10, 2022
1 parent 9d507dc commit 034a8bb
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/support/console_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ class ConsoleTestCase < TestCase
warn "Tests on local and remote. You can disable remote tests with RUBY_DEBUG_TEST_NO_REMOTE=1."
end

HOME_CANNOT_CHANGE =
begin
pwd = Dir.pwd
ruby = ENV['RUBY'] || RbConfig.ruby
home_cannot_change = false
PTY.spawn({ "HOME" => pwd }, ruby, '-e', 'puts ENV["HOME"]') do |r,|
home_cannot_change = r.gets.chomp != pwd
end
home_cannot_change
end

class << self
attr_reader :pty_home_dir

def startup
@pty_home_dir =
if ENV["CI"]
if HOME_CANNOT_CHANGE
# CIs usually doesn't allow overriding the HOME path
# we also don't need to worry about adding or being affected by ~/.rdbgrc on CI
# so we can just use the original home page there
Expand All @@ -25,7 +36,7 @@ def startup
end

def shutdown
unless ENV["CI"]
unless HOME_CANNOT_CHANGE
FileUtils.remove_entry @pty_home_dir
end
end
Expand Down

0 comments on commit 034a8bb

Please sign in to comment.