File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,11 @@ def test_debugger_stops_immediately
5757 end
5858
5959 class RCFileTest < TestCase
60+ def rc_filename
61+ # in test cases, Dir.home points to an updated ENV["HOME"] value, which is a tmpdir
62+ File . join ( Dir . home , ".rdbgrc" )
63+ end
64+
6065 def rc_script
6166 "config set skip_path /foo/bar/"
6267 end
@@ -68,14 +73,11 @@ def program
6873 end
6974
7075 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 ) }
76+ File . open ( rc_filename , "w" ) { |f | f . write ( rc_script ) }
7577
7678 yield
7779 ensure
78- File . rename ( renamed_rc_filename , rc_filename ) if File . exist? ( renamed_rc_filename )
80+ File . delete ( rc_filename )
7981 end
8082
8183 def test_debugger_loads_the_rc_file_by_default
Original file line number Diff line number Diff line change @@ -20,10 +20,15 @@ class TestCase < Test::Unit::TestCase
2020
2121 def setup
2222 @temp_file = nil
23+ @original_root = Dir . home ( "root" )
24+ # this is to prevent some test cases from updating the user's actual home dir
25+ dir = Dir . mktmpdir
26+ ENV [ "HOME" ] = dir
2327 end
2428
2529 def teardown
2630 remove_temp_file
31+ ENV [ "HOME" ] = @original_root
2732 end
2833
2934 def temp_file_path
@@ -361,7 +366,7 @@ def cleanup
361366 method : "Debugger.setBlackboxPatterns" ,
362367 params : {
363368 patterns : [
364-
369+
365370 ]
366371 }
367372 } ,
@@ -378,15 +383,15 @@ def initialize
378383 @result = [ ]
379384 @keys = [ ]
380385 end
381-
386+
382387 def parse objs
383388 objs . each { |k , v |
384389 parse_ k , v
385390 @keys . pop
386391 }
387392 @result
388393 end
389-
394+
390395 def parse_ k , v
391396 @keys << k
392397 case v
You can’t perform that action at this time.
0 commit comments