@@ -116,33 +116,41 @@ def test_backtrace_takes_both_number_and_pattern
116116 end
117117
118118 def test_frame_filtering_works_with_unexpanded_path_and_expanded_skip_path
119- foo_file = 'class Foo; def bar; debugger; end; end'
119+ foo_path = "#{ pty_home_dir } /foo_#{ Time . now . to_i } .rb"
120+ foo_file = <<~RUBY
121+ class Foo
122+ def bar
123+ debugger
124+ end
125+ end
126+ RUBY
127+
120128 program = <<~RUBY
121- 1| load "~/foo.rb "
129+ 1| load "~/#{ File . basename ( foo_path ) } "
122130 2| Foo.new.bar
123131 RUBY
124132
125133 begin
126- File . open ( " #{ pty_home_dir } /foo.rb" , 'w+' ) . close
134+ File . open ( foo_path , 'w+' ) . close
127135 rescue Errno ::EACCES , Errno ::EPERM
128136 omit "Skip test with load files. Cannot create files in HOME directory."
129137 end
130138
139+ file = File . open ( foo_path , 'w+' ) { |f | f . write ( foo_file ) }
131140 debug_code ( program ) do
132- type "file = File.open('#{ pty_home_dir } /foo.rb', 'w+') { |f| f.write('#{ foo_file } ') }"
133141 type 'c'
134142 type 'bt'
135143 assert_line_text ( /Foo#bar/ )
136- assert_line_text ( /~\/ foo \ . rb/ )
137- type "DEBUGGER__::CONFIG[:skip_path] = '#{ pty_home_dir } /foo.rb '"
144+ assert_line_text ( /~\/ foo_ \d + .rb/ )
145+ type "eval DEBUGGER__::CONFIG[:skip_path] = '#{ foo_path } '"
138146 type 'bt'
139- assert_no_line_text ( /Foo#bar/ ) # ~/foo.rb should match foo.rb's absolute path and be skipped
147+ assert_no_line_text ( /Foo#bar/ ) # ~/foo.... rb should match foo.rb's absolute path and be skipped
140148 assert_no_line_text ( /~\/ foo\. rb/ )
141149 type 'c'
142150 end
143151 ensure
144- if File . exist? " #{ pty_home_dir } /foo.rb"
145- File . unlink " #{ pty_home_dir } /foo.rb"
152+ if File . exist? foo_path
153+ File . unlink foo_path
146154 end
147155 end
148156 end
0 commit comments