дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 01:31:41 +02:00
feat(coverage): import coverage.py data files (.coverage) (#6450)
Import a Coverage Report now reads coverage.py's .coverage data file; choosing one .coverage.* file of a parallel run imports all of them. The data only records executed lines and arcs, so coverage.py in the project's interpreter combines it into a scratch file (combine --keep, the user's files untouched) and writes Cobertura XML (xml -i) for the existing importer, run in the project directory so [paths] and excluded lines apply. Running the interpreter needs a trusted project; without trust, an interpreter or coverage.py the error says so and points to coverage xml output. Files without source in the project are listed without lines and the notification says to map them with [paths]. Closes #6392 Co-authored-by: wildcatDownstairs <[email protected]>
Цей коміт міститься в:
1 джерело
a0afc478c1
коміт
660becbaa4
11 files changed
+244
-16
No files matched your search
@@ -114,6 +114,13 @@ it("says how many imported files are not in the project", async () => {
|
||||
expect(backend.notify).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ level: "warning", body: "2 files of the report are not in this project." }),
|
||||
);
|
||||
backend.coverageImport.mockResolvedValue(ok({ ...data, runner: "coverage.py", files: [file, foreign("/ci/a.py")] }));
|
||||
await importReport(report);
|
||||
expect(backend.notify).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
body: "1 file of the data has no source in this project. Map it with [paths] in the coverage.py configuration.",
|
||||
}),
|
||||
);
|
||||
backend.coverageImport.mockResolvedValue(ok(data));
|
||||
await importReport(report);
|
||||
expect(backend.notify).toHaveBeenLastCalledWith(expect.objectContaining({ level: "info", body: undefined }));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Coverage reports collected elsewhere: "Import a report collected in CI from
|
||||
* disk" (lcov, JaCoCo or Cobertura XML, Go cover profile, SimpleCov) and "Manage Coverage Reports"
|
||||
* disk" (lcov, JaCoCo or Cobertura XML, Go cover profile, SimpleCov, coverage.py data) and "Manage Coverage Reports"
|
||||
* (choose the shown suite, delete suites and remembered imports).
|
||||
*/
|
||||
import { useMemo, useState } from "react";
|
||||
@@ -43,6 +43,18 @@ async function pickReport(): Promise<string | null> {
|
||||
});
|
||||
}
|
||||
|
||||
/** Says how many files of an import are not in the project; coverage.py data maps them with `[paths]`. */
|
||||
function outsideText(outside: number, runner: string): string | undefined {
|
||||
if (!outside) return undefined;
|
||||
if (runner === "coverage.py")
|
||||
return outside === 1
|
||||
? "1 file of the data has no source in this project. Map it with [paths] in the coverage.py configuration."
|
||||
: tx`${outside} files of the data have no source in this project. Map them with [paths] in the coverage.py configuration.`;
|
||||
return outside === 1
|
||||
? "1 file of the report is not in this project."
|
||||
: tx`${outside} files of the report are not in this project.`;
|
||||
}
|
||||
|
||||
/** Imports `path` (asks for a file without one) and shows it like a run's suite. */
|
||||
export async function importReport(path?: string): Promise<Suite | null> {
|
||||
if (!isTauri()) {
|
||||
@@ -73,13 +85,7 @@ export async function importReport(path?: string): Promise<Suite | null> {
|
||||
level: outside ? "warning" : "info",
|
||||
key: "coverage-import",
|
||||
title: `Imported coverage '${suite.name}': ${formatPercent(covered!, total!)} lines`,
|
||||
body: !data.files.length
|
||||
? "The report covers no files of this project."
|
||||
: outside === 1
|
||||
? "1 file of the report is not in this project."
|
||||
: outside
|
||||
? tx`${outside} files of the report are not in this project.`
|
||||
: undefined,
|
||||
body: !data.files.length ? "The report covers no files of this project." : outsideText(outside, data.runner),
|
||||
});
|
||||
return suite;
|
||||
} catch (e) {
|
||||
|
||||
@@ -4296,5 +4296,7 @@
|
||||
"1 file of the report is not in this project.": "1 file of the report is not in this project.",
|
||||
"{count} files of the report are not in this project.": "{count} files of the report are not in this project.",
|
||||
"Waiting for process connection on {address}…": "Waiting for process connection on {address}…",
|
||||
"Add to the program: {line}": "Add to the program: {line}"
|
||||
"Add to the program: {line}": "Add to the program: {line}",
|
||||
"1 file of the data has no source in this project. Map it with [paths] in the coverage.py configuration.": "1 file of the data has no source in this project. Map it with [paths] in the coverage.py configuration.",
|
||||
"{count} files of the data have no source in this project. Map them with [paths] in the coverage.py configuration.": "{count} files of the data have no source in this project. Map them with [paths] in the coverage.py configuration."
|
||||
}
|
||||
@@ -10794,5 +10794,7 @@
|
||||
"Failed to deactivate {failed} of {total} data sources": "{total} 个数据源中有 {failed} 个停用失败",
|
||||
"Refresh {count} Data Sources": "刷新 {count} 个数据源",
|
||||
"Deactivate {count} Data Sources": "停用 {count} 个数据源",
|
||||
"Remove {count} Data Sources…": "移除 {count} 个数据源…"
|
||||
"Remove {count} Data Sources…": "移除 {count} 个数据源…",
|
||||
"1 file of the data has no source in this project. Map it with [paths] in the coverage.py configuration.": "数据中有 1 个文件在此项目中找不到源码。请在 coverage.py 配置的 [paths] 中映射它。",
|
||||
"{count} files of the data have no source in this project. Map them with [paths] in the coverage.py configuration.": "数据中有 {count} 个文件在此项目中找不到源码。请在 coverage.py 配置的 [paths] 中映射它们。"
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача