Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VSC-1515] fix unit tests not being refresh #1338

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions src/espIdf/unitTest/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
workspace,
} from "vscode";
import { EspIdfTestItem, idfTestData } from "./types";
import { readParameter } from "../../idfConfiguration";
import { runPyTestWithTestCase } from "./testExecution";
import { configurePyTestUnitApp } from "./configure";
import { getFileList, getTestComponents } from "./utils";
Expand All @@ -56,18 +55,6 @@ export class UnitTest {
) => {
const fileList = await getFileList();
this.testComponents = await getTestComponents(fileList);
const workspaceFolder = workspace.workspaceFolders
? workspace.workspaceFolders[0]
: undefined;

if (!workspaceFolder) {
return;
}
this.unitTestAppUri = await configurePyTestUnitApp(
workspaceFolder.uri,
this.testComponents,
cancelToken
);
await this.loadTests(fileList);
};

Expand Down Expand Up @@ -173,13 +160,10 @@ export class UnitTest {
context.subscriptions.push(this.unitTestController);
}

async getOrCreateFile(file: Uri) {
async createFileTestCaseItems(file: Uri) {
const existing = this.unitTestController.items.get(file.toString());
if (existing) {
return {
testItem: existing,
espIdfTestItem: idfTestData.get(existing) as EspIdfTestItem,
};
this.unitTestController.items.delete(existing.id);
}
const testItem = this.unitTestController.createTestItem(
file.toString(),
Expand Down Expand Up @@ -244,7 +228,7 @@ export class UnitTest {
} as EspIdfTestItem;

for (const file of files) {
const currentTestSuiteInfo = await this.getOrCreateFile(file);
const currentTestSuiteInfo = await this.createFileTestCaseItems(file);
localTestSuiteInfo.children.push(currentTestSuiteInfo.espIdfTestItem);
}

Expand Down