Debian Codegraph @

Rakefile

raw
1 # frozen_string_literal: true
2
3 require 'bundler/gem_tasks'
4 require 'rake/extensiontask'
5 require 'rake/testtask'
6
7 Rake::ExtensionTask.new('ox') do |ext|
8 ext.lib_dir = 'lib/ox'
9 end
10
11 def run(command)
12 if ENV['OX_ASAN']
13 @ld_preload ||= `gcc -print-file-name=libasan.so`.strip
14 command = "LD_PRELOAD=#{@ld_preload} ASAN_OPTIONS=detect_leaks=0 #{command}"
15 end
16 system command
17 end
18
19 task test_all: [:clean, :compile] do
20 $stdout.flush
21 exitcode = 0
22 status = true
23
24 %w[test/tests.rb test/sax/sax_test.rb].each do |test|
25 cmds = "bundle exec ruby #{test} -v"
26
27 $stdout.syswrite "\n#{'#' * 90}\n#{cmds}\n"
28 Bundler.with_original_env do
29 status = status && run(cmds)
30 end
31 end
32 exitcode = 1 unless status
33
34 unless ENV['OX_ASAN']
35 Rake::Task['test'].invoke
36 else
37 run('rake test')
38 end
39 exit(1) if exitcode == 1
40 end
41
42 task default: :test_all