Skip to content

Commit 37a5572

Browse files
committed
Adapt Thread::Backtrace::Location specs
1 parent f089ba2 commit 37a5572

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

spec/truffle/thread/backtrace/location/absolute_path_spec.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,20 @@
1010

1111
describe 'Thread::Backtrace::Location#absolute_path' do
1212

13-
it 'should be the same absolute path as in the formatted description for core methods' do
13+
it 'returns an existing and canonical path for core methods' do
1414
# Get the caller_locations from a call made into a core method.
1515
locations = [:non_empty].map { caller_locations }.flatten
1616

1717
locations.each do |location|
18-
filename, _line_number, _in_method = location.to_s.split(':')
1918
path = location.absolute_path
19+
path.should_not.include?('(core)')
2020

21-
path.should_not == '(core)'
22-
path.start_with?('resource:/').should be_false
23-
location.absolute_path.should == File.expand_path(filename)
21+
if path.include?('resource:')
22+
skip
23+
else
24+
File.should.exist?(location.absolute_path)
25+
File.realpath(location.absolute_path).should == location.absolute_path
26+
end
2427
end
2528
end
2629

spec/truffle/thread/backtrace/location/lineno_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
locations = [:non_empty].map { caller_locations }.flatten
1616

1717
locations.each do |location|
18-
_filename, line_number, _in_method = location.to_s.split(':')
19-
location.lineno.should == line_number.to_i
18+
line_number = location.to_s[/:(\d+):/, 1]
19+
location.lineno.should == Integer(line_number)
2020
end
2121
end
2222

spec/truffle/thread/backtrace/location/path_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
locations = [:non_empty].map { caller_locations }.flatten
1616

1717
locations.each do |location|
18-
filename, _line_number, _in_method = location.to_s.split(':')
18+
filename = location.to_s[/^(.+):\d+:/, 1]
1919
path = location.path
20+
path.should_not.include?('(core)')
21+
path.should_not.include?('resource:')
2022

21-
path.should_not == '(core)'
22-
path.start_with?('resource:/').should be_false
23-
File.basename(path).should == File.basename(filename)
23+
# #path is consistent with #to_s output, like on MRI
24+
path.should == filename
2425
end
2526
end
2627

0 commit comments

Comments
 (0)