question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTML report generation fails on too long path

See original GitHub issue

Originally reported by István Bede (Bitbucket: ibede, GitHub: ibede)


Hi!

I’m trying to generate HTML report on my coverage. Unfortunately I have very deep folder structure with some long directory and file names. The HTML generation tries to create an .html filename containing all this path, but on Windows 7 it fails if the file name is longer than 260 (NTFS). It reports an error like:

#!sh

---------- coverage: platform win32, python 2.7.13-final-0 -----------
Internal Error: runTests aborted: [Errno 2] No such file or directory: u'logs/coverage/_jenkins_work_XXXX_nightly_main_build_workspace_YYYYYYYYYYYYYYYYY-master_AAAAAAAAAAAAAAAAAAAAAAA_src_BBBBBBBBBBBBBBBBBBBB_CCCCCCCCCCCCCCCCCCCCCCC_py.html'

I made a small workaround/patch to make it work: Added directory_depth config value in coverage.cfg:

#!ini

[html]
directory = logs/coverage/
directory_depth = 4

and patched html generation the following way in html.py:

#!python
    def html_file(self, fr, analysis):
        """Generate an HTML file for one source file."""
        relname = fr.relative_filename()
        if self.config.dir_depth > 0: # initialized with -1
            import re
            relname = relname[[m.start() for m in re.finditer('\\\\', relname)][relname.count('\\') - self.config.dir_depth - 1] + 1:]
        rootname = flat_rootname(relname)
        html_filename = rootname + ".html"
        html_path = os.path.join(self.directory, html_filename)

and of course I added dir_depth to CoverageConfig.

As a result, only the needed directory depth is included in the filename. I don’t know if other OS or file system is problematic or not.

Note: maybe the annotate module is also affected as it uses the same mechanism for file name generation.

Thanks for the good work!


Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nedbatcommented, Oct 3, 2021

This is now released as part of coverage 6.0.

0reactions
nedbatcommented, Jul 18, 2021

This is now released as part of coverage 6.0b1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

path too long on windows when saving report with screenshots
I have following code to generate screenshots in reports ... When windows is trying to validate this long path, it fails into INTERNAL...
Read more >
HTML report generation takes a very long time | Clover
Clover HTML report generation is, by default, optimised to minimise memory usage. For some projects these optimisations may slow down report ...
Read more >
Summary HTML Report not generated when path is specified ...
Everything is working well, except for a minor discrepancy that seems to be occurring during report generation. The project folder structure ...
Read more >
Build fails (maybe because of too long path?) - MSDN - Microsoft
The very strange thing here is that the filename actually should contain the string "Reporting" whereas above in the error message the ...
Read more >
[Solved] Fileinfo error " too long path" - CodeProject
That is a limitation of the API functions what the .net framework is calling. This does note mean, that Windows or .net can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found