diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /tooling/merge_request_rspec_failure_rake_task.rb | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'tooling/merge_request_rspec_failure_rake_task.rb')
-rw-r--r-- | tooling/merge_request_rspec_failure_rake_task.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tooling/merge_request_rspec_failure_rake_task.rb b/tooling/merge_request_rspec_failure_rake_task.rb new file mode 100644 index 00000000000..02ac38bee69 --- /dev/null +++ b/tooling/merge_request_rspec_failure_rake_task.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'test_file_finder' +require_relative './merge_request' + +module Tooling + class MergeRequestRspecFailureRakeTask < RSpec::Core::RakeTask + PROJECT_PATH = 'gitlab-org/gitlab' + + def run_task(_verbose) + if pattern.empty? + puts "No rspec failures in the merge request." + return + end + + super + end + + def rspec_failures_on_merge_request + test_file_finder = TestFileFinder::FileFinder.new + test_file_finder.use TestFileFinder::MappingStrategies::GitlabMergeRequestRspecFailure.new(project_path: PROJECT_PATH, merge_request_iid: merge_request.iid) + test_file_finder.test_files + rescue TestFileFinder::TestReportError => e + abort e.message + end + + private + + def merge_request + @merge_request ||= Tooling::MergeRequest.for(branch: current_branch, project_path: PROJECT_PATH) + end + + def current_branch + @current_branch ||= `git branch --show-current`.strip + end + end +end |