Sha256: a3551ef5720b6a9a5e23af9b0c9d364281999148c1c87173965c282c8ce62148
Contents?: true
Size: 1.83 KB
Versions: 9
Compression:
Stored size: 1.83 KB
Contents
require "bundler/gem_tasks" require "rake/testtask" namespace :db do namespace :mysql do task :env do system "mysql -e 'drop database if exists pluck_map_test'" system "mysql -e 'create database pluck_map_test'" ENV["ACTIVE_RECORD_ADAPTER"] = "mysql2" end end namespace :postgres do task :env do system "psql -c 'drop database if exists pluck_map_test'" system "psql -c 'create database pluck_map_test'" ENV["ACTIVE_RECORD_ADAPTER"] = "postgresql" end end namespace :sqlite do task :env do ENV["ACTIVE_RECORD_ADAPTER"] = "sqlite3" end end end ADAPTERS = Rake.application.tasks.each_with_object([]) do |task, adapters| match = task.name.match(/db:(.*):env/) adapters.push(match[1]) if match end.freeze namespace :test do ADAPTERS.each do |adapter| Rake::TestTask.new(adapter => "db:#{adapter}:env") do |t| t.libs << "test" t.libs << "lib" t.test_files = FileList["test/**/*_test.rb"] end end end namespace :benchmark do ADAPTERS.each do |adapter| desc "Run benchmarks on #{adapter}" task adapter => "db:#{adapter}:env" do load File.expand_path("test/benchmarks.rb", __dir__) end end end def run_without_aborting(*tasks) errors = [] tasks.each do |task| puts task Rake::Task[task].invoke rescue Exception puts "\e[31m#{$!.class}: #{$!.message}\e[0m" errors << task end abort "Errors running #{errors.join(', ')}" if errors.any? end desc "Run #{ADAPTERS.join(', ')} tests" task :test do tasks = ADAPTERS.map { |adapter| "test:#{adapter}" } run_without_aborting(*tasks) end desc "Run #{ADAPTERS.join(', ')} benchmarks" task :benchmark do tasks = ADAPTERS.map { |adapter| "benchmark:#{adapter}" } run_without_aborting(*tasks) end desc "Run #{ADAPTERS.join(', ')} tests by default" task default: :test
Version data entries
9 entries across 9 versions & 1 rubygems