Skip to content

Commit 8c8fd75

Browse files
committed
Fix integration tests - missing pmd-core:jar:tests (#136)
Merge pull request #136 from adangel:fix-integration-tests
2 parents 017eac8 + 7deb6e0 commit 8c8fd75

File tree

3 files changed

+63
-11
lines changed

3 files changed

+63
-11
lines changed

History.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ projects. You might need to add `<tag>master</tag>` for some projects.
2424
* [#131](https://github.com/pmd/pmd-regression-tester/pull/131): Refactor GitHub Actions Workflows
2525
* [#132](https://github.com/pmd/pmd-regression-tester/pull/132): Fix manual integration test - Update expected_patch_config_3.xml: no more plsql exclusion
2626
* [#133](https://github.com/pmd/pmd-regression-tester/pull/133): \[ci] Make build a reuseable workflow
27+
* [#136](https://github.com/pmd/pmd-regression-tester/pull/136): Fix integration tests - missing pmd-core:jar:tests
2728

2829
## External Contributions
2930

lib/pmdtester/builders/pmd_report_builder.rb

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,26 @@ def find_pmd_dist_target
250250

251251
def build_pmd_with_maven
252252
logger.info "#{@pmd_branch_name}: Building PMD #{@pmd_version}..."
253-
package_cmd = './mvnw clean package ' \
254-
"-s #{ResourceLocator.resource('maven-settings.xml')} " \
255-
'-Pfor-dokka-maven-plugin ' \
256-
'-Dmaven.test.skip=true ' \
257-
'-Dmaven.javadoc.skip=true ' \
258-
'-Dmaven.source.skip=true ' \
259-
'-Dcheckstyle.skip=true ' \
260-
'-Dpmd.skip=true ' \
261-
'-T1C -B'
253+
254+
if Semver.compare(@pmd_version, '7.14.0') >= 0
255+
# build command since PMD migrated to central portal
256+
package_cmd = './mvnw clean package ' \
257+
'-PfastSkip ' \
258+
'-DskipTests ' \
259+
'-T1C -B'
260+
else
261+
# build command for older PMD versions
262+
package_cmd = './mvnw clean package ' \
263+
"-s #{ResourceLocator.resource('maven-settings.xml')} " \
264+
'-Pfor-dokka-maven-plugin ' \
265+
'-Dmaven.test.skip=true ' \
266+
'-Dmaven.javadoc.skip=true ' \
267+
'-Dmaven.source.skip=true ' \
268+
'-Dcheckstyle.skip=true ' \
269+
'-Dpmd.skip=true ' \
270+
'-T1C -B'
271+
end
272+
262273
logger.debug "#{@pmd_branch_name}: maven command: #{package_cmd}"
263274
Cmd.execute_successfully(package_cmd)
264275
end

test/test_pmd_report_builder.rb

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_build_normal
105105

106106
# PMD binary does not exist yet this time...
107107
record_expectations(sha1_head: 'sha1abc', sha1_base: 'sha1abc', zip_file_exists: false)
108-
stub_pmd_build_maven(binary_name: "pmd-bin-#{@pmd_version}.zip")
108+
stub_pmd_build_maven(binary_name: "pmd-bin-#{@pmd_version}.zip") # file is pmd-bin-...
109109
PmdTester::Cmd.stubs(:execute_successfully).with(
110110
"unzip -qo pmd-dist/target/pmd-bin-#{@pmd_version}.zip " \
111111
'-d pmd-dist/target/exploded'
@@ -129,7 +129,32 @@ def test_build_normal_pmd7
129129

130130
# PMD binary does not exist yet this time...
131131
record_expectations(sha1_head: 'sha1abc', sha1_base: 'sha1abc', zip_file_exists: false)
132-
stub_pmd_build_maven(binary_name: "pmd-dist-#{@pmd_version}-bin.zip")
132+
stub_pmd_build_maven(binary_name: "pmd-dist-#{@pmd_version}-bin.zip") # file is pmd-dist-...
133+
PmdTester::Cmd.stubs(:execute_successfully).with(
134+
"unzip -qo pmd-dist/target/pmd-dist-#{@pmd_version}-bin.zip " \
135+
'-d pmd-dist/target/exploded'
136+
).once
137+
PmdTester::Cmd.stubs(:execute_successfully).with(
138+
"mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version} " \
139+
"#{Dir.getwd}/target/pmd-bin-#{@pmd_version}-main-sha1abc"
140+
).once
141+
record_expectations_after_build
142+
143+
PmdTester::PmdReportBuilder
144+
.new(projects, options, options.base_config, options.base_branch)
145+
.build
146+
end
147+
148+
def test_build_normal_pmd7_new_build
149+
@pmd_version = '7.14.0'
150+
projects = []
151+
argv = %w[-r target/repositories/pmd -b main -p pmd_releases/7.14.0
152+
-c config/design.xml -l test/resources/pmd_report_builder/project-test.xml]
153+
options = PmdTester::Options.new(argv)
154+
155+
# PMD binary does not exist yet this time...
156+
record_expectations(sha1_head: 'sha1abc', sha1_base: 'sha1abc', zip_file_exists: false)
157+
stub_pmd_build_maven_new_pmd7_build()
133158
PmdTester::Cmd.stubs(:execute_successfully).with(
134159
"unzip -qo pmd-dist/target/pmd-dist-#{@pmd_version}-bin.zip " \
135160
'-d pmd-dist/target/exploded'
@@ -357,4 +382,19 @@ def stub_pmd_build_maven(binary_name:)
357382
end
358383
end.once
359384
end
385+
386+
def stub_pmd_build_maven_new_pmd7_build()
387+
PmdTester::Cmd.stubs(:execute_successfully).with do |cmd|
388+
if cmd == './mvnw clean package ' \
389+
'-PfastSkip ' \
390+
'-DskipTests ' \
391+
'-T1C -B'
392+
FileUtils.mkdir_p 'pmd-dist/target'
393+
FileUtils.touch "pmd-dist/target/pmd-dist-#{@pmd_version}-bin.zip"
394+
true
395+
else
396+
false
397+
end
398+
end.once
399+
end
360400
end

0 commit comments

Comments
 (0)