Commit 4a52bd98 authored by Julien Muchembled's avatar Julien Muchembled

qa: rewrite tools/coverage-html in Python to make -d option usable

parent 7a75daa9
#!/bin/sh -e #!/usr/bin/env python
for COV in coverage python-coverage import os, re, sys, shutil
do type $COV && break from coverage.cmdline import main, CmdOptionParser
done >/dev/null 2>&1 || exit
sys.argv.insert(1, 'html')
del CmdOptionParser.get_prog_name
$COV html "$@"
# https://bitbucket.org/ned/coveragepy/issues/474/javascript-in-html-captures-all-keys # https://bitbucket.org/ned/coveragepy/issues/474/javascript-in-html-captures-all-keys
sed -i " shutil_copyfile = shutil.copyfile
/assign_shortkeys *=/s/$/return;/ def copyfile(src, dst):
/^ *\.bind('keydown',/s,^,//, if os.path.basename(dst) == 'coverage_html.js':
" htmlcov/coverage_html.js with open(src) as f:
js = f.read()
js = re.sub(r"(assign_shortkeys.*\{)", r"\1return;", js)
js = re.sub(r"^( *\.bind\('keydown',)", r"//\1", js, flags=re.M)
with open(dst, 'w') as f:
f.write(js)
else:
shutil_copyfile(src, dst)
shutil.copyfile = copyfile
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment