pmdtester 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +3 -2
- data/.github/workflows/manual-integration-tests.yml +3 -2
- data/History.md +23 -0
- data/README.rdoc +1 -0
- data/lib/pmdtester/builders/liquid_renderer.rb +6 -0
- data/lib/pmdtester/builders/pmd_report_builder.rb +32 -15
- data/lib/pmdtester/builders/project_builder.rb +18 -20
- data/lib/pmdtester/builders/project_hasher.rb +3 -0
- data/lib/pmdtester/builders/rule_set_builder.rb +1 -1
- data/lib/pmdtester/cmd.rb +39 -11
- data/lib/pmdtester/parsers/pmd_report_document.rb +3 -4
- data/lib/pmdtester/pmd_report_detail.rb +16 -2
- data/lib/pmdtester/pmd_tester_utils.rb +2 -1
- data/lib/pmdtester/project.rb +3 -0
- data/lib/pmdtester/report_diff.rb +7 -1
- data/lib/pmdtester/runner.rb +2 -2
- data/lib/pmdtester/semver.rb +6 -0
- data/lib/pmdtester.rb +1 -1
- data/pmdtester.gemspec +3 -3
- data/resources/project_diff_report.html +6 -0
- data/resources/project_pmd_report.html +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 733a4296c7168a518aa22c6fde568d2b3bf966ee99711e17a06dac851605f290
|
4
|
+
data.tar.gz: 5b900068f5483c479d6184600bcd78c20faf9b83bc9db2bbe12ec2c78d0328cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '039f00d21c56f0ae4c59ff5343e40a9ee9361c6514b2ab62e276c81877a3f4a59506639c2ad7c0be2eb0d3e2011698e2e6e16711ee97928519ba685a4dc1d139'
|
7
|
+
data.tar.gz: 54cce64c7f1e995178a90d0a09da3b1afdf42a62e825fdc74827ef5b9ff453b102fc1e04e8c3ecf2fd797d7981b1079de72f883d849ba87fed1175db03b54e79
|
data/.github/workflows/build.yml
CHANGED
@@ -15,6 +15,7 @@ on:
|
|
15
15
|
|
16
16
|
jobs:
|
17
17
|
build:
|
18
|
+
timeout-minutes: 120
|
18
19
|
runs-on: ubuntu-latest
|
19
20
|
continue-on-error: false
|
20
21
|
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }}
|
@@ -27,9 +28,9 @@ jobs:
|
|
27
28
|
~/.cache
|
28
29
|
vendor/bundle
|
29
30
|
target/repositories
|
30
|
-
key:
|
31
|
+
key: v3-${{ runner.os }}-${{ hashFiles('pmdtester.gemspec') }}
|
31
32
|
restore-keys: |
|
32
|
-
|
33
|
+
v3-${{ runner.os }}-
|
33
34
|
- name: Set up Ruby 2.7
|
34
35
|
uses: ruby/setup-ruby@v1
|
35
36
|
with:
|
@@ -8,6 +8,7 @@ on:
|
|
8
8
|
|
9
9
|
jobs:
|
10
10
|
build:
|
11
|
+
timeout-minutes: 120
|
11
12
|
runs-on: ubuntu-latest
|
12
13
|
continue-on-error: false
|
13
14
|
steps:
|
@@ -19,9 +20,9 @@ jobs:
|
|
19
20
|
~/.cache
|
20
21
|
vendor/bundle
|
21
22
|
target/repositories
|
22
|
-
key:
|
23
|
+
key: v3-${{ runner.os }}-${{ hashFiles('pmdtester.gemspec') }}
|
23
24
|
restore-keys: |
|
24
|
-
|
25
|
+
v3-${{ runner.os }}-
|
25
26
|
- name: Set up Ruby 2.7
|
26
27
|
uses: ruby/setup-ruby@v1
|
27
28
|
with:
|
data/History.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# 1.5.1 / 2022-05-12
|
2
|
+
|
3
|
+
## Fixed Issues
|
4
|
+
|
5
|
+
* [#106](https://github.com/pmd/pmd-regression-tester/issues/106): git clone/checkout fails when using commit sha1 as tag
|
6
|
+
|
7
|
+
# 1.5.0 / 2022-05-06
|
8
|
+
|
9
|
+
## Enhancements
|
10
|
+
|
11
|
+
* [#108](https://github.com/pmd/pmd-regression-tester/issues/108): Disable progress bar for PMD 7
|
12
|
+
* [#109](https://github.com/pmd/pmd-regression-tester/issues/109): Make stdout/stderr and exit code available
|
13
|
+
|
14
|
+
## Fixed Issues
|
15
|
+
|
16
|
+
* [#107](https://github.com/pmd/pmd-regression-tester/issues/107): Deprecated command line options is used: `-auxclasspath`
|
17
|
+
|
18
|
+
# 1.4.1 / 2022-04-12
|
19
|
+
|
20
|
+
## Fixed Issues
|
21
|
+
|
22
|
+
* [#104](https://github.com/pmd/pmd-regression-tester/issues/104): Baseline filtering is not working anymore
|
23
|
+
|
1
24
|
# 1.4.0 / 2022-03-24
|
2
25
|
|
3
26
|
## Enhancements
|
data/README.rdoc
CHANGED
@@ -155,3 +155,4 @@ The tool creates the following folders:
|
|
155
155
|
* Push the tag. Github Actions will build and publish the new gem
|
156
156
|
* A github release is automatically created, verify it on https://github.com/pmd/pmd-regression-tester/releases
|
157
157
|
* To make pmd's main CI use the new version (in [pmd/pmd](https://github.com/pmd/pmd/)), go to the root directory and run `bundle lock --update`. Commit these changes.
|
158
|
+
* Rename milestone to version, close it and create a new "Next" milestone: https://github.com/pmd/pmd-regression-tester/milestones
|
@@ -60,6 +60,11 @@ module PmdTester
|
|
60
60
|
# copy original pmd reports
|
61
61
|
copy_file("#{root}/base_pmd_report.xml", project.report_diff.base_report.file)
|
62
62
|
copy_file("#{root}/patch_pmd_report.xml", project.report_diff.patch_report.file)
|
63
|
+
# copy stdout and stderr outputs
|
64
|
+
copy_file("#{root}/base_stdout.txt", "#{project.report_diff.base_report.report_folder}/stdout.txt")
|
65
|
+
copy_file("#{root}/base_stderr.txt", "#{project.report_diff.base_report.report_folder}/stderr.txt")
|
66
|
+
copy_file("#{root}/patch_stdout.txt", "#{project.report_diff.patch_report.report_folder}/stdout.txt")
|
67
|
+
copy_file("#{root}/patch_stderr.txt", "#{project.report_diff.patch_report.report_folder}/stderr.txt")
|
63
68
|
# render full pmd reports
|
64
69
|
write_file("#{root}/base_pmd_report.html",
|
65
70
|
render_liquid('project_pmd_report.html', pmd_report_liquid_env(project, BASE)))
|
@@ -120,6 +125,7 @@ module PmdTester
|
|
120
125
|
|
121
126
|
'execution_time' => PmdReportDetail.convert_seconds(report.exec_time),
|
122
127
|
'timestamp' => report.timestamp,
|
128
|
+
'exit_code' => report.exit_code,
|
123
129
|
|
124
130
|
'rules' => report.rule_summaries,
|
125
131
|
'errors' => report.errors_by_file.all_values.map { |e| error_to_hash(e, project) },
|
@@ -25,7 +25,7 @@ module PmdTester
|
|
25
25
|
def get_pmd_binary_file
|
26
26
|
logger.info "#{@pmd_branch_name}: Start packaging PMD"
|
27
27
|
Dir.chdir(@local_git_repo) do
|
28
|
-
build_branch_sha = Cmd.
|
28
|
+
build_branch_sha = Cmd.execute_successfully("git rev-parse #{@pmd_branch_name}^{commit}")
|
29
29
|
|
30
30
|
checkout_build_branch # needs a clean working tree, otherwise fails
|
31
31
|
|
@@ -70,49 +70,53 @@ module PmdTester
|
|
70
70
|
' -Dcheckstyle.skip=true' \
|
71
71
|
' -Dpmd.skip=true' \
|
72
72
|
' -T1C -B'
|
73
|
-
Cmd.
|
73
|
+
Cmd.execute_successfully(package_cmd)
|
74
74
|
end
|
75
75
|
|
76
76
|
logger.info "#{@pmd_branch_name}: Extracting the zip"
|
77
|
-
Cmd.
|
78
|
-
Cmd.
|
77
|
+
Cmd.execute_successfully("unzip -qo #{pmd_dist_target} -d pmd-dist/target/exploded")
|
78
|
+
Cmd.execute_successfully("mv pmd-dist/target/exploded/pmd-bin-#{@pmd_version} #{into_dir}")
|
79
79
|
end
|
80
80
|
|
81
81
|
def determine_pmd_version
|
82
82
|
version_cmd = "./mvnw -q -Dexec.executable=\"echo\" -Dexec.args='${project.version}' " \
|
83
83
|
'--non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec'
|
84
|
-
Cmd.
|
84
|
+
Cmd.execute_successfully(version_cmd)
|
85
85
|
end
|
86
86
|
|
87
87
|
def get_last_commit_sha
|
88
88
|
get_last_commit_sha_cmd = 'git rev-parse HEAD^{commit}'
|
89
|
-
Cmd.
|
89
|
+
Cmd.execute_successfully(get_last_commit_sha_cmd)
|
90
90
|
end
|
91
91
|
|
92
92
|
def get_last_commit_message
|
93
93
|
get_last_commit_message_cmd = 'git log -1 --pretty=%B'
|
94
|
-
Cmd.
|
94
|
+
Cmd.execute_successfully(get_last_commit_message_cmd)
|
95
95
|
end
|
96
96
|
|
97
97
|
def generate_pmd_report(project)
|
98
98
|
error_recovery_options = @error_recovery ? 'PMD_JAVA_OPTS="-Dpmd.error_recovery -ea" ' : ''
|
99
99
|
run_path = "#{saved_distro_path(@pmd_branch_details.branch_last_sha)}/bin/run.sh"
|
100
100
|
fail_on_violation = should_use_long_cli_options ? '--fail-on-violation false' : '-failOnViolation false'
|
101
|
+
auxclasspath_option = create_auxclasspath_option(project)
|
101
102
|
pmd_cmd = "#{error_recovery_options}" \
|
102
103
|
"#{run_path} pmd -d #{project.local_source_path} -f xml " \
|
103
104
|
"-R #{project.get_config_path(@pmd_branch_name)} " \
|
104
105
|
"-r #{project.get_pmd_report_path(@pmd_branch_name)} " \
|
105
106
|
"#{fail_on_violation} -t #{@threads} " \
|
106
|
-
"#{
|
107
|
+
"#{auxclasspath_option}" \
|
108
|
+
"#{pmd7? ? ' --no-progress' : ''}"
|
107
109
|
start_time = Time.now
|
110
|
+
exit_code = nil
|
108
111
|
if File.exist?(project.get_pmd_report_path(@pmd_branch_name))
|
109
112
|
logger.warn "#{@pmd_branch_name}: Skipping PMD run - report " \
|
110
113
|
"#{project.get_pmd_report_path(@pmd_branch_name)} already exists"
|
111
114
|
else
|
112
|
-
Cmd.execute(pmd_cmd)
|
115
|
+
status = Cmd.execute(pmd_cmd, project.get_project_target_dir(@pmd_branch_name))
|
116
|
+
exit_code = status.exitstatus
|
113
117
|
end
|
114
118
|
end_time = Time.now
|
115
|
-
[end_time - start_time, end_time]
|
119
|
+
[end_time - start_time, end_time, exit_code]
|
116
120
|
end
|
117
121
|
|
118
122
|
def generate_config_for(project)
|
@@ -139,12 +143,12 @@ module PmdTester
|
|
139
143
|
progress_logger = SimpleProgressLogger.new("generating #{project.name}'s PMD report")
|
140
144
|
progress_logger.start
|
141
145
|
generate_config_for(project)
|
142
|
-
execution_time, end_time = generate_pmd_report(project)
|
146
|
+
execution_time, end_time, exit_code = generate_pmd_report(project)
|
143
147
|
progress_logger.stop
|
144
148
|
sum_time += execution_time
|
145
149
|
|
146
|
-
|
147
|
-
|
150
|
+
PmdReportDetail.create(execution_time: execution_time, timestamp: end_time,
|
151
|
+
exit_code: exit_code, report_info_path: project.get_report_info_path(@pmd_branch_name))
|
148
152
|
logger.info "#{project.name}'s PMD report was generated successfully"
|
149
153
|
end
|
150
154
|
|
@@ -167,7 +171,7 @@ module PmdTester
|
|
167
171
|
def checkout_build_branch
|
168
172
|
logger.info "#{@pmd_branch_name}: Checking out the branch"
|
169
173
|
# note that this would fail if the tree is dirty
|
170
|
-
Cmd.
|
174
|
+
Cmd.execute_successfully("git checkout #{@pmd_branch_name}")
|
171
175
|
|
172
176
|
# determine the version
|
173
177
|
@pmd_version = determine_pmd_version
|
@@ -193,12 +197,25 @@ module PmdTester
|
|
193
197
|
end
|
194
198
|
|
195
199
|
def wd_has_dirty_git_changes
|
196
|
-
!Cmd.
|
200
|
+
!Cmd.execute_successfully('git status --porcelain').empty?
|
197
201
|
end
|
198
202
|
|
199
203
|
def should_use_long_cli_options
|
200
204
|
logger.debug "PMD Version: #{@pmd_version}"
|
201
205
|
Semver.compare(@pmd_version, '6.41.0') >= 0
|
202
206
|
end
|
207
|
+
|
208
|
+
def create_auxclasspath_option(project)
|
209
|
+
auxclasspath_option = ''
|
210
|
+
unless project.auxclasspath.empty?
|
211
|
+
auxclasspath_option = should_use_long_cli_options ? '--aux-classpath ' : '-auxclasspath '
|
212
|
+
auxclasspath_option += project.auxclasspath
|
213
|
+
end
|
214
|
+
auxclasspath_option
|
215
|
+
end
|
216
|
+
|
217
|
+
def pmd7?
|
218
|
+
Semver.compare(@pmd_version, '7.0.0-SNAPSHOT') >= 0
|
219
|
+
end
|
203
220
|
end
|
204
221
|
end
|
@@ -19,22 +19,28 @@ module PmdTester
|
|
19
19
|
logger.info "Start cloning #{project.name} repository"
|
20
20
|
path = project.clone_root_path
|
21
21
|
|
22
|
+
raise "Unsupported project type '#{project.type}' - only git is supported" unless project.type == 'git'
|
23
|
+
|
22
24
|
if File.exist?(path)
|
23
25
|
logger.warn "Skipping clone, project path #{path} already exists"
|
24
26
|
else
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# Don't download whole history
|
29
|
-
# Note we don't use --single-branch, because the repo is downloaded
|
30
|
-
# once but may be used with several tags.
|
31
|
-
clone_cmd = "git clone --no-single-branch --depth 1 #{project.connection} #{path}"
|
32
|
-
|
33
|
-
Cmd.execute(clone_cmd)
|
27
|
+
# Don't download whole history. This just fetches HEAD, the correct ref is fetched below.
|
28
|
+
clone_cmd = "git clone --single-branch --depth 1 #{project.connection} #{path}"
|
29
|
+
Cmd.execute_successfully(clone_cmd)
|
34
30
|
end
|
35
31
|
|
36
32
|
Dir.chdir(path) do
|
37
|
-
|
33
|
+
# this works with tags, branch names and (full-length) hashes
|
34
|
+
# first move to a different (temporary) branch, in case we are already on the branch that we want to update
|
35
|
+
Cmd.execute_successfully('git checkout -b fetched/temp')
|
36
|
+
# fetches any new commits. Could also be a tag.
|
37
|
+
Cmd.execute_successfully("git fetch --depth 1 origin #{project.tag}")
|
38
|
+
# update the branch to work on based on the new fetch. Creates a new branch if it doesn't exist already
|
39
|
+
Cmd.execute_successfully("git branch --force fetched/#{project.tag} FETCH_HEAD")
|
40
|
+
# checkout the updated branch
|
41
|
+
Cmd.execute_successfully("git checkout fetched/#{project.tag}")
|
42
|
+
# remove the temporary branch
|
43
|
+
Cmd.execute_successfully('git branch -D fetched/temp')
|
38
44
|
end
|
39
45
|
logger.info "Cloning #{project.name} completed"
|
40
46
|
end
|
@@ -71,7 +77,7 @@ module PmdTester
|
|
71
77
|
if project.auxclasspath_command
|
72
78
|
logger.debug "Executing auxclasspath-command: #{project.auxclasspath_command}"
|
73
79
|
auxclasspath = run_as_script(Dir.getwd, project.auxclasspath_command)
|
74
|
-
project.auxclasspath =
|
80
|
+
project.auxclasspath = auxclasspath
|
75
81
|
else
|
76
82
|
project.auxclasspath = ''
|
77
83
|
end
|
@@ -87,19 +93,11 @@ module PmdTester
|
|
87
93
|
if command.start_with?('#!')
|
88
94
|
shell = command.lines[0].chomp[2..] # remove leading "#!"
|
89
95
|
end
|
90
|
-
stdout = Cmd.
|
96
|
+
stdout = Cmd.execute_successfully("#{shell} #{script.path}")
|
91
97
|
ensure
|
92
98
|
script.unlink
|
93
99
|
end
|
94
100
|
stdout
|
95
101
|
end
|
96
|
-
|
97
|
-
def execute_reset_cmd(type, tag)
|
98
|
-
raise "Unsupported project type '#{type}' - only git is supported" unless type == 'git'
|
99
|
-
|
100
|
-
reset_cmd = "git checkout #{tag}; git reset --hard #{tag}"
|
101
|
-
|
102
|
-
Cmd.execute(reset_cmd)
|
103
|
-
end
|
104
102
|
end
|
105
103
|
end
|
@@ -21,6 +21,9 @@ module PmdTester
|
|
21
21
|
'base_timestamp' => rdiff.base_report.timestamp,
|
22
22
|
'patch_timestamp' => rdiff.patch_report.timestamp,
|
23
23
|
|
24
|
+
'base_exit_code' => rdiff.base_report.exit_code,
|
25
|
+
'patch_exit_code' => rdiff.patch_report.exit_code,
|
26
|
+
|
24
27
|
'rule_diffs' => rdiff.rule_summaries
|
25
28
|
}
|
26
29
|
end
|
@@ -176,7 +176,7 @@ module PmdTester
|
|
176
176
|
|
177
177
|
# We only need to support git here, since PMD's repo is using git.
|
178
178
|
diff_cmd = "git diff --name-only #{base}..#{patch} #{filepath_filter}"
|
179
|
-
filenames = Cmd.
|
179
|
+
filenames = Cmd.execute_successfully(diff_cmd)
|
180
180
|
end
|
181
181
|
filenames.split("\n")
|
182
182
|
end
|
data/lib/pmdtester/cmd.rb
CHANGED
@@ -6,9 +6,35 @@ module PmdTester
|
|
6
6
|
# Containing the common method for executing shell command
|
7
7
|
class Cmd
|
8
8
|
extend PmdTester
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
#
|
11
|
+
# Executes the given command and returns the process status.
|
12
|
+
# stdout and stderr are written to the files "stdout.txt" and "stderr.txt"
|
13
|
+
# in path.
|
14
|
+
#
|
15
|
+
def self.execute(cmd, path)
|
16
|
+
stdout, stderr, status = internal_execute(cmd)
|
17
|
+
|
18
|
+
file = File.new("#{path}/stdout.txt", 'w')
|
19
|
+
file.puts stdout
|
20
|
+
file.close
|
21
|
+
|
22
|
+
file = File.new("#{path}/stderr.txt", 'w')
|
23
|
+
file.puts stderr
|
24
|
+
file.close
|
25
|
+
|
26
|
+
status
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.execute_successfully(cmd)
|
30
|
+
stdout, stderr, status = internal_execute(cmd)
|
31
|
+
|
32
|
+
unless status.success?
|
33
|
+
logger.error stdout
|
34
|
+
logger.error stderr
|
35
|
+
raise CmdException.new(cmd, stdout, stderr, status)
|
36
|
+
end
|
37
|
+
|
12
38
|
stdout
|
13
39
|
end
|
14
40
|
|
@@ -22,14 +48,12 @@ module PmdTester
|
|
22
48
|
|
23
49
|
stdout, stderr, status = Open3.capture3("#{cmd};")
|
24
50
|
|
25
|
-
logger.debug
|
26
|
-
|
27
|
-
|
28
|
-
logger.error stderr
|
29
|
-
raise CmdException.new(cmd, stderr)
|
30
|
-
end
|
51
|
+
logger.debug "status: #{status}"
|
52
|
+
logger.debug "stdout: #{stdout}"
|
53
|
+
logger.debug "stderr: #{stderr}"
|
31
54
|
|
32
55
|
stdout&.chomp!
|
56
|
+
stderr&.chomp!
|
33
57
|
|
34
58
|
[stdout, stderr, status]
|
35
59
|
end
|
@@ -40,15 +64,19 @@ module PmdTester
|
|
40
64
|
# The exception should be raised when the shell command failed.
|
41
65
|
class CmdException < StandardError
|
42
66
|
attr_reader :cmd
|
67
|
+
attr_reader :stdout
|
43
68
|
attr_reader :error
|
69
|
+
attr_reader :status
|
44
70
|
attr_reader :message
|
45
71
|
|
46
72
|
COMMON_MSG = 'An error occurred while executing the shell command'
|
47
73
|
|
48
|
-
def initialize(cmd, error)
|
74
|
+
def initialize(cmd, stdout, error, status)
|
49
75
|
@cmd = cmd
|
76
|
+
@stdout = stdout
|
50
77
|
@error = error
|
51
|
-
@
|
78
|
+
@status = status
|
79
|
+
@message = "#{COMMON_MSG} '#{cmd}' #{status}"
|
52
80
|
end
|
53
81
|
end
|
54
82
|
end
|
@@ -89,11 +89,10 @@ module PmdTester
|
|
89
89
|
def match_filter_set?(violation)
|
90
90
|
return true if @filter_set.nil?
|
91
91
|
|
92
|
-
|
93
|
-
return true if @filter_set.include?(
|
94
|
-
|
95
|
-
rule_ref = "#{violation.language}/#{ruleset_attr}/#{violation.rule_name}"
|
92
|
+
ruleset_filter = violation.language << '/' << violation.ruleset_name.delete(' ').downcase! << '.xml'
|
93
|
+
return true if @filter_set.include?(ruleset_filter)
|
96
94
|
|
95
|
+
rule_ref = "#{ruleset_filter}/#{violation.rule_name}"
|
97
96
|
@filter_set.include?(rule_ref)
|
98
97
|
end
|
99
98
|
|
@@ -8,15 +8,22 @@ module PmdTester
|
|
8
8
|
attr_accessor :execution_time
|
9
9
|
attr_accessor :timestamp
|
10
10
|
attr_accessor :working_dir
|
11
|
+
attr_accessor :exit_code
|
11
12
|
|
12
|
-
def initialize(execution_time: 0, timestamp: '', working_dir: Dir.getwd)
|
13
|
+
def initialize(execution_time: 0, timestamp: '', working_dir: Dir.getwd, exit_code: nil)
|
13
14
|
@execution_time = execution_time
|
14
15
|
@timestamp = timestamp
|
15
16
|
@working_dir = working_dir
|
17
|
+
@exit_code = exit_code.nil? ? '?' : exit_code.to_s
|
16
18
|
end
|
17
19
|
|
18
20
|
def save(report_info_path)
|
19
|
-
hash = {
|
21
|
+
hash = {
|
22
|
+
execution_time: @execution_time,
|
23
|
+
timestamp: @timestamp,
|
24
|
+
working_dir: @working_dir,
|
25
|
+
exit_code: @exit_code
|
26
|
+
}
|
20
27
|
file = File.new(report_info_path, 'w')
|
21
28
|
file.puts JSON.generate(hash)
|
22
29
|
file.close
|
@@ -36,6 +43,13 @@ module PmdTester
|
|
36
43
|
self.class.convert_seconds(@execution_time)
|
37
44
|
end
|
38
45
|
|
46
|
+
def self.create(execution_time: 0, timestamp: '', working_dir: Dir.getwd, exit_code: nil, report_info_path:)
|
47
|
+
detail = PmdReportDetail.new(execution_time: execution_time, timestamp: timestamp,
|
48
|
+
working_dir: working_dir, exit_code: exit_code)
|
49
|
+
detail.save(report_info_path)
|
50
|
+
detail
|
51
|
+
end
|
52
|
+
|
39
53
|
# convert seconds into HH::MM::SS
|
40
54
|
def self.convert_seconds(seconds)
|
41
55
|
Time.at(seconds.abs).utc.strftime('%H:%M:%S')
|
data/lib/pmdtester/project.rb
CHANGED
@@ -123,6 +123,9 @@ module PmdTester
|
|
123
123
|
get_report_info_path(base_branch),
|
124
124
|
get_report_info_path(patch_branch),
|
125
125
|
filter_set)
|
126
|
+
|
127
|
+
report_diff.base_report.report_folder = get_project_target_dir(base_branch)
|
128
|
+
report_diff.patch_report.report_folder = get_project_target_dir(patch_branch)
|
126
129
|
end
|
127
130
|
end
|
128
131
|
end
|
@@ -57,17 +57,22 @@ module PmdTester
|
|
57
57
|
:configerrors_by_rule,
|
58
58
|
:exec_time,
|
59
59
|
:timestamp,
|
60
|
+
:exit_code,
|
60
61
|
:file
|
61
62
|
|
63
|
+
attr_accessor :report_folder
|
64
|
+
|
62
65
|
def initialize(report_document: nil,
|
63
66
|
file: '',
|
64
67
|
exec_time: 0,
|
65
|
-
timestamp: '0'
|
68
|
+
timestamp: '0',
|
69
|
+
exit_code: '?')
|
66
70
|
initialize_empty
|
67
71
|
initialize_with_report_document report_document unless report_document.nil?
|
68
72
|
@exec_time = exec_time
|
69
73
|
@timestamp = timestamp
|
70
74
|
@file = file
|
75
|
+
@exit_code = exit_code
|
71
76
|
end
|
72
77
|
|
73
78
|
def self.empty
|
@@ -108,6 +113,7 @@ module PmdTester
|
|
108
113
|
@violations_by_file = CollectionByFile.new
|
109
114
|
@errors_by_file = CollectionByFile.new
|
110
115
|
@configerrors_by_rule = {}
|
116
|
+
@report_folder = ''
|
111
117
|
end
|
112
118
|
end
|
113
119
|
|
data/lib/pmdtester/runner.rb
CHANGED
@@ -97,8 +97,8 @@ module PmdTester
|
|
97
97
|
unzip_cmd = "unzip -qo #{zip_filename}"
|
98
98
|
|
99
99
|
Dir.chdir(target_path) do
|
100
|
-
Cmd.
|
101
|
-
Cmd.
|
100
|
+
Cmd.execute_successfully(wget_cmd) unless File.exist?(zip_filename)
|
101
|
+
Cmd.execute_successfully(unzip_cmd)
|
102
102
|
end
|
103
103
|
|
104
104
|
"#{target_path}/#{branch_filename}"
|
data/lib/pmdtester/semver.rb
CHANGED
@@ -4,6 +4,12 @@ module PmdTester
|
|
4
4
|
# Utility to deal with semantic versions
|
5
5
|
class Semver
|
6
6
|
def self.compare(version_a, version_b)
|
7
|
+
result = internal_compare(version_a, version_b)
|
8
|
+
PmdTester.logger.debug " result: #{result}"
|
9
|
+
result
|
10
|
+
end
|
11
|
+
|
12
|
+
private_class_method def self.internal_compare(version_a, version_b)
|
7
13
|
PmdTester.logger.debug "Comparing #{version_a} <=> #{version_b}"
|
8
14
|
m = /(\d+)\.(\d+)\.(\d+)(.*)/.match(version_a)
|
9
15
|
a_major = m[1].to_i
|
data/lib/pmdtester.rb
CHANGED
@@ -33,7 +33,7 @@ require_relative 'pmdtester/parsers/projects_parser'
|
|
33
33
|
# and unexpected behaviors will not be introduced to PMD project
|
34
34
|
# after fixing an issue and new rules can work as expected.
|
35
35
|
module PmdTester
|
36
|
-
VERSION = '1.
|
36
|
+
VERSION = '1.5.1'
|
37
37
|
BASE = 'base'
|
38
38
|
PATCH = 'patch'
|
39
39
|
PR_NUM_ENV_VAR = 'PMD_CI_PULL_REQUEST_NUMBER' # see PmdBranchDetail
|
data/pmdtester.gemspec
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake hoe:spec`.
|
2
2
|
|
3
3
|
# -*- encoding: utf-8 -*-
|
4
|
-
# stub: pmdtester 1.
|
4
|
+
# stub: pmdtester 1.5.1 ruby lib
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "pmdtester".freeze
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.5.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
11
11
|
s.metadata = { "bug_tracker_uri" => "https://github.com/pmd/pmd-regression-tester/issues", "homepage_uri" => "https://pmd.github.io", "source_code_uri" => "https://github.com/pmd/pmd-regression-tester" } if s.respond_to? :metadata=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Andreas Dangel".freeze, "Binguo Bao".freeze, "Cl\u00E9ment Fournier".freeze]
|
14
|
-
s.date = "2022-
|
14
|
+
s.date = "2022-05-12"
|
15
15
|
s.description = "A regression testing tool ensure that new problems and unexpected behaviors will not be introduced to PMD project after fixing an issue , and new rules can work as expected.".freeze
|
16
16
|
s.email = ["andreas.dangel@pmd-code.org".freeze, "djydewang@gmail.com".freeze, "clement.fournier76@gmail.com".freeze]
|
17
17
|
s.executables = ["pmdtester".freeze]
|
@@ -71,6 +71,12 @@
|
|
71
71
|
<td class="patch">{{diff.patch_timestamp}}</td>
|
72
72
|
<td class="diff"></td>
|
73
73
|
</tr>
|
74
|
+
<tr>
|
75
|
+
<td class="item">Exit Code</td>
|
76
|
+
<td class="base">{{diff.base_exit_code}} <a href="base_stdout.txt">stdout</a> | <a href="base_stderr.txt">stderr</a></td>
|
77
|
+
<td class="patch">{{diff.patch_exit_code}} <a href="patch_stdout.txt">stdout</a> | <a href="patch_stderr.txt">stderr</a></td>
|
78
|
+
<td class="diff"></td>
|
79
|
+
</tr>
|
74
80
|
<tr>
|
75
81
|
<td class="item">Full Report</td>
|
76
82
|
<td class="base"><a href="base_pmd_report.html">Base PMD Report</a></td>
|
@@ -53,6 +53,10 @@
|
|
53
53
|
<td class="item">Timestamp</td>
|
54
54
|
<td class="{{branch}}">{{report.timestamp}}</td>
|
55
55
|
</tr>
|
56
|
+
<tr>
|
57
|
+
<td class="item">Exit Code</td>
|
58
|
+
<td class="{{branch}}">{{report.exit_code}} <a href="{{branch}}_stdout.txt">stdout</a> | <a href="{{branch}}_stderr.txt">stderr</a></td>
|
59
|
+
</tr>
|
56
60
|
<tr>
|
57
61
|
<td class="item">Full Report</td>
|
58
62
|
<td class="{{branch}}"><a href="{{branch}}_pmd_report.xml">{{branch}}_pmd_report.xml</a></td>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pmdtester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Dangel
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|