@@ -425,22 +425,22 @@ def _RunForCoverage(python_program, main_filename, args, env,
425425 directory under the runfiles tree, and will recursively delete the
426426 runfiles directory if set.
427427 """
428+ instrumented_files = [abs_path for abs_path, _ in InstrumentedFilePaths()]
429+ unique_dirs = {os.path.dirname(file) for file in instrumented_files}
430+
431+ PrintVerboseCoverage("[coveragepy] Instrumented Files:\n" + "\n".join(instrumented_files))
432+ PrintVerboseCoverage("[coveragepy] Sources:\n" + "\n".join(unique_dirs))
433+
428434 # We need for coveragepy to use relative paths. This can only be configured
429435 unique_id = uuid.uuid4()
430436 rcfile_name = os.path.join(os.environ['COVERAGE_DIR'], ".coveragerc_{}".format(unique_id))
431437 with open(rcfile_name, "w") as rcfile:
432- rcfile.write('''[run]
438+ rcfile.write(f '''[run]
433439relative_files = True
440+ source =
441+ \t{"\n\t".join(unique_dirs)}
434442''')
435443 PrintVerboseCoverage('Coverage entrypoint:', coverage_entrypoint)
436-
437- instrumented_files = [abs_path for abs_path, _ in InstrumentedFilePaths()]
438- unique_dirs = {os.path.dirname(file) for file in instrumented_files}
439- source = ",".join(unique_dirs)
440-
441- PrintVerboseCoverage("[coveragepy] Instrumented Files:\n" + "\n".join(instrumented_files))
442- PrintVerboseCoverage("[coveragepy] Sources:\n" + "\n".join(unique_dirs))
443-
444444 # First run the target Python file via coveragepy to create a .coverage
445445 # database file, from which we can later export lcov.
446446 ret_code = subprocess.call(
@@ -451,7 +451,6 @@ relative_files = True
451451 "--rcfile=" + rcfile_name,
452452 "--append",
453453 "--branch",
454- "--source=" + source,
455454 main_filename
456455 ] + args,
457456 env=env,
0 commit comments