Skip to content

Commit 2737ef0

Browse files
committed
Include version and branch name for distro_path
The full distro_path looks now like <cwd>/pmd-bin-<version>-<branch>-<sha>
1 parent cd16c88 commit 2737ef0

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

lib/pmdtester/builders/pmd_report_builder.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,11 @@ def work_dir
169169
end
170170

171171
# path to the unzipped distribution
172+
# e.g. <cwd>/pmd-bin-<version>-<branch>-<sha>
172173
def saved_distro_path(build_sha)
173-
"#{work_dir}/pmd-bin-#{build_sha}"
174+
"#{work_dir}/pmd-bin-#{@pmd_version}" \
175+
"-#{PmdBranchDetail.branch_filename(@pmd_branch_name)}" \
176+
"-#{build_sha}"
174177
end
175178

176179
def wd_has_dirty_git_changes

test/test_pmd_report_builder.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
# Unit test class for PmdReportBuilder
66
class TestPmdReportBuilder < Test::Unit::TestCase
7+
def setup
8+
# pmd version that is simulated in tests when pmd should be built
9+
@pmd_version = '6.10.0-SNAPSHOT'
10+
end
11+
712
def test_build_skip
813
projects = []
914
argv = %w[-r target/repositories/pmd -b master -p pmd_releases/6.1.0
@@ -28,10 +33,10 @@ def test_build_normal
2833
record_expectations('sha1abc', 'sha1abc', false)
2934
PmdTester::Cmd.stubs(:execute).with('./mvnw clean package -Dmaven.test.skip=true' \
3035
' -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Dcheckstyle.skip=true').once
31-
PmdTester::Cmd.stubs(:execute).with('unzip -qo pmd-dist/target/pmd-bin-6.10.0-SNAPSHOT.zip' \
36+
PmdTester::Cmd.stubs(:execute).with("unzip -qo pmd-dist/target/pmd-bin-#{@pmd_version}.zip" \
3237
' -d pmd-dist/target/exploded').once
33-
PmdTester::Cmd.stubs(:execute).with('mv pmd-dist/target/exploded/pmd-bin-6.10.0-SNAPSHOT' \
34-
" #{Dir.getwd}/target/pmd-bin-sha1abc").once
38+
PmdTester::Cmd.stubs(:execute).with("mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version}" \
39+
" #{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-sha1abc").once
3540
record_expectations_after_build
3641

3742
PmdTester::PmdReportBuilder
@@ -89,7 +94,7 @@ def record_expectations_project_build(sha1, error = false)
8994
PmdTester::SimpleProgressLogger.any_instance.stubs(:start).once
9095
PmdTester::SimpleProgressLogger.any_instance.stubs(:stop).once
9196
error_prefix = error ? 'PMD_JAVA_OPTS="-Dpmd.error_recovery -ea" ' : ''
92-
distro_path = "#{Dir.getwd}/target/pmd-bin-#{sha1}"
97+
distro_path = "#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-master-#{sha1}"
9398
PmdTester::Cmd.stubs(:execute)
9499
.with("#{error_prefix}" \
95100
"#{distro_path}/bin/run.sh " \
@@ -110,13 +115,13 @@ def record_expectations(sha1_head, sha1_base, zip_file_exists)
110115
PmdTester::Cmd.stubs(:execute).with('./mvnw -q -Dexec.executable="echo" ' \
111116
"-Dexec.args='${project.version}' " \
112117
'--non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec')
113-
.returns('6.10.0-SNAPSHOT').at_least(1).at_most(2)
118+
.returns(@pmd_version).at_least(1).at_most(2)
114119
PmdTester::Cmd.stubs(:execute).with('git status --porcelain').returns('').once
115120

116121
# back into get_pmd_binary_file
117122
PmdTester::Cmd.stubs(:execute).with('git rev-parse HEAD^{commit}').returns(sha1_head).once
118123
# PMD binary might not exist yet...
119-
distro_path = "target/pmd-bin-#{sha1_base}"
124+
distro_path = "target/pmd-bin-#{@pmd_version}-master-#{sha1_base}"
120125
if zip_file_exists
121126
FileUtils.mkdir_p(distro_path)
122127
elsif File.exist?(distro_path)

0 commit comments

Comments
 (0)