2014-03-14 08:23:28 -04:00
|
|
|
Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach')
|
2014-03-14 04:44:16 -04:00
|
|
|
|
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
|
2014-06-04 16:55:27 -04:00
|
|
|
|
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
|
2014-06-04 16:55:27 -04:00
|
|
|
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
|
|
|
|
|
2016-08-09 19:29:14 -04:00
|
|
|
def run_system_command(cmd)
|
2016-03-09 08:12:08 -05:00
|
|
|
system({'RAILS_ENV' => 'test', 'force' => 'yes'}, *cmd)
|
2014-06-04 16:55:27 -04:00
|
|
|
end
|
2014-03-14 04:44:16 -04:00
|
|
|
|
2016-03-09 08:12:08 -05:00
|
|
|
def run_spinach_command(args)
|
2016-08-09 19:29:14 -04:00
|
|
|
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
|
2016-08-09 17:23:25 -04:00
|
|
|
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 ''
|
2016-06-01 18:37:15 -04:00
|
|
|
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)
|
2014-03-14 04:44:16 -04:00
|
|
|
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
|