Sha256: e4dca20f301de5bebd33940fcdde5c2da6ec587eada801a12b6fd688a33f9221

Contents?: true

Size: 1.03 KB

Versions: 128

Compression:

Stored size: 1.03 KB

Contents

require 'nokogiri'

module Gitlab
  module QA
    module Report
      class UpdateScreenshotPath
        def initialize(files:)
          @files = files
        end

        REGEX = %r{(?<gitlab_qa_run>gitlab-qa-run-.*?(?=\/))\/(?<gitlab_ce_ee_qa>gitlab-(ee|ce)-qa-.*?(?=\/))}

        def invoke!
          Dir.glob(@files).each do |rspec_report_file|
            report = rewrite_each_screenshot_path(rspec_report_file)

            File.write(rspec_report_file, report)

            puts "Saved #{rspec_report_file}"
          end
        end

        private

        def rewrite_each_screenshot_path(rspec_report_file)
          report = Nokogiri::XML(File.open(rspec_report_file))

          match_data = rspec_report_file.match(REGEX)

          report.xpath('//system-out').each do |system_out|
            system_out.content = system_out.content.gsub(File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp'), "#{match_data[:gitlab_qa_run]}/#{match_data[:gitlab_ce_ee_qa]}")
          end

          report.to_s
        end
      end
    end
  end
end

Version data entries

128 entries across 128 versions & 1 rubygems

Version Path
gitlab-qa-6.1.2 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-6.1.1 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-6.1.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-6.0.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.17.1 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.17.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.16.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.15.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.14.1 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.14.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.7 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.6 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.5 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.4 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.3 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.2 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.1 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.13.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.12.0 lib/gitlab/qa/report/update_screenshot_path.rb
gitlab-qa-5.10.1 lib/gitlab/qa/report/update_screenshot_path.rb