-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
148 lines (126 loc) · 4.05 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env rake
require 'rubygems'
require 'bundler/setup'
require 'rake/testtask'
require 'traceview/test'
Rake::TestTask.new do |t|
t.verbose = false
t.warning = false
t.ruby_opts = []
t.libs << 'test'
# Since we support so many libraries and frameworks, tests
# runs are segmented into gemfiles that have different
# sets and versions of gems (libraries and frameworks).
#
# Here we detect the Gemfile the tests are being run against
# and load the appropriate tests.
#
case TraceView::Test.gemfile
when /delayed_job/
require 'delayed/tasks'
t.test_files = FileList["test/queues/delayed_job*_test.rb"]
when /rails/
# Pre-load rails to get the major version number
require 'rails'
if Rails::VERSION::MAJOR == 5
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"] +
FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_api_test.rb"]
else
t.test_files = FileList["test/frameworks/rails#{Rails::VERSION::MAJOR}x_test.rb"]
end
when /frameworks/
t.test_files = FileList['test/frameworks/sinatra*_test.rb'] +
FileList['test/frameworks/padrino*_test.rb'] +
FileList['test/frameworks/grape*_test.rb']
when /libraries/
t.test_files = FileList['test/support/*_test.rb'] +
FileList['test/reporter/*_test.rb'] +
FileList['test/instrumentation/*_test.rb'] +
FileList['test/profiling/*_test.rb']
end
if defined?(JRUBY_VERSION)
t.ruby_opts << ['-J-javaagent:/usr/local/tracelytics/tracelyticsagent.jar']
end
end
desc "Build the gem's c extension"
task :compile do
if !defined?(JRUBY_VERSION)
puts "== Building the c extension against Ruby #{RUBY_VERSION}"
pwd = Dir.pwd
ext_dir = File.expand_path('ext/oboe_metal')
lib_dir = File.expand_path('lib')
symlink = File.expand_path('lib/oboe_metal.so')
so_file = File.expand_path('ext/oboe_metal/oboe_metal.so')
Dir.chdir ext_dir
cmd = [ Gem.ruby, 'extconf.rb']
sh cmd.join(' ')
sh '/usr/bin/env make'
File.delete symlink if File.exist? symlink
if File.exist? so_file
File.symlink so_file, symlink
Dir.chdir pwd
puts "== Extension built and symlink'd to #{symlink}"
else
Dir.chdir pwd
puts '!! Extension failed to build (see above). Are the base TraceView packages installed?'
puts '!! See http://docs.traceview.solarwinds.com/TraceView/install-instrumentation.html'
end
else
puts '== Nothing to do under JRuby.'
end
end
desc 'Clean up extension build files'
task :clean do
if !defined?(JRUBY_VERSION)
pwd = Dir.pwd
ext_dir = File.expand_path('ext/oboe_metal')
symlink = File.expand_path('lib/oboe_metal.so')
File.delete symlink if File.exist? symlink
Dir.chdir ext_dir
sh '/usr/bin/env make clean'
Dir.chdir pwd
else
puts '== Nothing to do under JRuby.'
end
end
desc 'Remove all built files and extensions'
task :distclean do
if !defined?(JRUBY_VERSION)
pwd = Dir.pwd
ext_dir = File.expand_path('ext/oboe_metal')
symlink = File.expand_path('lib/oboe_metal.so')
mkmf_log = File.expand_path('ext/oboe_metal/mkmf.log')
if File.exist? mkmf_log
File.delete symlink if File.exist? symlink
Dir.chdir ext_dir
sh '/usr/bin/env make distclean'
Dir.chdir pwd
else
puts 'Nothing to distclean. (nothing built yet?)'
end
else
puts '== Nothing to do under JRuby.'
end
end
desc "Rebuild the gem's c extension"
task :recompile => [:distclean, :compile]
task :environment do
ENV['TRACEVIEW_GEM_VERBOSE'] = 'true'
Bundler.require(:default, :development)
TraceView::Config[:tracing_mode] = :always
TV::Test.load_extras
if TV::Test.gemfile?(:delayed_job)
require 'delayed/tasks'
end
end
task :console => :environment do
ARGV.clear
if TV::Test.gemfile?(:delayed_job)
require './test/servers/delayed_job'
end
Pry.start
end
# Used when testing Resque locally
task 'resque:setup' => :environment do
require 'resque/tasks'
end