Skip to content

Commit

Permalink
This commit allow to load all file matching a given Pattern.
Browse files Browse the repository at this point in the history
In Dangerfile, simply have

junit.parsePattern "spec/reports/*.xml"

to load all xml file in the given directory

orta#30
  • Loading branch information
cyberguard committed Nov 30, 2021
1 parent 86881c2 commit 59b21cb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/junit/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ def parse(file)
parse_files(file)
end

# Load all XML file that match the given pattern
# This allow to load all file in a given directory, instead of identifying each file specifically.
# will `raise` for errors
# @return [void]
def parse_pattern(pattern)
files_in_pattern = Dir.glob(pattern)
parse_files(files_in_pattern)
end

# Parses multiple XML files, which fills all the attributes,
# will `raise` for errors
# @return [void]
Expand Down
10 changes: 10 additions & 0 deletions spec/junit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ module Danger
expect(@junit.skipped.count).to eq 7 + 0
end

it 'gets the right results for an pattern of files' do
files = 'spec/fixtures/*.xml'
@junit.parse_pattern files

expect(@junit.failures.count).to eq 6
expect(@junit.passes.count).to eq 1346
expect(@junit.errors.count).to eq 0 + 0
expect(@junit.skipped.count).to eq 1+ 7 + 0
end

it 'defaults to reporting common attributes for multiple files' do
@junit.parse_files 'spec/fixtures/rspec_fail.xml', 'spec/fixtures/eigen_fail.xml'

Expand Down

0 comments on commit 59b21cb

Please sign in to comment.