Skip to content

Commit 4f31f39

Browse files
committed
feat(tracer): add debug smoke test and pp require
1 parent 6f7fef4 commit 4f31f39

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
!test/benchmarks/fixtures/*.json
55
test/tmp/
66
.direnv/
7-
pkg/
7+
pkg/
8+
9+
# Built ruby gems
10+
11+
**/*.gem
812

913
# Offline dependency sources
1014
.codex/deps_src/

gems/codetracer-pure-ruby-recorder/lib/recorder.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
require 'fileutils'
66
require 'set'
77
require 'ostruct'
8+
require 'pp'
89

910
CallRecord = Struct.new(:function_id, :args) do
1011
def to_data_for_json

test/test_tracer.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,19 @@ def test_gem_installation
126126
def test_pure_gem_installation
127127
run_gem_installation_test('codetracer-pure-ruby-recorder', 'codetracer_pure_ruby_recorder')
128128
end
129+
130+
def test_pure_debug_smoke
131+
Dir.chdir(File.expand_path('..', __dir__)) do
132+
env = { 'CODETRACER_RUBY_RECORDER_DEBUG' => '1' }
133+
out_dir = File.join('test', 'tmp', 'debug_smoke')
134+
FileUtils.rm_rf(out_dir)
135+
stdout, stderr, status = Open3.capture3(env, 'ruby', 'gems/codetracer-pure-ruby-recorder/lib/trace.rb', '--out-dir', out_dir, File.join('test', 'programs', 'addition.rb'))
136+
raise "trace failed: #{stderr}" unless status.success?
137+
138+
lines = stdout.lines.map(&:chomp)
139+
assert lines.any? { |l| l.start_with?('call ') }, 'missing debug output'
140+
assert lines.include?('3'), 'missing program output'
141+
assert File.exist?(File.join(out_dir, 'trace.json'))
142+
end
143+
end
129144
end

0 commit comments

Comments
 (0)