Commit dd910ae2 authored by Maxime Orefice's avatar Maxime Orefice

Revert "Merge branch 'mo-strip-out-junit-screenshot-path' into 'master'"

This reverts merge request !62520
parent 9258c973
......@@ -994,7 +994,7 @@ module Ci
end
def latest_test_report_builds
latest_report_builds(Ci::JobArtifact.test_reports).preload(:project, :job_variables, :metadata)
latest_report_builds(Ci::JobArtifact.test_reports).preload(:project)
end
def builds_with_coverage
......
......@@ -66,12 +66,10 @@ module Gitlab
status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
system_output = data['failure']
attachment = attachment_path(data['system_out'])
attachment = remove_project_prefix(attachment, job)
elsif data.key?('error')
status = ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR
system_output = data['error']
attachment = attachment_path(data['system_out'])
attachment = remove_project_prefix(attachment, job)
elsif data.key?('skipped')
status = ::Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED
system_output = data['skipped']
......@@ -103,10 +101,6 @@ module Gitlab
matches = data.match(ATTACHMENT_TAG_REGEX)
matches[:path] if matches
end
def remove_project_prefix(attachment, job)
attachment&.delete_prefix(job.variables['CI_PROJECT_DIR']&.value || '')
end
end
end
end
......
......@@ -8,14 +8,8 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do
let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new('rspec') }
let(:test_cases) { flattened_test_cases(test_suite) }
let(:variables) { [{ key: 'CI_PROJECT_DIR', value: '/builds/group/project' }] }
let(:job) { double(max_test_cases_per_report: max_test_cases) }
let(:max_test_cases) { 0 }
let(:job) do
double(
max_test_cases_per_report: max_test_cases,
variables: Gitlab::Ci::Variables::Collection.new.concat(variables)
)
end
context 'when data is JUnit style XML' do
context 'when there are no <testcases> in <testsuite>' do
......@@ -423,27 +417,6 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do
end
end
context 'when paths contains the build group project path' do
let(:junit) do
<<~EOF
<testsuites>
<testsuite>
<testcase classname='Calculator' name='sumTest1' time='0.01'>
<failure>Some failure</failure>
<system-out>[[ATTACHMENT|/builds/group/project/some/path.png]]</system-out>
</testcase>
</testsuite>
</testsuites>
EOF
end
it 'removes the builds group project path prefix' do
expect { subject }.not_to raise_error
expect(test_cases[0].attachment).to eq("/some/path.png")
end
end
context 'when attachment is specified in test case with error' do
let(:junit) do
<<~EOF
......
......@@ -177,6 +177,7 @@ RSpec.configure do |config|
config.append_after do |example|
if example.metadata[:screenshot]
screenshot = example.metadata[:screenshot][:image] || example.metadata[:screenshot][:html]
screenshot&.delete_prefix!(ENV.fetch('CI_PROJECT_DIR', ''))
example.metadata[:stdout] = %{[[ATTACHMENT|#{screenshot}]]}
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment