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"
|
2021-11-27 05:48:16 +03:00
|
|
|
require "licensed"
|
2018-02-20 18:20:41 +03:00
|
|
|
|
2018-03-23 08:38:42 +03:00
|
|
|
desc "Run source setup scripts"
|
2018-05-17 09:16:48 +03:00
|
|
|
task :setup, [:arguments] do |task, args|
|
|
|
|
arguments = args[:arguments].to_s.split
|
|
|
|
force = arguments.include?("-f") ? "-f" : ""
|
|
|
|
|
2021-11-27 05:48:16 +03:00
|
|
|
Dir["script/source-setup/**/*"].each do |script|
|
|
|
|
next if File.directory?(script)
|
|
|
|
|
2018-03-23 18:43:51 +03:00
|
|
|
# green
|
|
|
|
puts "\033[32mRunning #{script}.\e[0m"
|
|
|
|
|
2018-05-17 09:18:58 +03:00
|
|
|
if Bundler.with_clean_env { system(script, force) }
|
2018-03-23 18:43:51 +03:00
|
|
|
# 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
|
2018-03-23 08:38:42 +03:00
|
|
|
end
|
|
|
|
|
2021-11-27 05:48:16 +03:00
|
|
|
sources = Licensed::Sources::Source.sources.map { |source| source.full_type }
|
2018-03-29 08:21:50 +03:00
|
|
|
|
|
|
|
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"
|
2019-03-31 08:16:19 +03:00
|
|
|
t.test_files = FileList["test/commands/*_test.rb", "test/sources/#{source}_test.rb"]
|
2018-03-29 08:21:50 +03:00
|
|
|
end
|
|
|
|
end
|
2019-08-22 20:12:49 +03:00
|
|
|
|
|
|
|
namespace :core do
|
|
|
|
task :env do
|
|
|
|
ENV["SOURCE"] = ""
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-08-22 21:06:00 +03:00
|
|
|
Rake::TestTask.new(core: "test:core:env") do |t|
|
2019-08-22 20:12:49 +03:00
|
|
|
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")
|
|
|
|
end
|
2018-03-29 08:21:50 +03:00
|
|
|
end
|
|
|
|
|
2018-02-20 18:20:41 +03:00
|
|
|
Rake::TestTask.new(:test) do |t|
|
|
|
|
t.libs << "test"
|
|
|
|
t.libs << "lib"
|
2018-06-15 22:38:20 +03:00
|
|
|
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb")
|
2018-02-20 18:20:41 +03:00
|
|
|
end
|
|
|
|
|
2018-06-21 21:27:02 +03:00
|
|
|
packages_search = File.expand_path("script/packages/*", __dir__)
|
2018-06-21 21:57:51 +03:00
|
|
|
platforms = Dir[packages_search].map { |f| File.basename(f, ".*") }
|
2019-04-17 02:50:58 +03:00
|
|
|
.reject { |f| f == "build" }
|
2018-06-21 21:27:02 +03:00
|
|
|
|
|
|
|
namespace :package do
|
|
|
|
platforms.each do |platform|
|
|
|
|
desc "Package licensed for #{platform}"
|
|
|
|
task platform.to_sym do
|
|
|
|
puts "Packaging licensed for #{platform}"
|
|
|
|
|
|
|
|
if Bundler.with_original_env { system("script/packages/#{platform}") }
|
|
|
|
# green
|
|
|
|
puts "\033[32mCompleted packaging for #{platform}.\e[0m"
|
|
|
|
else
|
|
|
|
# red
|
|
|
|
puts "\033[31mEncountered an error packaging for #{platform}.\e[0m"
|
|
|
|
end
|
|
|
|
|
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "Package licensed for all platforms"
|
|
|
|
task package: platforms.map { |platform| "package:#{platform}" }
|
|
|
|
|
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
|