Skip to content

Commit

Permalink
fix: use build target id instead of target name
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Aug 6, 2024
1 parent 2e0957e commit a8ccbaa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ suite("Test Explorer events", () => {
label: folderName,
children: [
{
id: targetName,
id: targetUri,
label: targetName,
children: [
{ id: "NoPackage", label: "NoPackage", uri, children: [] },
Expand Down Expand Up @@ -117,7 +117,7 @@ suite("Test Explorer events", () => {
label: folderName,
children: [
{
id: targetName,
id: targetUri,
label: targetName,
children: [
{ id: "NoPackage", label: "NoPackage", uri, children: [] },
Expand Down Expand Up @@ -164,7 +164,7 @@ suite("Test Explorer events", () => {
folderUri,
foo
);
removeTestItem(testController, targetName, folderUri, {
removeTestItem(testController, targetUri, folderUri, {
...foo,
kind: "removeSuite",
});
Expand All @@ -174,7 +174,7 @@ suite("Test Explorer events", () => {
label: folderName,
children: [
{
id: targetName,
id: targetUri,
label: targetName,
children: [
{ id: "NoPackage", label: "NoPackage", uri, children: [] },
Expand Down Expand Up @@ -215,7 +215,7 @@ suite("Test Explorer events", () => {
label: folderName,
children: [
{
id: targetName,
id: targetUri,
label: targetName,
children: [
{ id: "NoPackage", label: "NoPackage", uri, children: [] },
Expand Down
2 changes: 1 addition & 1 deletion packages/metals-vscode/src/testExplorer/addTestCases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function addTestCases(
}
const workspaceFolderItem = testController.items.get(folderUri);
if (workspaceFolderItem) {
const buildTargetItem = workspaceFolderItem.children.get(targetName);
const buildTargetItem = workspaceFolderItem.children.get(targetUri);
if (buildTargetItem) {
const testPath = prefixesOf(event.fullyQualifiedClassName, true);
addTestCasesLoop(buildTargetItem, testPath);
Expand Down
6 changes: 4 additions & 2 deletions packages/metals-vscode/src/testExplorer/addTestSuites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export function addTestSuite(
const buildTargetItem = getOrCreateBuildTargetItem(
testController,
workspaceFolderItem,
targetUri,
targetName
);

Expand Down Expand Up @@ -82,14 +83,15 @@ export function addTestSuite(
function getOrCreateBuildTargetItem(
testController: vscode.TestController,
workspaceFolderItem: vscode.TestItem,
targetUri: TargetUri,
targetName: TargetName
): vscode.TestItem {
const buildTarget = workspaceFolderItem.children.get(targetName);
const buildTarget = workspaceFolderItem.children.get(targetUri);
if (buildTarget) {
return buildTarget;
}

const createdNode = testController.createTestItem(targetName, targetName);
const createdNode = testController.createTestItem(targetUri, targetName);
refineTestItem("module", createdNode, workspaceFolderItem);
workspaceFolderItem.children.add(createdNode);

Expand Down
9 changes: 5 additions & 4 deletions packages/metals-vscode/src/testExplorer/removeTestItem.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as vscode from "vscode";
import { RemoveTestSuite, TargetName, FolderUri } from "./types";
import { RemoveTestSuite, FolderUri } from "./types";
import { prefixesOf, TestItemPath } from "./util";
import { TargetUri } from "../types";

export function removeTestItem(
testController: vscode.TestController,
targetName: TargetName,
targetUri: TargetUri,
folderUri: FolderUri,
event: RemoveTestSuite
): void {
Expand All @@ -29,12 +30,12 @@ export function removeTestItem(

const workspaceFolderItem = testController.items.get(folderUri);
if (workspaceFolderItem) {
const buildTargetItem = workspaceFolderItem.children.get(targetName);
const buildTargetItem = workspaceFolderItem.children.get(targetUri);
if (buildTargetItem) {
const testPath = prefixesOf(event.fullyQualifiedClassName);
removeTestItemLoop(buildTargetItem, testPath);
if (buildTargetItem.children.size === 0) {
testController.items.delete(buildTargetItem.id);
workspaceFolderItem.children.delete(buildTargetItem.id);
}
}
if (workspaceFolderItem.children.size === 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/metals-vscode/src/testExplorer/testManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class TestManager {
const folderName_ = folderName || ("root" as FolderName);
for (const event of events) {
if (event.kind === "removeSuite") {
removeTestItem(this.testController, targetName, folderUri_, event);
removeTestItem(this.testController, targetUri, folderUri_, event);
} else if (event.kind === "addSuite") {
addTestSuite(
this.testController,
Expand All @@ -106,7 +106,7 @@ class TestManager {
} else if (event.kind === "updateSuiteLocation") {
updateTestSuiteLocation(
this.testController,
targetName,
targetUri,
folderUri_,
event
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as vscode from "vscode";
import { TargetName, UpdateSuiteLocation, FolderUri } from "./types";
import { UpdateSuiteLocation, FolderUri } from "./types";
import { prefixesOf, TestItemPath, toVscodeRange } from "./util";
import { TargetUri } from "../types";

/**
*
Expand All @@ -11,7 +12,7 @@ import { prefixesOf, TestItemPath, toVscodeRange } from "./util";
*/
export function updateTestSuiteLocation(
testController: vscode.TestController,
targetName: TargetName,
targetUri: TargetUri,
folderUri: FolderUri,
event: UpdateSuiteLocation
): void {
Expand All @@ -36,7 +37,7 @@ export function updateTestSuiteLocation(

const workspaceFolderItem = testController.items.get(folderUri);
if (workspaceFolderItem) {
const buildTargetItem = workspaceFolderItem.children.get(targetName);
const buildTargetItem = workspaceFolderItem.children.get(targetUri);
if (buildTargetItem) {
const testPath = prefixesOf(event.fullyQualifiedClassName, true);
updateTestSuiteLocationLoop(buildTargetItem, testPath);
Expand Down

0 comments on commit a8ccbaa

Please sign in to comment.