Skip to content

Commit b684ab7

Browse files
committed
Correctly cleanup after tests
1 parent e442ef9 commit b684ab7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/test_pmd_report_builder.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ class TestPmdReportBuilder < Test::Unit::TestCase
77
def setup
88
# pmd version that is simulated in tests when pmd should be built
99
@pmd_version = '6.10.0-SNAPSHOT'
10+
end
1011

12+
def teardown
13+
pmd_repo = 'target/repositories/pmd'
1114
# pre-built PMD binary
12-
pmd_binary = "target/repositories/pmd/pmd-dist/target/pmd-bin-#{@pmd_version}.zip"
13-
15+
pmd_binary = "#{pmd_repo}/pmd-dist/target/pmd-bin-#{@pmd_version}.zip"
1416
File.unlink pmd_binary if File.exist? pmd_binary
17+
18+
# only deleting empty directories in order to leave pmd_repo intact
19+
# for local dev environment, where a local pmd clone might already exist
20+
["#{pmd_repo}/pmd-dist/target", "#{pmd_repo}/pmd-dist", pmd_repo].each do |d|
21+
Dir.unlink(d) if Dir.exist?(d) && Dir.empty?(d)
22+
end
1523
end
1624

1725
def test_build_skip

0 commit comments

Comments
 (0)