-
Notifications
You must be signed in to change notification settings - Fork 35
/
Rakefile
94 lines (78 loc) · 2.28 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
# frozen_string_literal: true
require "./lib/orogen/version"
require "shellwords"
require "bundler/gem_tasks"
require "rake/testtask"
task :setup do
begin
require "typelib"
require "orogen"
rescue ScriptErrors => e
warn <<~MESSAGE
cannot load oroGen
- did you install Typelib\'s Ruby bindings and update the RUBYLIB environment
variable accordingly ?
- did you add #{File.expand_path('lib', __dir__)} to RUBYLIB ?
The error is: #{e.message}
MESSAGE
e.backtrace.each do |line|
warn " #{line}"
end
exit(1)
end
end
task default: :setup
ENV["OROGEN_DISABLE_PLUGINS"] = "1"
TESTOPTS = ENV.delete("TESTOPTS") || ""
RUBOCOP_REQUIRED = (ENV["RUBOCOP"] == "1")
USE_RUBOCOP = (ENV["RUBOCOP"] != "0")
USE_JUNIT = (ENV["JUNIT"] == "1")
REPORT_DIR = ENV["REPORT_DIR"] || File.expand_path("test_reports", __dir__)
def minitest_set_options(test_task, name)
minitest_options = []
if USE_JUNIT
minitest_options += [
"--junit", "--junit-jenkins",
"--junit-filename=#{REPORT_DIR}/#{name}.junit.xml"
]
end
minitest_args =
if minitest_options.empty?
""
else
"\"" + minitest_options.join("\" \"") + "\""
end
test_task.options = "#{TESTOPTS} #{minitest_args} -- --simplecov-name=#{name}"
end
Rake::TestTask.new(:test) do |t|
t.libs << "lib"
minitest_set_options(t, "core")
t.libs << "test"
t.warning = false
t.test_files = FileList.new("test/**/test_*.rb") do |fl|
fl.exclude { |p| %r{^test/gen}.match?(p) && (p != "test/gen/test_base.rb") }
end
end
Rake::TestTask.new("test:gen") do |t|
t.libs << "lib"
minitest_set_options(t, "gen")
t.libs << "test"
t.warning = false
t.test_files = FileList["test/gen/**/test_*.rb"]
end
task "test:all" => ["test", "test:gen"]
if USE_RUBOCOP
begin
require "rubocop/rake_task"
RuboCop::RakeTask.new do |t|
if USE_JUNIT
t.formatters << "junit"
t.options << "-o" << "#{REPORT_DIR}/rubocop.junit.xml"
end
end
task "test" => "rubocop"
rescue LoadError
raise if RUBOCOP_REQUIRED
end
end
task gem: :build