Skip to content

Commit 85a31ed

Browse files
Stop tests from polluting maven settings (#18525) (#18528)
The pluginmanager tests modify `~/.m2/settings.xml`. Previously when that file exists it would be restored on test cleanup. However if that file did not exist prior to the tests, the file with nonsense values generated during testing would persist. This would cause subsequent issues when the pluginmanager or other systems that respect those maven settings. This commit updates the test to ensure the test file is deleted if it did not previously exist. (cherry picked from commit f36ba65) Co-authored-by: Cas Donoghue <[email protected]>
1 parent cd82f32 commit 85a31ed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

spec/unit/plugin_manager/proxy_support_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
end
3131

3232
after do
33-
FileUtils.mv(settings_backup, settings) if File.exist?(settings_backup)
33+
if File.exist?(settings_backup)
34+
FileUtils.mv(settings_backup, settings)
35+
elsif File.exist?(settings)
36+
FileUtils.rm(settings)
37+
end
3438
environments.each { |key, _| ENV[key] = nil }
3539
end
3640

0 commit comments

Comments
 (0)