licensed/Rakefile

64 строки
1.5 KiB
Ruby
Исходник Обычный вид История

2018-02-20 18:20:41 +03:00
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
2018-03-29 08:23:49 +03:00
require "rubocop/rake_task"
2018-02-20 18:20:41 +03:00
desc "Run source setup scripts"
task :setup do
Dir["script/source-setup/*"].each do |script|
2018-03-23 18:43:51 +03:00
# green
puts "\033[32mRunning #{script}.\e[0m"
if system(script)
# 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 = Dir["lib/licensed/source/*.rb"].map { |f| File.basename(f, ".*") }
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"
# use negative lookahead to exclude all source tests except
# the tests for `source`
2018-03-29 08:54:45 +03:00
t.test_files = FileList["test/**/*_test.rb"].exclude(/test\/source\/(?!#{source}).*?_test.rb/)
end
end
end
2018-02-20 18:20:41 +03:00
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
end
2018-03-29 08:23:49 +03:00
# add rubocop task
# -S adds styleguide urls to offense messages
RuboCop::RakeTask.new do |t|
t.options.push "-S"
end
2018-02-20 18:20:41 +03:00
task default: :test