Skip to content

Commit 8a03269

Browse files
committed
Fix manual integration tests
The patches needed to be adapted to the final PMD 7 changes.
1 parent 9a6c4ae commit 8a03269

9 files changed

+55
-47
lines changed

History.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
## Fixed Issues
1010
* [#126](https://github.com/pmd/pmd-regression-tester/pull/126): Fix integration tests
11+
* [#127](https://github.com/pmd/pmd-regression-tester/pull/127): Fix manual integration tests
1112

1213
## External Contributions
1314

lib/pmdtester/runner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def download_baseline(url_prefix, branch_name)
9393

9494
url = get_baseline_url(url_prefix, zip_filename)
9595
logger.info "Downloading baseline for branch #{branch_name} from #{url}"
96-
wget_cmd = "wget --timestamping #{url}"
96+
wget_cmd = "wget --no-verbose --timestamping #{url}"
9797
unzip_cmd = "unzip -qo #{zip_filename}"
9898

9999
Dir.chdir(target_path) do

test/manual_integration_tests.rb

+14-12
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,20 @@ def test_case_1_single_java_rule_changed
4949
# checkstyle: 195 violations
5050
# spring-framework: 280 violations
5151
# openjdk11: 29 violations
52-
# -> total = 504
53-
assert_equal(195 + 280 + 29, @summary[:violations][:removed], 'found removed violations')
52+
# java-regression-tests: 1 violation
53+
# -> total = 505
54+
assert_equal(195 + 280 + 29 + 1, @summary[:violations][:removed], 'found removed violations')
5455

5556
# errors might have been caused in the baseline for other rules (only visible in the stacktrace)
5657
# hence they might appear as removed
5758

5859
# project "apex-link" has 2 errors removed, since we only executed java rules
59-
# project "checkstyle" has 10 errors removed and 1 changed
60-
# project "openjdk-11" has 0 error removed or changed
61-
# project "spring-framework" has 1 error removed
60+
# project "checkstyle" has 0 errors removed and 1 changed
61+
# project "openjdk-11" has 0 errors removed or changed
62+
# project "spring-framework" has 0 errors removed or changed
63+
# project "java-regression-tests" has 0 errors removed or changed
6264
# each project has 1 config error removed (LoosePackageCoupling dysfunctional): in total 7 config errors removed
63-
assert_equal(13, @summary[:errors][:removed], 'found removed errors')
65+
assert_equal(2, @summary[:errors][:removed], 'found removed errors')
6466
# The stack overflow exception might vary in the beginning/end of the stack frames shown
6567
# This stack overflow error is from checkstyle's InputIndentationLongConcatenatedString.java
6668
# instead of assert_equal(0, @summary[:errors][:changed], 'found changed errors')
@@ -73,7 +75,7 @@ def test_case_1_single_java_rule_changed
7375

7476
assert_equal("This changeset changes 0 violations,\n" \
7577
"introduces 0 new violations, 0 new errors and 0 new configuration errors,\n" \
76-
'removes 504 violations, 13 errors and 7 configuration errors.',
78+
'removes 505 violations, 2 errors and 7 configuration errors.',
7779
create_summary_message)
7880

7981
assert_file_equals("#{PATCHES_PATH}/expected_patch_config_1.xml", 'target/reports/diff/patch_config.xml')
@@ -99,11 +101,11 @@ def test_case_2_single_xpath_rule_changed
99101
# hence they might appear as removed
100102

101103
# project "apex-link" has 2 errors removed, since we only executed java rules
102-
# project "checkstyle" has 5 errors removed and 1 errors changed
103-
# project "openjdk-11" has 0 error removed or changed
104-
# project "spring-framework" has 1 error removed
104+
# project "checkstyle" has 0 errors removed and 1 errors changed
105+
# project "openjdk-11" has 0 errors removed or changed
106+
# project "spring-framework" has 0 errors removed or changed
105107
# each project has 1 config error removed (LoosePackageCoupling dysfunctional): in total 7 config errors removed
106-
assert_equal(8, @summary[:errors][:removed], 'found removed errors')
108+
assert_equal(2, @summary[:errors][:removed], 'found removed errors')
107109
# The stack overflow exception might vary in the beginning/end of the stack frames shown
108110
# This stack overflow error is from checkstyle's InputIndentationLongConcatenatedString.java
109111
# instead of assert_equal(0, @summary[:errors][:changed], 'found changed errors')
@@ -116,7 +118,7 @@ def test_case_2_single_xpath_rule_changed
116118

117119
assert_equal("This changeset changes 0 violations,\n" \
118120
"introduces 0 new violations, 0 new errors and 0 new configuration errors,\n" \
119-
'removes 22 violations, 8 errors and 7 configuration errors.',
121+
'removes 22 violations, 2 errors and 7 configuration errors.',
120122
create_summary_message)
121123

122124
assert_file_equals("#{PATCHES_PATH}/expected_patch_config_2.xml", 'target/reports/diff/patch_config.xml')

test/resources/manual_integration_tests/expected_patch_config_3.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0"?>
1+
<?xml version="1.0" encoding="UTF-8"?>
22

33
<ruleset name="All Regression Rules"
44
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,49 @@
1-
From ab94c0fed1813eb5e8376be51a7c93164652e26b Mon Sep 17 00:00:00 2001
1+
From c4b5364d69ea11a139a4fe9bb11f49124afb22af Mon Sep 17 00:00:00 2001
22
From: Andreas Dangel <[email protected]>
3-
Date: Thu, 4 May 2023 19:44:31 +0200
3+
Date: Thu, 5 Sep 2024 14:50:24 +0200
44
Subject: [PATCH] test case 1 - single java rule changed
55

6-
A single rule (java class) is changed. Only this rule should be executed
7-
and only this rule should be compared (ruleset is filtered).
6+
A single rule (java class) is changed. Only this rule should be
7+
executed and only this rule should be compared (ruleset is
8+
filtered).
89

910
The rule "AbstractClassWithoutAbstractMethod" doesn't report
1011
any violations anymore, so false-negatives should appear for
1112
exactly this rule.
1213
---
1314
.../bestpractices/AbstractClassWithoutAbstractMethodRule.java | 2 +-
14-
.../bestpractices/AbstractClassWithoutAbstractMethodTest.java | 3 +++
15+
.../java/rule/design/AbstractClassWithoutAnyMethodTest.java | 3 +++
1516
2 files changed, 4 insertions(+), 1 deletion(-)
1617

1718
diff --git a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodRule.java b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodRule.java
18-
index 0d0d8c33e4..972e1bd62a 100644
19+
index 835acebd14..5129fa0f15 100644
1920
--- a/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodRule.java
2021
+++ b/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodRule.java
2122
@@ -22,7 +22,7 @@ public class AbstractClassWithoutAbstractMethodRule extends AbstractJavaRulechai
2223
}
2324

2425
if (node.getDeclarations(ASTMethodDeclaration.class).none(ASTMethodDeclaration::isAbstract)) {
25-
- addViolation(data, node);
26-
+ //addViolation(data, node);
26+
- asCtx(data).addViolation(node);
27+
+ //asCtx(data).addViolation(node);
2728
}
2829
return data;
2930
}
30-
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodTest.java
31-
index b319c5e9f1..77698edb60 100644
32-
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodTest.java
33-
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AbstractClassWithoutAbstractMethodTest.java
31+
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/AbstractClassWithoutAnyMethodTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/AbstractClassWithoutAnyMethodTest.java
32+
index a5d9253ee2..2df451e9b8 100644
33+
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/AbstractClassWithoutAnyMethodTest.java
34+
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/design/AbstractClassWithoutAnyMethodTest.java
3435
@@ -4,8 +4,11 @@
3536

36-
package net.sourceforge.pmd.lang.java.rule.bestpractices;
37+
package net.sourceforge.pmd.lang.java.rule.design;
3738

3839
+import org.junit.jupiter.api.Disabled;
3940
+
40-
import net.sourceforge.pmd.testframework.PmdRuleTst;
41+
import net.sourceforge.pmd.test.PmdRuleTst;
4142

4243
+@Disabled
43-
class AbstractClassWithoutAbstractMethodTest extends PmdRuleTst {
44+
class AbstractClassWithoutAnyMethodTest extends PmdRuleTst {
4445
// no additional unit tests
4546
}
4647
--
47-
2.39.2
48+
2.45.2
49+
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From 1614ba4af8a0869f7bbc7b8dca60f1d7802218cc Mon Sep 17 00:00:00 2001
1+
From e0b3402ef126c6ea412a5e01f271b50e389c4c35 Mon Sep 17 00:00:00 2001
22
From: Andreas Dangel <[email protected]>
3-
Date: Thu, 4 May 2023 19:54:59 +0200
3+
Date: Thu, 5 Sep 2024 14:54:26 +0200
44
Subject: [PATCH] test case 2 - single xpath rule changed
55

66
The rule AvoidMessageDigestField is disabled
@@ -15,20 +15,20 @@ the baseline.
1515
2 files changed, 4 insertions(+), 1 deletion(-)
1616

1717
diff --git a/pmd-java/src/main/resources/category/java/bestpractices.xml b/pmd-java/src/main/resources/category/java/bestpractices.xml
18-
index 728ab98c9b..836428d33e 100644
18+
index 4bf4a370bf..41ce59b33a 100644
1919
--- a/pmd-java/src/main/resources/category/java/bestpractices.xml
2020
+++ b/pmd-java/src/main/resources/category/java/bestpractices.xml
2121
@@ -147,7 +147,7 @@ public class Foo {
2222
<property name="xpath">
2323
<value>
2424
<![CDATA[
25-
-//FieldDeclaration/ClassOrInterfaceType[pmd-java:typeIs('java.security.MessageDigest')]
26-
+//FieldDeclaration/ClassOrInterfaceType[pmd-java:typeIs('java.security.MessageDigestFoo')]
25+
-//FieldDeclaration/ClassType[pmd-java:typeIs('java.security.MessageDigest')]
26+
+//FieldDeclaration/ClassType[pmd-java:typeIs('java.security.MessageDigestFoo')]
2727
]]>
2828
</value>
2929
</property>
3030
diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidMessageDigestFieldTest.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidMessageDigestFieldTest.java
31-
index df4543674d..f5c87e6705 100644
31+
index 1403fe41f3..7f4e0947ea 100644
3232
--- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidMessageDigestFieldTest.java
3333
+++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/rule/bestpractices/AvoidMessageDigestFieldTest.java
3434
@@ -4,8 +4,11 @@
@@ -37,11 +37,12 @@ index df4543674d..f5c87e6705 100644
3737

3838
+import org.junit.jupiter.api.Disabled;
3939
+
40-
import net.sourceforge.pmd.testframework.PmdRuleTst;
40+
import net.sourceforge.pmd.test.PmdRuleTst;
4141

4242
+@Disabled
4343
class AvoidMessageDigestFieldTest extends PmdRuleTst {
4444
// no additional unit tests
4545
}
4646
--
47-
2.39.2
47+
2.45.2
48+

test/resources/manual_integration_tests/patch_test_case_3_modify_pmd-core.patch

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From 478d9f3767a449aefa8fb211e4e11debd9d7a6b6 Mon Sep 17 00:00:00 2001
1+
From 311f91741d0b1f8e58561e61035e8e432074403c Mon Sep 17 00:00:00 2001
22
From: Andreas Dangel <[email protected]>
3-
Date: Thu, 4 May 2023 19:58:47 +0200
3+
Date: Thu, 5 Sep 2024 14:56:46 +0200
44
Subject: [PATCH] test case 3 - change in pmd-core
55

66
This changes the class PMDVersion which will trigger a
@@ -10,7 +10,7 @@ complete reevaluation of all rules by the regression tester.
1010
1 file changed, 1 insertion(+)
1111

1212
diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java b/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java
13-
index 96565eca93..a9b134b4ff 100644
13+
index 19532bd99e..78f61a81cf 100644
1414
--- a/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java
1515
+++ b/pmd-core/src/main/java/net/sourceforge/pmd/PMDVersion.java
1616
@@ -2,6 +2,7 @@
@@ -22,4 +22,5 @@ index 96565eca93..a9b134b4ff 100644
2222

2323
import java.io.IOException;
2424
--
25-
2.39.2
25+
2.45.2
26+

test/resources/manual_integration_tests/patch_test_case_4_modify_docs.patch

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
From e1138cff3fff770e1b74688882e5bf09269b3a06 Mon Sep 17 00:00:00 2001
1+
From 454a8e2bda07ecceaa2b0114d5fd01b16028fcc0 Mon Sep 17 00:00:00 2001
22
From: Andreas Dangel <[email protected]>
3-
Date: Thu, 4 May 2023 20:00:52 +0200
3+
Date: Thu, 5 Sep 2024 14:57:32 +0200
44
Subject: [PATCH] test case 4 - unrelated change
55

66
This commit changes a file in /docs. This definitely doesn't
@@ -11,7 +11,7 @@ execution.
1111
1 file changed, 1 insertion(+), 1 deletion(-)
1212

1313
diff --git a/docs/index.md b/docs/index.md
14-
index be951ab7f8..eb030aa757 100644
14+
index 3bafc43f4d..ac7b593dfd 100644
1515
--- a/docs/index.md
1616
+++ b/docs/index.md
1717
@@ -17,7 +17,7 @@ additional_js:
@@ -24,4 +24,5 @@ index be951ab7f8..eb030aa757 100644
2424
## 💡 Overview
2525

2626
--
27-
2.39.2
27+
2.45.2
28+

test/test_runner.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_online_mode
104104
File.stubs(:new).with('target/reports/diff/index.html', anything).returns.once
105105

106106
Dir.stubs(:chdir).with('target/reports').yields.once
107-
Cmd.stubs(:execute_successfully).with('wget --timestamping https://sourceforge.net/projects/pmd/files/pmd-regression-tester/master-baseline.zip').once
107+
Cmd.stubs(:execute_successfully).with('wget --no-verbose --timestamping https://sourceforge.net/projects/pmd/files/pmd-regression-tester/master-baseline.zip').once
108108
Cmd.stubs(:execute_successfully).with('unzip -qo master-baseline.zip').once
109109
ProjectsParser.any_instance.stubs(:parse)
110110
.with('target/reports/master/project-list.xml')

0 commit comments

Comments
 (0)