Skip to content

Commit

Permalink
Fix test rake task indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jan 9, 2024
1 parent 7a948b7 commit 98ba05e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 62 deletions.
78 changes: 39 additions & 39 deletions lib/tasks/test.rake
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
require_relative './evm_test_helper'

if defined?(RSpec)
namespace :test do
task :initialize do
if ENV['RAILS_ENV'] && ENV["RAILS_ENV"] != "test"
warn "Warning: RAILS_ENV is currently set to '#{ENV["RAILS_ENV"]}'. Forcing to 'test' for this run."
namespace :test do
task :initialize do
if ENV['RAILS_ENV'] && ENV["RAILS_ENV"] != "test"
warn "Warning: RAILS_ENV is currently set to '#{ENV["RAILS_ENV"]}'. Forcing to 'test' for this run."
end
ENV['RAILS_ENV'] = "test"
Rails.env = 'test' if defined?(Rails)

ENV['VERBOSE'] ||= "false"
end
ENV['RAILS_ENV'] = "test"
Rails.env = 'test' if defined?(Rails)

ENV['VERBOSE'] ||= "false"
end
desc "Verifies that the rails environment does not require DB access"
task :verify_no_db_access_loading_rails_environment do
if Rake::Task['environment'].already_invoked
raise "Failed to verify database access when loading rails because the 'environment' rake task has already been invoked!"
end

desc "Verifies that the rails environment does not require DB access"
task :verify_no_db_access_loading_rails_environment do
if Rake::Task['environment'].already_invoked
raise "Failed to verify database access when loading rails because the 'environment' rake task has already been invoked!"
EvmRakeHelper.with_dummy_database_url_configuration do
begin
puts "** Confirming rails environment does not connect to the database"
Rake::Task['environment'].invoke
rescue ActiveRecord::NoDatabaseError
STDERR.write "Detected Rails environment trying to connect to the database! Check the backtrace for an initializer trying to access the database.\n\n"
raise
end
end
end

EvmRakeHelper.with_dummy_database_url_configuration do
begin
puts "** Confirming rails environment does not connect to the database"
Rake::Task['environment'].invoke
rescue ActiveRecord::NoDatabaseError
STDERR.write "Detected Rails environment trying to connect to the database! Check the backtrace for an initializer trying to access the database.\n\n"
raise
end
task :setup_db => [:initialize, :setup_region] do
reset_task = defined?(ENGINE_ROOT) ? 'app:evm:db:reset' : 'evm:db:reset'
Rake::Task[reset_task].invoke
end
end

task :setup_db => [:initialize, :setup_region] do
reset_task = defined?(ENGINE_ROOT) ? 'app:evm:db:reset' : 'evm:db:reset'
Rake::Task[reset_task].invoke
end
task :setup_region do
ENV["REGION"] ||= (rand(99) + 1).to_s # Ensure we have a random, non-0, region
puts "** Preparing database with REGION #{ENV["REGION"]}"
end

task :spec_deps => [:initialize, 'evm:compile_sti_loader']

task :setup_region do
ENV["REGION"] ||= (rand(99) + 1).to_s # Ensure we have a random, non-0, region
puts "** Preparing database with REGION #{ENV["REGION"]}"
task :setup do
test_suite = ENV["TEST_SUITE"] || "vmdb"
Rake::Task["test:#{test_suite}:setup"].invoke
end
end

task :spec_deps => [:initialize, 'evm:compile_sti_loader']
task :default => :test

task :setup do
task :test do
test_suite = ENV["TEST_SUITE"] || "vmdb"
Rake::Task["test:#{test_suite}:setup"].invoke
Rake::Task["test:#{test_suite}"].invoke
end
end

task :default => :test

task :test do
test_suite = ENV["TEST_SUITE"] || "vmdb"
Rake::Task["test:#{test_suite}"].invoke
end
end # ifdef
16 changes: 8 additions & 8 deletions lib/tasks/test_providers_common.rake
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require_relative './evm_test_helper'

if defined?(RSpec)
namespace :test do
desc "Run all specs tagged 'providers_common'"
RSpec::Core::RakeTask.new(:providers_common => :spec_deps) do |t|
EvmTestHelper.init_rspec_task(t, ['--tag', 'providers_common'])
namespace :test do
desc "Run all specs tagged 'providers_common'"
RSpec::Core::RakeTask.new(:providers_common => :spec_deps) do |t|
EvmTestHelper.init_rspec_task(t, ['--tag', 'providers_common'])

if defined?(ENGINE_ROOT)
t.rspec_opts += ["--exclude-pattern", "manageiq/spec/tools/**/*_spec.rb"]
t.pattern = "manageiq/spec/**/*_spec.rb"
if defined?(ENGINE_ROOT)
t.rspec_opts += ["--exclude-pattern", "manageiq/spec/tools/**/*_spec.rb"]
t.pattern = "manageiq/spec/**/*_spec.rb"
end
end
end
end
end
30 changes: 15 additions & 15 deletions lib/tasks/test_vmdb.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ require_relative "./evm_test_helper"

if defined?(RSpec) && defined?(RSpec::Core::RakeTask)

require 'parallel_tests/tasks'
require 'parallel_tests/tasks'

namespace :test do
namespace :vmdb do
desc "Setup environment for vmdb specs"
task :setup => :initialize do |rake_task|
# in case we are called from an engine or plugin, the task might be namespaced under 'app:'
# i.e. it's 'app:test:vmdb:setup'. Then we have to call the tasks in here under the 'app:' namespace too
app_prefix = rake_task.name.chomp('test:vmdb:setup')
Rake::Task["#{app_prefix}test:setup_db"].invoke
namespace :test do
namespace :vmdb do
desc "Setup environment for vmdb specs"
task :setup => :initialize do |rake_task|
# in case we are called from an engine or plugin, the task might be namespaced under 'app:'
# i.e. it's 'app:test:vmdb:setup'. Then we have to call the tasks in here under the 'app:' namespace too
app_prefix = rake_task.name.chomp('test:vmdb:setup')
Rake::Task["#{app_prefix}test:setup_db"].invoke
end
end
end

desc "Run all vmdb specs"
RSpec::Core::RakeTask.new(:vmdb => :spec_deps) do |t|
EvmTestHelper.init_rspec_task(t)
t.pattern = EvmTestHelper.vmdb_spec_directories
desc "Run all vmdb specs"
RSpec::Core::RakeTask.new(:vmdb => :spec_deps) do |t|
EvmTestHelper.init_rspec_task(t)
t.pattern = EvmTestHelper.vmdb_spec_directories
end
end
end
end # ifdef

0 comments on commit 98ba05e

Please sign in to comment.