44
55# Unit test class for PmdReportBuilder
66class 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