1 """Coverage.py's main entrypoint."""
6 bundled_coverage_path = os.getenv('BUNDLED_COVERAGE_PATH')
7 if bundled_coverage_path:
8 sys_path_backup = sys.path
9 sys.path = [p for p in sys.path if p != bundled_coverage_path]
10 from coverage.cmdline import main
11 sys.path = sys_path_backup
13 from coverage.cmdline import main
15 coverage_file = os.getenv('PYCHARM_COVERAGE_FILE')
17 coverage_file = coverage_file[0:-len(".coverage")]
19 run_cov = os.getenv('PYCHARM_RUN_COVERAGE')
20 if os.getenv('CREATE_TEMP_COVERAGE_FILE'):
21 line = 'LOG: PyCharm: File mapping:%s\t%s\n'
23 (h, new_cov_file) = tempfile.mkstemp(prefix='pycharm-coverage')
24 print(line%(coverage_file + ".coverage", new_cov_file + ".coverage"))
25 print(line%(coverage_file + '.syspath.txt', new_cov_file + '.syspath.txt'))
26 print(line%(coverage_file + '.xml', new_cov_file + '.xml'))
27 coverage_file = new_cov_file
30 os.environ['COVERAGE_FILE'] = coverage_file + ".coverage"
33 a_file = open(coverage_file + '.syspath.txt', mode='w')
34 a_file.write(os.getcwd()+"\n")
35 for path in sys.path: a_file.write(path + "\n")
40 if arg.startswith('-m'):
54 main(["xml", "-o", coverage_file + ".xml", "--ignore-errors"])