Skip to content

Commit 860af99

Browse files
committed
test(threads): fix threads, by removing the ThreadSwitch record events, because their parameter is variable (contains a thread id, which is different on every program run)
1 parent c387478 commit 860af99

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test/test_tracer.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ def setup
1616
FileUtils.mkdir_p(TMP_DIR)
1717
end
1818

19+
def filter_trace(trace)
20+
result = []
21+
trace.each {|a|
22+
if not a.has_key?("ThreadSwitch")
23+
result << a
24+
end
25+
}
26+
result
27+
end
28+
1929
def run_trace(tracer_script, program_name, *args)
2030
base = File.basename(program_name, '.rb')
2131
tracer_name = tracer_script.include?('pure') ? 'pure' : 'native'
@@ -27,7 +37,7 @@ def run_trace(tracer_script, program_name, *args)
2737
stdout, stderr, status = Open3.capture3(RbConfig.ruby, tracer_script, '--out-dir', out_dir, program, *args)
2838
raise "trace failed: #{stderr}" unless status.success?
2939
trace_file = File.join(out_dir, 'trace.json')
30-
trace = JSON.parse(File.read(trace_file)) if File.exist?(trace_file)
40+
trace = filter_trace(JSON.parse(File.read(trace_file))) if File.exist?(trace_file)
3141
program_out = stdout.lines.reject { |l| l.start_with?('call ') || l.start_with?('return') }.join
3242
[trace, program_out]
3343
end
@@ -46,7 +56,7 @@ def run_trace_with_separator(tracer_script, program_name, *args)
4656
)
4757
raise "trace failed: #{stderr}" unless status.success?
4858
trace_file = File.join(out_dir, 'trace.json')
49-
trace = JSON.parse(File.read(trace_file)) if File.exist?(trace_file)
59+
trace = filter_trace(JSON.parse(File.read(trace_file))) if File.exist?(trace_file)
5060
program_out = stdout.lines.reject { |l| l.start_with?('call ') || l.start_with?('return') }.join
5161
[trace, program_out]
5262
end

0 commit comments

Comments
 (0)