Commit 2651ee6a authored by Kerri Miller's avatar Kerri Miller

Merge branch 'revert-0ea64f98' into 'master'

Revert delete prefix for junit attachment path

See merge request gitlab-org/gitlab!62928
parents b4651551 dd910ae2
...@@ -994,7 +994,7 @@ module Ci ...@@ -994,7 +994,7 @@ module Ci
end end
def latest_test_report_builds 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 end
def builds_with_coverage def builds_with_coverage
......
...@@ -66,12 +66,10 @@ module Gitlab ...@@ -66,12 +66,10 @@ module Gitlab
status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
system_output = data['failure'] system_output = data['failure']
attachment = attachment_path(data['system_out']) attachment = attachment_path(data['system_out'])
attachment = remove_project_prefix(attachment, job)
elsif data.key?('error') elsif data.key?('error')
status = ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR status = ::Gitlab::Ci::Reports::TestCase::STATUS_ERROR
system_output = data['error'] system_output = data['error']
attachment = attachment_path(data['system_out']) attachment = attachment_path(data['system_out'])
attachment = remove_project_prefix(attachment, job)
elsif data.key?('skipped') elsif data.key?('skipped')
status = ::Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED status = ::Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED
system_output = data['skipped'] system_output = data['skipped']
...@@ -103,10 +101,6 @@ module Gitlab ...@@ -103,10 +101,6 @@ module Gitlab
matches = data.match(ATTACHMENT_TAG_REGEX) matches = data.match(ATTACHMENT_TAG_REGEX)
matches[:path] if matches matches[:path] if matches
end end
def remove_project_prefix(attachment, job)
attachment&.delete_prefix(job.variables['CI_PROJECT_DIR']&.value || '')
end
end end
end end
end end
......
...@@ -8,14 +8,8 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do ...@@ -8,14 +8,8 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do
let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new('rspec') } let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new('rspec') }
let(:test_cases) { flattened_test_cases(test_suite) } 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(: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 data is JUnit style XML' do
context 'when there are no <testcases> in <testsuite>' do context 'when there are no <testcases> in <testsuite>' do
...@@ -423,27 +417,6 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do ...@@ -423,27 +417,6 @@ RSpec.describe Gitlab::Ci::Parsers::Test::Junit do
end end
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 context 'when attachment is specified in test case with error' do
let(:junit) do let(:junit) do
<<~EOF <<~EOF
......
...@@ -177,6 +177,7 @@ RSpec.configure do |config| ...@@ -177,6 +177,7 @@ RSpec.configure do |config|
config.append_after do |example| config.append_after do |example|
if example.metadata[:screenshot] if example.metadata[:screenshot]
screenshot = example.metadata[:screenshot][:image] || example.metadata[:screenshot][:html] screenshot = example.metadata[:screenshot][:image] || example.metadata[:screenshot][:html]
screenshot&.delete_prefix!(ENV.fetch('CI_PROJECT_DIR', ''))
example.metadata[:stdout] = %{[[ATTACHMENT|#{screenshot}]]} example.metadata[:stdout] = %{[[ATTACHMENT|#{screenshot}]]}
end end
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