Skip to content

Commit 074ad0b

Browse files
committed
(GH-199) Update stack trace tests for Puppet 6.11.0
The Puppet call stack has changed behaviour for both exceptions and succesful calls. This commit updates the tests for expect different stack traces for exceptions, and updates the generate stack trace method to ignore call sites with invalid line numbers (e.g. 0)
1 parent fb3dea7 commit 074ad0b

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/puppet-debugserver/debug_session/hook_handlers.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,11 @@ def process_breakpoint_hook(reason, args)
256256
end
257257

258258
break_description = break_display_text if break_description.empty?
259-
stack_trace = Puppet::Pops::PuppetStack.stacktrace
259+
# Due to a modification to the way stack traces are treated in Puppet 6.11.0, the stack
260+
# now includes entries for files in Line 0, which doesn't exist. These indicate that a file
261+
# has started to be processed/parsed/compiled. So we just ignore them
262+
# See https://tickets.puppetlabs.com/browse/PUP-10150 for more infomation
263+
stack_trace = Puppet::Pops::PuppetStack.stacktrace.reject { |item| item[1].zero? }
260264
# Due to https://github.com/puppetlabs/puppet/commit/0f96dd918b6184261bc2219e5e68e246ffbeac10
261265
# Prior to Puppet 4.8.0, stacktrace is in reverse order
262266
stack_trace.reverse! if Gem::Version.new(Puppet.version) < Gem::Version.new('4.8.0')

spec/debugserver/integration/puppet-debugserver/end_to_end_spec.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
@debug_stderr.close
3333
}
3434

35+
def modified_puppet_stack_trace
36+
# Due to a modification to the way stack traces are treated in Puppet 6.11.0, the stack size is different
37+
# See https://tickets.puppetlabs.com/browse/PUP-10150 for more infomation
38+
@modified_puppet_stack_trace ||= Gem::Version.create(Puppet.version) >= Gem::Version.create('6.11.0')
39+
end
40+
3541
context 'Processing an empty manifest with no breakpoints' do
3642
let(:manifest_file) { File.join($fixtures_dir, 'environments', 'testfixtures', 'manifests', 'empty.pp') }
3743
let(:noop) { true }
@@ -92,10 +98,14 @@
9298
result = @client.data_from_request_seq_id(@client.current_seq_id)
9399
# As we're only in the root, only two frames should be available. The error and where it was called from
94100
expect(result['success']).to be true
95-
expect(result['body']['stackFrames'].count).to eq(2)
96-
expect(result['body']['stackFrames'][0]).to include('line' => 3)
97-
expect(result['body']['stackFrames'][1]).to include('line' => 3)
98-
101+
if modified_puppet_stack_trace
102+
expect(result['body']['stackFrames'].count).to eq(1)
103+
expect(result['body']['stackFrames'][0]).to include('line' => 3)
104+
else
105+
expect(result['body']['stackFrames'].count).to eq(2)
106+
expect(result['body']['stackFrames'][0]).to include('line' => 3)
107+
expect(result['body']['stackFrames'][1]).to include('line' => 3)
108+
end
99109
# continue_request
100110
@client.send_data(@client.continue_request(@client.next_seq_id, thread_id))
101111
expect(@client).to receive_message_with_request_id_within_timeout([@client.current_seq_id, 5])

0 commit comments

Comments
 (0)