gitlab-org--gitlab-foss/lib/tasks/spinach.rake

61 lines
1.7 KiB
Ruby
Raw Normal View History

Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach')
2015-06-23 10:48:52 -04:00
namespace :spinach do
2015-12-09 04:50:38 -05:00
namespace :project do
desc "GitLab | Spinach | Run project commits, issues and merge requests spinach features"
task :half do
2016-03-09 08:12:08 -05:00
run_spinach_tests('@project_commits,@project_issues,@project_merge_requests')
2015-12-09 04:50:38 -05:00
end
desc "GitLab | Spinach | Run remaining project spinach features"
task :rest do
2016-03-09 08:12:08 -05:00
run_spinach_tests('~@admin,~@dashboard,~@profile,~@public,~@snippets,~@project_commits,~@project_issues,~@project_merge_requests')
2015-12-09 04:50:38 -05:00
end
end
2015-06-23 10:48:52 -04:00
desc "GitLab | Spinach | Run project spinach features"
task :project do
2016-03-09 08:12:08 -05:00
run_spinach_tests('~@admin,~@dashboard,~@profile,~@public,~@snippets')
2015-06-23 10:48:52 -04:00
end
2015-06-23 10:48:52 -04:00
desc "GitLab | Spinach | Run other spinach features"
task :other do
2016-03-09 08:12:08 -05:00
run_spinach_tests('@admin,@dashboard,@profile,@public,@snippets')
end
desc "GitLab | Spinach | Run other spinach features"
task :builds do
run_spinach_tests('@builds')
2015-06-23 10:48:52 -04:00
end
end
2015-06-23 10:48:52 -04:00
desc "GitLab | Run spinach"
task :spinach do
2016-03-09 08:12:08 -05:00
run_spinach_tests(nil)
end
def run_system_command(cmd)
2016-03-09 08:12:08 -05:00
system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd)
end
2016-03-09 08:12:08 -05:00
def run_spinach_command(args)
run_system_command(%w(spinach -r rerun) + args)
2016-03-09 08:12:08 -05:00
end
def run_spinach_tests(tags)
success = run_spinach_command(%W(--tags #{tags}))
3.times do |_|
break if success
break unless File.exist?('tmp/spinach-rerun.txt')
2016-03-09 08:12:08 -05:00
tests = File.foreach('tmp/spinach-rerun.txt').map(&:chomp)
puts ''
puts "Spinach tests for #{tags}: Retrying tests... #{tests}".color(:red)
2016-03-09 08:12:08 -05:00
puts ''
sleep(3)
success = run_spinach_command(tests)
end
2016-03-09 08:12:08 -05:00
raise("spinach tests for #{tags} failed!") unless success
2015-12-09 04:50:38 -05:00
end