Skip to content

Commit 13dcca4

Browse files
znzko1
authored andcommitted
Always use tmp home unless CI
#732 (comment) * If it's a local environment, we don't want to modify $HOME * If it's a CI environment, it's fine to write files in $HOME * However, in ruby/actions's CI we also don't want $HOME to be writable
1 parent 034a8bb commit 13dcca4

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/support/console_test_case.rb

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ class ConsoleTestCase < TestCase
99
warn "Tests on local and remote. You can disable remote tests with RUBY_DEBUG_TEST_NO_REMOTE=1."
1010
end
1111

12-
HOME_CANNOT_CHANGE =
12+
# CIs usually doesn't allow overriding the HOME path
13+
# we also don't need to worry about adding or being affected by ~/.rdbgrc on CI
14+
# so we can just use the original home page there
15+
USE_TMP_HOME =
16+
!ENV["CI"] ||
1317
begin
1418
pwd = Dir.pwd
1519
ruby = ENV['RUBY'] || RbConfig.ruby
@@ -25,18 +29,15 @@ class << self
2529

2630
def startup
2731
@pty_home_dir =
28-
if HOME_CANNOT_CHANGE
29-
# CIs usually doesn't allow overriding the HOME path
30-
# we also don't need to worry about adding or being affected by ~/.rdbgrc on CI
31-
# so we can just use the original home page there
32-
Dir.home
33-
else
32+
if USE_TMP_HOME
3433
Dir.mktmpdir
34+
else
35+
Dir.home
3536
end
3637
end
3738

3839
def shutdown
39-
unless HOME_CANNOT_CHANGE
40+
if USE_TMP_HOME
4041
FileUtils.remove_entry @pty_home_dir
4142
end
4243
end

0 commit comments

Comments
 (0)