Skip to content

Commit 0847292

Browse files
committed
Ignore user's rdbgrc script in tests
1 parent 5002782 commit 0847292

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

test/debug/rdbg_option_test.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def test_debugger_stops_immediately
5757
end
5858

5959
class RCFileTest < TestCase
60+
def rc_filename
61+
File.join(@pty_home_dir, ".rdbgrc")
62+
end
63+
6064
def rc_script
6165
"config set skip_path /foo/bar/"
6266
end
@@ -68,14 +72,11 @@ def program
6872
end
6973

7074
def with_rc_script
71-
rc_filename = "~/.rdbgrc"
72-
renamed_rc_filename = "~/.rdbgrc.original"
73-
File.rename(rc_filename, renamed_rc_filename) if File.exist?(rc_filename)
74-
File.open(File.join(Dir.home, ".rdbgrc"), "w") { |f| f.write(rc_script) }
75+
File.open(rc_filename, "w") { |f| f.write(rc_script) }
7576

7677
yield
7778
ensure
78-
File.rename(renamed_rc_filename, rc_filename) if File.exist?(renamed_rc_filename)
79+
File.delete(rc_filename)
7980
end
8081

8182
def test_debugger_loads_the_rc_file_by_default

test/support/test_case.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TestCase < Test::Unit::TestCase
2020

2121
def setup
2222
@temp_file = nil
23+
@pty_home_dir = Dir.mktmpdir
2324
end
2425

2526
def teardown
@@ -361,7 +362,7 @@ def cleanup
361362
method: "Debugger.setBlackboxPatterns",
362363
params: {
363364
patterns: [
364-
365+
365366
]
366367
}
367368
},
@@ -378,15 +379,15 @@ def initialize
378379
@result = []
379380
@keys = []
380381
end
381-
382+
382383
def parse objs
383384
objs.each{|k, v|
384385
parse_ k, v
385386
@keys.pop
386387
}
387388
@result
388389
end
389-
390+
390391
def parse_ k, v
391392
@keys << k
392393
case v

test/support/utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def prepare_test_environment(program, test_steps, &block)
178178
TIMEOUT_SEC = (ENV['RUBY_DEBUG_TIMEOUT_SEC'] || 10).to_i
179179

180180
def run_test_scenario cmd, test_info
181-
PTY.spawn(cmd) do |read, write, pid|
181+
PTY.spawn({ "HOME" => @pty_home_dir }, cmd) do |read, write, pid|
182182
test_info.backlog = []
183183
test_info.last_backlog = []
184184
begin

0 commit comments

Comments
 (0)