forked from github/licensed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
81 lines (68 loc) · 2.09 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
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
require "rubocop/rake_task"
require "licensed"
desc "Run source setup scripts"
task :setup, [:arguments] do |task, args|
arguments = args[:arguments].to_s.split
force = arguments.include?("-f") ? "-f" : ""
Dir["script/source-setup/**/*"].each do |script|
next if File.directory?(script)
# green
puts "\033[32mRunning #{script}.\e[0m"
if Bundler.with_clean_env { system(script, force) }
# green
puts "\033[32mCompleted #{script}.\e[0m"
elsif $?.exitstatus == 127
# yellow
puts "\033[33mSkipped #{script}.\e[0m"
else
# red
puts "\033[31mEncountered an error running #{script}.\e[0m"
end
puts
end
end
sources = Licensed::Sources::Source.sources.map { |source| source.full_type }
namespace :test do
sources.each do |source|
# hidden task to set ENV and filter tests to the given source
# see `each_source` in test/test_helper.rb
namespace source.to_sym do
task :env do
ENV["SOURCE"] = source
end
end
Rake::TestTask.new(source => "test:#{source}:env") do |t|
t.description = "Run #{source} tests"
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/commands/*_test.rb", "test/sources/#{source}_test.rb"]
end
end
namespace :core do
task :env do
ENV["SOURCE"] = ""
end
end
Rake::TestTask.new(core: "test:core:env") do |t|
t.description = "Run non-source tests"
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb")
.exclude("test/sources/*_test.rb")
.exclude("test/sources/**/*_test.rb")
end
end
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb")
end
# add rubocop task
# -S adds styleguide urls to offense messages
RuboCop::RakeTask.new do |t|
t.options.push "-S"
end
task default: :test