Skip to content

Commit

Permalink
Return relative file path in JUnitReporter
Browse files Browse the repository at this point in the history
Before, if a file path was absolute, it would be returned as-is. Now, it returns the resolved relative file path if the original is absolute, or the original file path if it's already relative
Fixed #305
  • Loading branch information
itsliamegan committed Jan 18, 2021
1 parent e909246 commit 8c2dae5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### [1.4.3](https://github.com/kern/minitest-reporters/compare/v1.4.2...v1.4.3) (2021-01-15)

* fixed JUnitReporter to use a relative file path if a file path is absolute [#305](https://github.com/minitest-reporters/minitest-reporters/issues/305)
* fixed MeanTimeReporter to reset by deleting previous run file [#296](https://github.com/kern/minitest-reporters/pull/296) contributed by [AnythonyClark](https://github.com/AnthonyClark)
* removed debug output from ProgressReporter [#301](https://github.com/kern/minitest-reporters/pull/301) contributed by [wvanbergen](https://github.com/wvanbergen)

Expand Down
8 changes: 6 additions & 2 deletions lib/minitest/reporters/junit_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ def report
def get_relative_path(result)
file_path = Pathname.new(get_source_location(result).first)
base_path = Pathname.new(@base_path)
file_path.relative_path_from(base_path) if file_path.absolute?
file_path

if file_path.absolute?
file_path.relative_path_from(base_path)
else
file_path
end
end

private
Expand Down

0 comments on commit 8c2dae5

Please sign in to comment.