Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid test coverage reports with error: Invalid path part "/" #476

Open
zachglee opened this issue Sep 28, 2021 · 8 comments
Open

Invalid test coverage reports with error: Invalid path part "/" #476

zachglee opened this issue Sep 28, 2021 · 8 comments
Assignees

Comments

@zachglee
Copy link

I have set up the test reporter to run as part of my CircleCI flow. I push a commit to github, and the CircleCI flow runs. The two relevant run blocks are as follows:

- run:
name: Setup Code Climate test-reporter
command: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
- run:
name: run tests
command: |
source ~/.pyenv/versions/venv/bin/activate
./cc-test-reporter before-build
coverage run -m pytest saga
coverage xml
./cc-test-reporter after-build --debug --coverage-input-type coverage.py --exit-code $?

This does successfully upload a report to CodeClimate, but when I view these reports, their state is shown as invalid. (See this page: https://codeclimate.com/repos/60f063e943e546014c02417e/settings/test_reporter) (Permission granted to log in to my account, if necessary: Yes.)

Inspecting the details of a report shows the following:

{
  "message": "Invalid path part \"/\" and Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('615330002ed2b51a2a005658'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"cbb4c74a6c553c86cc6b6ba230996c063e0aa87c\", \"coverage\"=>\"[null,null,null,null,null,null,null,null,null,null,null,null,1,null,1,1,1,1,null,null,1,null,null,1,null,null,null,null,null,null,null,null,0,0,0,0,0,0,0,null,null,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,0,0,null,0,null,0,0,0,null,0,0,0,0,null,0,0,0,0,null,null,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,0,0,null,0,0,0,null,null,1,null,null,null,null,null,null,null,null,0,null,0,0,0,0,0,null,null,1,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,0,null,null,null,null,0,0,0,0,0,null,null,null,0,0,0,0,0,0,null,0,null,0,null,null,0,0,0,null,0,null,null,null,null,null,null,null,0,0,null,null,null,null,null,null,null,0,0,0,null,null,0,0,0,null,null,null,null,null,null,null,0,0,0,0,0,0,0,0,null,null,0,0,0,0,0,null,null,null,null,null,null,0,null,null,0,0,0,0,0,null,null,null,null,null,null,null,null,0,null,0,0,0,0,null,null,null,null,null,null,null,0]\", \"covered_percent\"=>11.34020618556701, \"covered_strength\"=>0.1134020618556701, \"line_counts\"=>{\"missed\"=>86, \"covered\"=>11, \"total\"=>97}, \"path\"=>\"//home/circleci/.pyenv/versions/3.9.7/envs/venv/lib/python3.9/site-packages/botocore/docs/method.py\", \"test_report_id\"=>BSON::ObjectId('61532fff5646331e260090cf')}"
}

The error seems to be that part of some path is just "/", which is not a valid path part. I do see that the path field of that json begins with two "/"'s: "//home/circleci/.pyenv/versions/3.9.7.... This seems like the possible source of the problem, but I'm not sure where this path is coming from. The value of this path field seems to vary from test report to test report -- being a seemingly random file from within my python3.9/site-packages. This makes me wonder if the test reporter is somehow trying to report on coverage of every file in my site-packages?

Any guidance / thoughts would be greatly appreciated! Thanks! And let me know if there is any more information you would like.

@nicon89
Copy link

nicon89 commented May 6, 2022

I have same issue.

{
  "message": "Invalid path part \"/\" and Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('62753df22c69c4523e0063d6'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"77dcf9ab13b9095dcee364c2145ce701fbad29a8\", \"coverage\"=>\"[null,null,null,null,1,null,1,null,1,1,null,null,1,1,1,null,null,null,null,1,null,null,1,1,1,0,0,null,null,null,null,0,0,0,null,0,0,null,0,0,null,0,0,null,0,0,0,0,0,0,null,1,0,0,0,null,0,0,0,null,null,null,1,0,0,0]\", \"covered_percent\"=>33.33333333333333, \"covered_strength\"=>0.3333333333333333, \"line_counts\"=>{\"missed\"=>26, \"covered\"=>13, \"total\"=>39}, \"path\"=>\"//usr/lib/python3/dist-packages/cryptography/hazmat/primitives/kdf/scrypt.py\", \"test_report_id\"=>BSON::ObjectId('62753def76839f688500676a')}"
}

Did you found a solution for this issue?

@amsmith-pro
Copy link

amsmith-pro commented Jul 10, 2022

Same issue with same message, except I'm uploading codeclimate.json with formatted gcov results

{
  "message": "Invalid path part \"/\"",
  "file_document": "{\"_id\"=>BSON::ObjectId('62ca906fd3d0be61fd002038'), \"type\"=>\"test_file_reports\", \"blob_id\"=>\"c296a70d2d176318f450e08d81ee97f30178cc50\", \"coverage\"=>\"[null,null,2]\", \"covered_percent\"=>100, \"covered_strength\"=>2, \"line_counts\"=>{\"missed\"=>0, \"covered\"=>1, \"total\"=>1}, \"path\"=>\"/home/runner/work/lib-template-cpp/lib-template-cpp/src/lib.cpp\", \"test_report_id\"=>BSON::ObjectId('62ca906f3189824c2d006389')}"
}

@nicon89
Copy link

nicon89 commented Jul 11, 2022

AFAIR: You need to exclude paths from outside of your code from the coverage report.

@Morkrom
Copy link

Morkrom commented Dec 14, 2022

Am having this as well when uploading xccov generated json results. Would really like to use this tool.

update
I was able to get this to work manually once. Subsequently from my fastlane file, no.

@scotdalton
Copy link

This seems to be a duplicate of #375. The solution there was to specify the --prefix option.

@gitizenme
Copy link

The --prefix option does not solve this problem.

@CodeBooster97
Copy link

doesn't work me either

@CodeBooster97
Copy link

You need to run the tests from the rootdir of the project.
The --prefix option doesn't fix this, indeed.
When you run the test from an other dir than the project folder it will fail.
Please fix @codeclimate-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants