@@ -94,84 +94,6 @@ def test_args_sum_with_separator
9494 assert_equal expected , native_out
9595 end
9696
97- def run_gem_installation_test ( gem_bin , gem_module )
98- Dir . chdir ( File . expand_path ( '..' , __dir__ ) ) do
99- gem_dir = File . join ( 'gems' , gem_bin )
100-
101- if gem_bin == 'codetracer-ruby-recorder'
102- system ( 'just' , 'build-extension' , exception : true )
103- dlext = RbConfig ::CONFIG [ 'DLEXT' ]
104- ext_path = File . join ( gem_dir , 'ext' , 'native_tracer' , 'target' , 'release' , "codetracer_ruby_recorder.#{ dlext } " )
105- FileUtils . rm_f ( ext_path )
106- end
107-
108- Dir . mktmpdir ( 'gemhome' ) do |gem_home |
109- gemspec = Dir [ File . join ( gem_dir , '*.gemspec' ) ] . first
110- gem_build = IO . popen ( %W[ gem -C #{ gem_dir } build #{ File . basename ( gemspec ) } ] , err : [ :child , :out ] ) { |io | io . read }
111- gem_file = gem_build . lines . grep ( /File:/ ) . first . split . last
112- gem_file = File . expand_path ( File . join ( gem_dir , gem_file ) )
113-
114- env = { 'GEM_HOME' => gem_home , 'GEM_PATH' => gem_home , 'PATH' => "#{ gem_home } /bin:#{ ENV [ 'PATH' ] } " }
115- system ( env , 'gem' , 'install' , '--local' , gem_file , exception : true )
116-
117- out_dir = File . join ( 'test' , 'tmp' , "gem_install_#{ gem_bin . tr ( '-' , '_' ) } " )
118- FileUtils . rm_rf ( out_dir )
119- stdout , stderr , status = Open3 . capture3 ( env , RbConfig . ruby , '-S' , gem_bin , '--out-dir' , out_dir , File . join ( 'test' , 'programs' , 'addition.rb' ) )
120- raise "#{ gem_bin } failed: #{ stderr } " unless status . success?
121- assert_equal "3\n " , stdout
122- assert File . exist? ( File . join ( out_dir , 'trace.json' ) )
123-
124- out_dir_lib = File . join ( 'test' , 'tmp' , "gem_install_#{ gem_bin . tr ( '-' , '_' ) } _lib" )
125- FileUtils . rm_rf ( out_dir_lib )
126-
127- recorder_class = if gem_bin == 'codetracer-ruby-recorder'
128- "CodeTracer::RubyRecorder"
129- else
130- "CodeTracer::PureRubyRecorder"
131- end
132-
133- script = <<~RUBY
134- require '#{ gem_module } '
135- recorder = #{ recorder_class } .new('#{ out_dir_lib } ')
136- puts 'start trace'
137- recorder.stop
138- puts 'this will not be traced'
139- recorder.start
140- puts 'this will be traced'
141- recorder.stop
142- puts 'tracing disabled'
143- recorder.flush_trace
144- RUBY
145- script_path = File . join ( 'test' , 'tmp' , "use_#{ gem_bin . tr ( '-' , '_' ) } .rb" )
146- File . write ( script_path , script )
147- stdout , stderr , status = Open3 . capture3 ( env , RbConfig . ruby , script_path )
148- raise "#{ gem_module } library failed: #{ stderr } " unless status . success?
149- expected_out = <<~OUT
150- start trace
151- this will not be traced
152- this will be traced
153- tracing disabled
154- OUT
155- assert_equal expected_out , stdout
156- assert File . exist? ( File . join ( out_dir_lib , 'trace.json' ) )
157- end
158- end
159- end
160-
161- def test_gem_installation
162- run_gem_installation_test ( 'codetracer-ruby-recorder' , 'codetracer_ruby_recorder' )
163- end
164-
165- def test_pure_gem_installation
166- # When the pure Ruby recorder traces a script that holds a reference to the
167- # `PureRubyRecorder` instance in a local variable, the variable inspection code
168- # would recursively serialise the tracer's internal state. This results in an
169- # explosive amount of output and may appear as an infinite recursion when running
170- # `examples/selective_tracing_pure.rb`. For this reason, we skip this test for now.
171- skip
172- run_gem_installation_test ( 'codetracer-pure-ruby-recorder' , 'codetracer_pure_ruby_recorder' )
173- end
174-
17597 def test_pure_debug_smoke
17698 Dir . chdir ( File . expand_path ( '..' , __dir__ ) ) do
17799 env = { 'CODETRACER_RUBY_RECORDER_DEBUG' => '1' }
0 commit comments