-
Notifications
You must be signed in to change notification settings - Fork 9
/
Rakefile
89 lines (83 loc) · 3.13 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
require 'rake/testtask'
require 'minitest/reporters'
require 'parallel'
require 'rubocop/rake_task'
desc 'Run measure tests'
namespace :unit_tests do
desc 'Run all measure tests'
task :all_tests => [:measure_tests, :workflow_measure_tests, :upgrade_measure_tests] do
puts 'Running all measure tests:'
end
desc 'Run reporting measure tests'
task :reporting_measure_tests do
puts 'Running all reporting measure tests:'
# load test files from file
file_list = FileList.new(File.readlines('test/reporting_measure_tests.txt').map(&:chomp))
file_list.select! { |item| item.include?('rb') && File.exist?(item) }
Parallel.each(file_list, in_processes: Parallel.processor_count) do |file|
puts "Running test #{file} in process #{Process.pid}"
load file
true
rescue StandardError => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
end
desc 'Run workflow measure tests'
task :workflow_measure_tests do
puts 'Running all workflow measure tests:'
# load test files from file
file_list = FileList.new(File.readlines('test/workflow_measure_tests.txt').map(&:chomp))
file_list.select! { |item| item.include?('rb') && !item.include?('upgrade') && File.exist?(item) }
Parallel.each(file_list, in_processes: Parallel.processor_count) do |file|
puts "Running test #{file} in process #{Process.pid}"
load file
true
rescue StandardError => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
end
desc 'Run upgrade measure tests'
task :upgrade_measure_tests do
puts 'Running all upgrade measure tests:'
# load test files from file
file_list = FileList.new(File.readlines('test/upgrade_measure_tests.txt').map(&:chomp))
file_list.select! { |item| item.include?('rb') && item.include?('upgrade') && File.exist?(item) }
Parallel.each(file_list, in_processes: Parallel.processor_count) do |file|
puts "Running test #{file} in process #{Process.pid}"
load file
true
rescue StandardError => e
puts "Error in #{file}: #{e.message}"
Minitest::Reporters.reporter.report_error(file, e)
false
end
end
end
desc 'Check the code for style consistency'
RuboCop::RakeTask.new(:rubocop) do |t|
# Make a folder for the output
out_dir = '.rubocop'
FileUtils.mkdir_p(out_dir)
# Output both XML (CheckStyle format) and HTML
t.options = ["--out=#{out_dir}/rubocop-results.xml", '--format=h', "--out=#{out_dir}/rubocop-results.html", '--format=offenses', "--out=#{out_dir}/rubocop-summary.txt"]
t.requires = ['rubocop/formatter/checkstyle_formatter']
t.formatters = ['RuboCop::Formatter::CheckstyleFormatter']
# don't abort rake on failure
t.fail_on_error = false
end
desc 'Show the rubocop output in a web browser'
task 'rubocop:show' => [:rubocop] do
link = "#{__dir__}/.rubocop/rubocop-results.html"
case RbConfig::CONFIG['host_os']
when /mswin/, /mingw/, /cygwin/
system "start #{link}"
when /darwin/
system "open #{link}"
when /linux/, /bsd/
system "xdg-open #{link}"
end
end