You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming SimpleCov.root is /, which could happen in some forms of container builds, then the generated filename attributes are cut off incorrectly.
Example:
Full path
Expected result
Actual result
/foo/bar.rb
foo/bar.rb
oo/bar.rb
This happens because the code that tries to strip away the project root assumes that it must be at least 1 character before the path separator, which is not true with a path like "/".
filename=file.filename# Here is the problem; the +1 assumes that SimpleCov.root.length is just before# the path separator, while for the case of "/" it is actually *on* the path# separator.path=filename[SimpleCov.root.length+1..-1]class_.attributes['name']=File.basename(filename,'.*')class_.attributes['filename']=path
The real reason I get this
I'm trying to set up code coverage reporting on GitLab, which does not support the <source> element and instead requires the filename to be the full path to the file from the repo root.
However, this repo contains several projects and so the actual project root is not at the repo root. This would not have been a problem, as I could just adjust the SimpleCov.root, but the tests run inside a container where the app is just one directory below the root (/myapp). So I have to set the root to / to get it to include the myapp/ part in the filename so Gitlab can resolve the file from <repo root>/myapp/foo/bar.rb.
You could say this is a perfect storm of edge cases, and I would agree.
The text was updated successfully, but these errors were encountered:
Assuming
SimpleCov.root
is/
, which could happen in some forms of container builds, then the generatedfilename
attributes are cut off incorrectly.Example:
/foo/bar.rb
foo/bar.rb
oo/bar.rb
This happens because the code that tries to strip away the project root assumes that it must be at least 1 character before the path separator, which is not true with a path like
"/"
.The real reason I get this
I'm trying to set up code coverage reporting on GitLab, which does not support the
<source>
element and instead requires thefilename
to be the full path to the file from the repo root.However, this repo contains several projects and so the actual project root is not at the repo root. This would not have been a problem, as I could just adjust the
SimpleCov.root
, but the tests run inside a container where the app is just one directory below the root (/myapp
). So I have to set theroot
to/
to get it to include themyapp/
part in thefilename
so Gitlab can resolve the file from<repo root>/myapp/foo/bar.rb
.You could say this is a perfect storm of edge cases, and I would agree.
The text was updated successfully, but these errors were encountered: