Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Look at why Space in py_modules path breaks ptr #30

Open
cooperlees opened this issue Feb 20, 2019 · 2 comments
Open

Look at why Space in py_modules path breaks ptr #30

cooperlees opened this issue Feb 20, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@cooperlees
Copy link
Contributor

Thanks for logging an issue with ptr. Here are some questions to help try
and pull out as much information possible to help us help you!

How is ptr not doing what you expect?

I would of expected pathlib to handle this

  • Also, work out why we're not running from venv code for py_modules (might handle this better)

What is your suggestion to make this better?

Unfortunately support spaces or see why pathlib does not.

Code/Bug example?

/tmp/workspace/PYTHON ptr_terragraph_ansbible/nmap_to_scuba/nts.py                    143     75    48%   36-41, 80-87, 107-130, 136-170, 178-196, 239-255, 259
/tmp/workspace/PYTHON ptr_terragraph_ansbible/nmap_to_scuba/nts_tests.py               29      0   100%
/tmp/workspace/PYTHON ptr_terragraph_ansbible/nmap_to_scuba/nts_tests_fixtures.py       4      0   100%
-----------------------------------------------------------------------------------------------------------------
TOTAL                                                                               10381   7339    29%
[2019-02-19 16:26:05,058] ERROR: Unable to find path relative path for /tmp/workspace/PYTHON (ptr.py:147)
[2019-02-19 16:26:05,059] ERROR: Unable to find path relative path for /tmp/workspace/PYTHON (ptr.py:147)
[2019-02-19 16:26:05,059] ERROR: Unable to find path relative path for /tmp/workspace/PYTHON (ptr.py:147)

Traceback (most recent call last):
  File "/tmp/ptr_terragraph_ansible/bin/ptr", line 11, in <module>
    sys.exit(main())
  File "/tmp/ptr_terragraph_ansible/lib/python3.6/site-packages/ptr.py", line 880, in main
    args.stats_file,
  File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "/tmp/ptr_terragraph_ansible/lib/python3.6/site-packages/ptr.py", line 813, in async_main
    stats_file,
  File "/tmp/ptr_terragraph_ansible/lib/python3.6/site-packages/ptr.py", line 761, in run_tests
    await asyncio.gather(*consumers)
  File "/tmp/ptr_terragraph_ansible/lib/python3.6/site-packages/ptr.py", line 547, in _test_runner
    print_cov,
  File "/tmp/ptr_terragraph_ansible/lib/python3.6/site-packages/ptr.py", line 500, in _test_steps_runner
    stats,
  File "/tmp/ptr_terragraph_ansible/lib/python3.6/site-packages/ptr.py", line 171, in _analyze_coverage
    if coverage_lines[afile].cover < cov_req:
KeyError: 'nts.py'

How can a developer reproduce this?

Add a unittest with a path to some code with a space in it.

@cooperlees cooperlees added the bug Something isn't working label Feb 20, 2019
@cooperlees
Copy link
Contributor Author

So this fails because I was lazy and parsed the human output of coverage as it made some thing easier for me. I use split on white space, and get all the coverage output as one str due to using maxsplits. Only way I can see how to sanely fix this is to parse the XML and reconstruct the output from the XML.

@amyreese
Copy link
Contributor

it might be easier to just parse stdout with a simple regex that expects some number of numeric fields, and capture everything before the first numeric field (minus trailing whitespace) as the filename.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants