Skip to content

Commit d1af7b9

Browse files
committed
Allow junits_dir to match hidden files and dirs
Ruby's Dir.Glob will not match on Unix-like hidden files by default. Since build artifacts can be uploaded and downloaded from paths containing hidden directories, the junit plugin should match on hidden files and directories as well.
1 parent e46bcf2 commit d1af7b9

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

ruby/bin/annotate

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ failure_format = 'classname' if !failure_format || failure_format.empty?
2020
class Failure < Struct.new(:name, :failed_test, :body, :job, :type, :message)
2121
end
2222

23-
junit_report_files = Dir.glob(File.join(junits_dir, "**", "*"))
23+
junit_report_files = Dir.glob(File.join(junits_dir, "**", "*"), File::FNM_DOTMATCH)
2424
testcases = 0
2525
failures = []
2626

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuite name="rspec" tests="2" skipped="0" failures="0" errors="0" time="49.290713" timestamp="2018-04-18T23:29:42+00:00" hostname="626d214475e4">
3+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ" file="./spec/models/account_spec.rb" time="0.020013"/>
4+
<testcase classname="spec.models.account_spec" name="Account#maximum_jobs_added_by_pipeline_changer returns 900 if the account is F00" file="./spec/models/account_spec.rb" time="0.020013"/>
5+
</testsuite>

ruby/tests/annotate_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,4 +499,17 @@
499499

500500
assert_equal 0, status.exitstatus
501501
end
502+
503+
it "handles junit dir paths with hidden directories" do
504+
output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/.tests-in-hidden-dir/")
505+
506+
assert_equal <<~OUTPUT, output
507+
Parsing junit-1.xml
508+
--- ❓ Checking failures
509+
2 testcases found
510+
There were no failures/errors 🙌
511+
OUTPUT
512+
513+
assert_equal 0, status.exitstatus
514+
end
502515
end

0 commit comments

Comments
 (0)