forked from ohler55/oj
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Rakefile
105 lines (89 loc) · 2.47 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
#!/usr/bin/env rake
require 'bundler/gem_tasks'
require 'rake/extensiontask'
require 'rake/testtask'
Rake::ExtensionTask.new('oj') do |ext|
ext.lib_dir = 'lib/oj'
end
=begin
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.pattern = 'test/test_*.rb'
test.options = "-v"
end
=end
task :test_all => [:clean, :compile] do
STDOUT.flush
exitcode = 0
status = 0
cmds = "ruby test/tests.rb -v && ruby test/tests_mimic.rb -v && ruby test/tests_mimic_addition.rb -v"
STDOUT.syswrite "\n#{'#'*90}\n#{cmds}\n"
Bundler.with_original_env do
status = system(cmds)
end
exitcode = 1 unless status
# Verifying that json gem tests work for native implementation for Ruby 2.4.0
# and above only. We know the older versions do not pass the 2.4.0 unit
# tests.
if RUBY_VERSION >= '2.4'
Dir.glob('test/json_gem/*_test.rb').each do |file|
cmd = "bundle exec ruby -Itest #{file}"
STDOUT.syswrite "\n#{'#'*90}\n#{cmd}\n"
Bundler.with_original_env do
ENV['REAL_JSON_GEM'] = '1'
status = system(cmd)
end
exitcode = 1 unless status
end
end
Rake::Task['test'].invoke
exit(1) if exitcode == 1
end
task :default => :test_all
begin
require "rails/version"
if Rails.version =~ /^4\.\d/
Rake::TestTask.new "activesupport4" do |t|
t.libs << 'test'
t.pattern = 'test/activesupport4/*_test.rb'
t.warning = true
t.verbose = true
end
Rake::Task[:test_all].enhance ["activesupport4"]
end
if Rails.version =~ /^5\.\d/
Rake::TestTask.new "activesupport5" do |t|
t.libs << 'test'
t.pattern = 'test/activesupport5/*_test.rb'
t.warning = true
t.verbose = true
end
Rake::Task[:test_all].enhance ["activesupport5"]
end
if Rails.version =~ /^6\.\d/
Rake::TestTask.new "activesupport6" do |t|
t.libs << 'test'
t.pattern = 'test/activesupport6/*_test.rb'
t.warning = true
t.verbose = true
end
Rake::Task[:test_all].enhance ["activesupport6"]
end
if Rails.version =~ /7\.\d/
Rake::TestTask.new "activesupport7" do |t|
t.libs << 'test'
t.pattern = 'test/activesupport7/*_test.rb'
t.warning = true
t.verbose = true
end
Rake::Task[:test_all].enhance ["activesupport7"]
end
Rake::TestTask.new "activerecord" do |t|
t.libs << 'test'
t.pattern = 'test/activerecord/*_test.rb'
t.warning = true
t.verbose = true
end
Rake::Task[:test_all].enhance ["activerecord"]
rescue LoadError
end