blob: 57859456e99e2d3ec174fe8ee3ae73897014107d [file] [log] [blame]
Tor Norbye3a2425a52013-11-04 10:16:08 -08001"""Coverage.py's main entrypoint."""
2
3import os
4import sys
5import imp
6
7helpers_root = os.getenv('PYCHARM_HELPERS_ROOT')
8if helpers_root:
9 sys_path_backup = sys.path
10 sys.path = [p for p in sys.path if p!=helpers_root]
11 from coverage.cmdline import main
12 sys.path = sys_path_backup
13else:
14 from coverage.cmdline import main
15
16coverage_file = os.getenv('PYCHARM_COVERAGE_FILE')
17run_cov = os.getenv('PYCHARM_RUN_COVERAGE')
18if os.getenv('JETBRAINS_REMOTE_RUN'):
19 line = 'LOG: PyCharm: File mapping:%s\t%s\n'
20 import tempfile
21 (h, new_cov_file) = tempfile.mkstemp(prefix='pycharm-coverage')
22 print(line%(coverage_file, new_cov_file))
23 print(line%(coverage_file + '.syspath.txt', new_cov_file + '.syspath.txt'))
24 print(line%(coverage_file + '.xml', new_cov_file + '.xml'))
25 coverage_file = new_cov_file
26
27if coverage_file:
28 os.environ['COVERAGE_FILE'] = coverage_file
29if run_cov:
30 a_file = open(coverage_file + '.syspath.txt', mode='w')
31 a_file.write(os.getcwd()+"\n")
32 for path in sys.path: a_file.write(path + "\n")
33 a_file.close()
34main()
35if run_cov:
36 main(["xml", "-o", coverage_file + ".xml", "--ignore-errors"])