@@ -46,29 +46,34 @@ def test_case_1_single_java_rule_changed
4646 assert_equal ( 0 , @summary [ :violations ] [ :changed ] , 'found changed violations' )
4747 assert_equal ( 0 , @summary [ :violations ] [ :new ] , 'found new violations' )
4848 # These are the artificially created false-negatives for AbstractClassWithoutAbstractMethod rule
49- # checkstyle: 204 violations
49+ # checkstyle: 195 violations
5050 # spring-framework: 280 violations
5151 # openjdk11: 29 violations
52- # -> total = 513
53- assert_equal ( 204 + 280 + 29 , @summary [ :violations ] [ :removed ] , 'found removed violations' )
52+ # -> total = 504
53+ assert_equal ( 195 + 280 + 29 , @summary [ :violations ] [ :removed ] , 'found removed violations' )
5454
5555 # errors might have been caused in the baseline for other rules (only visible in the stacktrace)
5656 # hence they might appear as removed
5757
58- # project "apex-link" has 2 errors, since we only executed java rules, 2 errors are removed
59- assert_equal ( 2 , @summary [ :errors ] [ :removed ] , 'found removed errors' )
60- assert_equal ( 0 , @summary [ :errors ] [ :changed ] , 'found changed errors' )
58+ # 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
62+ # 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' )
64+ # The stack overflow exception might vary in the beginning/end of the stack frames shown
65+ # This stack overflow error is from checkstyle's InputIndentationLongConcatenatedString.java
66+ # instead of assert_equal(0, @summary[:errors][:changed], 'found changed errors')
67+ # allow 0 or 1 changed errors
68+ assert @summary [ :errors ] [ :changed ] <= 1
6169 assert_equal ( 0 , @summary [ :errors ] [ :new ] , 'found new errors' )
6270 assert_equal ( 0 , @summary [ :configerrors ] [ :changed ] , 'found changed configerrors' )
6371 assert_equal ( 0 , @summary [ :configerrors ] [ :new ] , 'found new configerrors' )
64- # Only the rule AbstractClassWithoutAbtractMethod has been executed, so the
65- # configerrors about LoosePackageCoupling are gone, one for each project
66- # we now have 7 projects in total (4 java, 3 apex)
6772 assert_equal ( 7 , @summary [ :configerrors ] [ :removed ] , 'found removed configerrors' )
6873
6974 assert_equal ( "This changeset changes 0 violations,\n " \
7075 "introduces 0 new violations, 0 new errors and 0 new configuration errors,\n " \
71- 'removes 513 violations, 2 errors and 7 configuration errors.' ,
76+ 'removes 504 violations, 13 errors and 7 configuration errors.' ,
7277 create_summary_message )
7378
7479 assert_file_equals ( "#{ PATCHES_PATH } /expected_patch_config_1.xml" , 'target/reports/diff/patch_config.xml' )
@@ -93,20 +98,25 @@ def test_case_2_single_xpath_rule_changed
9398 # errors might have been caused in the baseline for other rules (only visible in the stacktrace)
9499 # hence they might appear as removed
95100
96- # project "apex-link" has 2 errors, since we only executed java rules, 2 errors are removed
97- assert_equal ( 2 , @summary [ :errors ] [ :removed ] , 'found removed errors' )
98- assert_equal ( 0 , @summary [ :errors ] [ :changed ] , 'found changed errors' )
101+ # 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
105+ # 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' )
107+ # The stack overflow exception might vary in the beginning/end of the stack frames shown
108+ # This stack overflow error is from checkstyle's InputIndentationLongConcatenatedString.java
109+ # instead of assert_equal(0, @summary[:errors][:changed], 'found changed errors')
110+ # allow 0 or 1 changed errors
111+ assert @summary [ :errors ] [ :changed ] <= 1
99112 assert_equal ( 0 , @summary [ :errors ] [ :new ] , 'found new errors' )
100113 assert_equal ( 0 , @summary [ :configerrors ] [ :changed ] , 'found changed configerrors' )
101114 assert_equal ( 0 , @summary [ :configerrors ] [ :new ] , 'found new configerrors' )
102- # Only the rule AvoidMessageDigestField and all other rules from bestpractices have been executed, so the
103- # configerrors about LoosePackageCoupling are gone, one for each project
104- # we now have 7 projects in total (4 java, 3 apex)
105115 assert_equal ( 7 , @summary [ :configerrors ] [ :removed ] , 'found removed configerrors' )
106116
107117 assert_equal ( "This changeset changes 0 violations,\n " \
108118 "introduces 0 new violations, 0 new errors and 0 new configuration errors,\n " \
109- 'removes 22 violations, 2 errors and 7 configuration errors.' ,
119+ 'removes 22 violations, 8 errors and 7 configuration errors.' ,
110120 create_summary_message )
111121
112122 assert_file_equals ( "#{ PATCHES_PATH } /expected_patch_config_2.xml" , 'target/reports/diff/patch_config.xml' )
@@ -115,7 +125,7 @@ def test_case_2_single_xpath_rule_changed
115125
116126 def test_case_3_change_in_core
117127 checkout_pmd_branch
118- prepare_patch_branch ( 'patch_test_case_3_modify_PMD .patch' , 'test-case-3' )
128+ prepare_patch_branch ( 'patch_test_case_3_modify_pmd-core .patch' , 'test-case-3' )
119129
120130 run_pmd_tester
121131
@@ -125,7 +135,11 @@ def test_case_3_change_in_core
125135 assert_equal ( 0 , @summary [ :violations ] [ :new ] , 'found new violations' )
126136 assert_equal ( 0 , @summary [ :violations ] [ :removed ] , 'found removed violations' )
127137 assert_equal ( 0 , @summary [ :errors ] [ :removed ] , 'found removed errors' )
128- assert_equal ( 0 , @summary [ :errors ] [ :changed ] , 'found changed errors' )
138+ # The stack overflow exception might vary in the beginning/end of the stack frames shown
139+ # This stack overflow error is from checkstyle's InputIndentationLongConcatenatedString.java
140+ # instead of assert_equal(0, @summary[:errors][:changed], 'found changed errors')
141+ # allow 0 or 1 changed errors
142+ assert @summary [ :errors ] [ :changed ] <= 1
129143 assert_equal ( 0 , @summary [ :errors ] [ :new ] , 'found new errors' )
130144 assert_equal ( 0 , @summary [ :configerrors ] [ :changed ] , 'found changed configerrors' )
131145 assert_equal ( 0 , @summary [ :configerrors ] [ :new ] , 'found new configerrors' )
@@ -231,7 +245,7 @@ def checkout_pmd_branch(branch = 'master')
231245 system ( 'git config user.email "[email protected] "' ) 232246 system ( 'git config user.name "PMD CI (pmd-bot)"' )
233247 # remove any already existing binary to force a rebuild
234- FileUtils . rm Dir . glob ( 'pmd-dist/target/pmd-bin- *.zip' )
248+ FileUtils . rm Dir . glob ( 'pmd-dist/target/pmd-*.zip' )
235249 end
236250 end
237251
@@ -248,19 +262,19 @@ def prepare_patch_branch(patch_file, local_branch, base_branch = 'master')
248262 end
249263
250264 def assert_master_baseline
251- assert_path_exist ( 'target/reports/master/ checkstyle/config.xml' )
252- assert_path_exist ( 'target/reports/master/checkstyle/report_info.json' )
253- assert_path_exist ( 'target/reports/master/checkstyle/pmd_report.xml' )
254- assert ( File . size ( 'target/reports/master/checkstyle/pmd_report.xml' ) > 50 * 1024 * 1024 )
255-
256- assert_path_exist ( 'target/reports/master/openjdk-11/config.xml' )
257- assert_path_exist ( 'target/reports/master/openjdk-11/report_info.json' )
258- assert_path_exist ( 'target/reports/master/openjdk-11/pmd_report.xml' )
259- assert ( File . size ( 'target/reports/master/openjdk-11/pmd_report.xml' ) > 100 * 1024 * 1024 )
260-
261- assert_path_exist ( ' target/reports/master/spring-framework /config.xml' )
262- assert_path_exist ( ' target/reports/master/spring-framework /report_info.json' )
263- assert_path_exist ( ' target/reports/master/spring-framework /pmd_report.xml' )
264- assert ( File . size ( ' target/reports/master/spring-framework /pmd_report.xml' ) > 150 * 1024 * 1024 )
265+ assert_master_baseline_project ( ' checkstyle' , 40 * 1024 * 1024 )
266+ assert_master_baseline_project ( 'openjdk-11' , 80 * 1024 * 1024 )
267+ assert_master_baseline_project ( 'spring-framework' , 100 * 1024 * 1024 )
268+ assert_master_baseline_project ( 'java-regression-tests' , 100 * 1024 )
269+ assert_master_baseline_project ( 'apex-link' , 10 * 1024 )
270+ assert_master_baseline_project ( 'fflib-apex-common' , 400 * 1024 )
271+ assert_master_baseline_project ( 'Schedul-o-matic-9000' , 20 * 1024 )
272+ end
273+
274+ def assert_master_baseline_project ( project_name , report_size_in_bytes )
275+ assert_path_exist ( " target/reports/master/#{ project_name } /config.xml" )
276+ assert_path_exist ( " target/reports/master/#{ project_name } /report_info.json" )
277+ assert_path_exist ( " target/reports/master/#{ project_name } /pmd_report.xml" )
278+ assert ( File . size ( " target/reports/master/#{ project_name } /pmd_report.xml" ) > report_size_in_bytes )
265279 end
266280end
0 commit comments