debian-mirror-gitlab/lib/tasks/spinach.rake

61 lines
1.7 KiB
Ruby
Raw Normal View History

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