forked from fengguang/lkp-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
50 lines (43 loc) · 1.12 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
require 'rubygems'
require 'bundler/setup' unless `hostname`.chomp == 'inn'
require 'rspec/core/rake_task'
require 'fileutils'
begin
require 'rubocop/rake_task'
rescue LoadError => e
puts e.to_s
end
# SPEC
#
# usage: rake spec [spec=result_path]
# example:
# - "rake spec" : check all unit tests status
# - "rake spec spec=job" : check spec/job_spec.rb status
#
# RUBOCOP
#
# usage: rake rubocop [file=pattern]
# example:
# - rake rubocop file="lib/**/*.rb": check all lib files
RSpec::Core::RakeTask.new do |t|
ENV['LKP_SRC'] ||= File.expand_path File.dirname(__FILE__).to_s
puts "PWD = #{Dir.pwd}"
puts "ENV['LKP_SRC'] = #{ENV['LKP_SRC']}"
spec = ENV['spec'] || '*'
t.pattern = "spec/**{,/*/**}/#{spec}_spec.rb"
end
if ENV['GENERATE_REPORTS'] == 'true'
require 'ci/reporter/rake/rspec'
task spec: 'ci:setup:rspec'
end
begin
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['-D', '-c.rubocop.yml']
t.patterns = [ENV['file']] if ENV['file']
puts "PWD = #{Dir.pwd}"
puts "rubocop.patterns = #{t.patterns}"
puts "rubocop.options = #{t.options}"
end
rescue StandardError => e
puts e.to_s
end