Skip to content

Commit 54edbb7

Browse files
committed
Added delete env from Project logic + Regrouped buttons
1 parent 859250d commit 54edbb7

3 files changed

Lines changed: 193 additions & 123 deletions

File tree

package.json

Lines changed: 136 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
"category": "VectorCAST Test Explorer",
141141
"title": "Clean Environment"
142142
},
143+
{
144+
"command": "vectorcastTestExplorer.deleteEnviroFromProject",
145+
"category": "VectorCAST Test Explorer",
146+
"title": "Delete Environment from Project"
147+
},
143148
{
144149
"command": "vectorcastTestExplorer.removeTestsuite",
145150
"category": "VectorCAST Test Explorer",
@@ -456,6 +461,10 @@
456461
"command": "vectorcastTestExplorer.cleanEnviro",
457462
"when": "never"
458463
},
464+
{
465+
"command": "vectorcastTestExplorer.deleteEnviroFromProject",
466+
"when": "never"
467+
},
459468
{
460469
"command": "vectorcastTestExplorer.removeTestsuite",
461470
"when": "never"
@@ -677,128 +686,133 @@
677686
"group": "vcast@3"
678687
}
679688
],
680-
"vectorcastTestExplorer.vcastsubmenu": [
681-
{
682-
"command": "vectorcastTestExplorer.openVCAST",
683-
"group": "vcastOpen@1",
684-
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
685-
},
686-
{
687-
"command": "vectorcastTestExplorer.buildProjectEnviro",
688-
"group": "vcastBuild@1",
689-
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastUnbuiltEnviroList"
690-
},
691-
{
692-
"command": "vectorcastTestExplorer.buildExecuteIncremental",
693-
"group": "vcastBuild@3",
694-
"when": "vectorcastTestExplorer.globalProjectIsOpenedChecker && ( testId =~ /\\.vcm$/ || testId in vectorcastTestExplorer.globalProjectCompilers || testId in vectorcastTestExplorer.globalProjectTestsuites || (testId =~ /^vcast:.*$/ && ( testId in vectorcastTestExplorer.vcastEnviroList || testId in vectorcastTestExplorer.vcastUnbuiltEnviroList)))"
695-
},
696-
{
697-
"command": "vectorcastTestExplorer.rebuildEnviro",
698-
"group": "vcast@2",
699-
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
700-
},
701-
{
702-
"command": "vectorcastTestExplorer.addTestsuiteToCompiler",
703-
"group": "vcast@1",
704-
"when": "testId in vectorcastTestExplorer.globalProjectCompilers"
705-
},
706-
{
707-
"command": "vectorcastTestExplorer.addEnviroToProject",
708-
"group": "vcast@1",
709-
"when": "testId =~ /\\.vcm$/"
710-
},
711-
{
712-
"command": "vectorcastTestExplorer.updateProjectEnvironment",
713-
"group": "vcast@1",
714-
"when": "(testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker) && !config.vectorcastTestExplorer.automaticallyUpdateManageProject"
715-
},
716-
{
717-
"command": "vectorcastTestExplorer.addCompilerToProject",
718-
"group": "vcast@1",
719-
"when": "testId =~ /\\.vcm$/"
720-
},
721-
{
722-
"command": "vectorcastTestExplorer.openProjectInVectorCAST",
723-
"group": "vcast@1",
724-
"when": "testId =~ /\\.vcm$/ || testId in vectorcastTestExplorer.globalProjectCompilers || testId in vectorcastTestExplorer.globalProjectTestsuites"
725-
},
726-
{
727-
"command": "vectorcastTestExplorer.deleteTestsuite",
728-
"group": "vcast@1",
729-
"when": "testId in vectorcastTestExplorer.globalProjectTestsuites"
730-
},
731-
{
732-
"command": "vectorcastTestExplorer.deleteCompiler",
733-
"group": "vcast@1",
734-
"when": "testId in vectorcastTestExplorer.globalProjectCompilers"
735-
},
736-
{
737-
"command": "vectorcastTestExplorer.deleteEnviro",
738-
"group": "vcast@3",
739-
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && !vectorcastTestExplorer.globalProjectIsOpenedChecker"
740-
},
741-
{
742-
"command": "vectorcastTestExplorer.cleanEnviro",
743-
"group": "vcast@3",
744-
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.globalProjectIsOpenedChecker && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
745-
},
746-
{
747-
"command": "vectorcastTestExplorer.removeTestsuite",
748-
"group": "vcast@1",
749-
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker"
750-
},
751-
{
752-
"command": "vectorcastTestExplorer.editTestScript",
753-
"group": "vcast@4",
754-
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
755-
},
756-
{
757-
"command": "vectorcastTestExplorer.createTestScript",
758-
"group": "vcast@5",
759-
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /.*coded_tests_driver.*/)"
760-
},
761-
{
762-
"command": "vectorcastTestExplorer.addCodedTests",
763-
"group": "vcast@4",
764-
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
765-
},
766-
{
767-
"command": "vectorcastTestExplorer.generateCodedTests",
768-
"group": "vcast@5",
769-
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
770-
},
771-
{
772-
"command": "vectorcastTestExplorer.removeCodedTests",
773-
"group": "vcast@6",
774-
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId in vectorcastTestExplorer.vcastHasCodedTestsList"
775-
},
776-
{
777-
"command": "vectorcastTestExplorer.editCodedTest",
778-
"group": "vcast@7",
779-
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && testId =~ /.*coded_tests_driver.+/"
780-
},
781-
{
782-
"command": "vectorcastTestExplorer.insertBasisPathTests",
783-
"group": "vcast@6",
784-
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
785-
},
786-
{
787-
"command": "vectorcastTestExplorer.insertATGTests",
788-
"group": "vcast@7",
789-
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.atgAvailable && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
790-
},
791-
{
792-
"command": "vectorcastTestExplorer.deleteTest",
793-
"group": "vcast@8",
794-
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
795-
},
796-
{
797-
"command": "vectorcastTestExplorer.viewResults",
798-
"group": "vcast@9",
799-
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
800-
}
801-
]
689+
"vectorcastTestExplorer.vcastsubmenu": [
690+
{
691+
"command": "vectorcastTestExplorer.openProjectInVectorCAST",
692+
"group": "vcast.project",
693+
"when": "testId =~ /\\.vcm$/ || testId in vectorcastTestExplorer.globalProjectCompilers || testId in vectorcastTestExplorer.globalProjectTestsuites"
694+
},
695+
{
696+
"command": "vectorcastTestExplorer.addCompilerToProject",
697+
"group": "vcast.project",
698+
"when": "testId =~ /\\.vcm$/"
699+
},
700+
{
701+
"command": "vectorcastTestExplorer.addEnviroToProject",
702+
"group": "vcast.project",
703+
"when": "testId =~ /\\.vcm$/"
704+
},
705+
{
706+
"command": "vectorcastTestExplorer.addTestsuiteToCompiler",
707+
"group": "vcast.project",
708+
"when": "testId in vectorcastTestExplorer.globalProjectCompilers"
709+
},
710+
{
711+
"command": "vectorcastTestExplorer.updateProjectEnvironment",
712+
"group": "vcast.project",
713+
"when": "(testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker) && !config.vectorcastTestExplorer.automaticallyUpdateManageProject"
714+
},
715+
{
716+
"command": "vectorcastTestExplorer.buildProjectEnviro",
717+
"group": "vcast.build",
718+
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastUnbuiltEnviroList"
719+
},
720+
{
721+
"command": "vectorcastTestExplorer.buildExecuteIncremental",
722+
"group": "vcast.build",
723+
"when": "vectorcastTestExplorer.globalProjectIsOpenedChecker && ( testId =~ /\\.vcm$/ || testId in vectorcastTestExplorer.globalProjectCompilers || testId in vectorcastTestExplorer.globalProjectTestsuites || (testId =~ /^vcast:.*$/ && ( testId in vectorcastTestExplorer.vcastEnviroList || testId in vectorcastTestExplorer.vcastUnbuiltEnviroList)))"
724+
},
725+
{
726+
"command": "vectorcastTestExplorer.rebuildEnviro",
727+
"group": "vcast.build",
728+
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
729+
},
730+
{
731+
"command": "vectorcastTestExplorer.cleanEnviro",
732+
"group": "vcast.build",
733+
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && vectorcastTestExplorer.globalProjectIsOpenedChecker && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
734+
},
735+
{
736+
"command": "vectorcastTestExplorer.openVCAST",
737+
"group": "vcast.enviroManagement",
738+
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
739+
},
740+
{
741+
"command": "vectorcastTestExplorer.deleteEnviro",
742+
"group": "vcast.enviroManagement",
743+
"when": "testId =~ /^vcast:.*$/ && testId in vectorcastTestExplorer.vcastEnviroList && !vectorcastTestExplorer.globalProjectIsOpenedChecker"
744+
},
745+
{
746+
"command": "vectorcastTestExplorer.deleteEnviroFromProject",
747+
"group": "vcast.enviroManagement",
748+
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker"
749+
},
750+
{
751+
"command": "vectorcastTestExplorer.removeTestsuite",
752+
"group": "vcast.enviroManagement",
753+
"when": "testId =~ /^vcast:.*$/ && (testId in vectorcastTestExplorer.vcastUnbuiltEnviroList || testId in vectorcastTestExplorer.vcastEnviroList) && vectorcastTestExplorer.globalProjectIsOpenedChecker"
754+
},
755+
{
756+
"command": "vectorcastTestExplorer.editTestScript",
757+
"group": "vcast.testScript",
758+
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
759+
},
760+
{
761+
"command": "vectorcastTestExplorer.createTestScript",
762+
"group": "vcast.testScript",
763+
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && !(testId =~ /.*coded_tests_driver.*/ )"
764+
},
765+
{
766+
"command": "vectorcastTestExplorer.editCodedTest",
767+
"group": "vcast.testScript",
768+
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList && testId =~ /.*coded_tests_driver.+/"
769+
},
770+
{
771+
"command": "vectorcastTestExplorer.addCodedTests",
772+
"group": "vcast.testScript",
773+
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
774+
},
775+
{
776+
"command": "vectorcastTestExplorer.generateCodedTests",
777+
"group": "vcast.testScript",
778+
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId not in vectorcastTestExplorer.vcastHasCodedTestsList"
779+
},
780+
{
781+
"command": "vectorcastTestExplorer.removeCodedTests",
782+
"group": "vcast.testScript",
783+
"when": "testId =~ /^vcast:.*$/ && testId =~ /.*coded_tests_driver$/ && testId in vectorcastTestExplorer.vcastHasCodedTestsList"
784+
},
785+
{
786+
"command": "vectorcastTestExplorer.insertBasisPathTests",
787+
"group": "vcast.testGeneration",
788+
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
789+
},
790+
{
791+
"command": "vectorcastTestExplorer.insertATGTests",
792+
"group": "vcast.testGeneration",
793+
"when": "testId =~ /^vcast:.*$/ && vectorcastTestExplorer.atgAvailable && !(testId =~ /^.*<<COMPOUND>>.*$/) && !(testId =~ /^.*<<INIT>>.*$/) && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
794+
},
795+
{
796+
"command": "vectorcastTestExplorer.deleteTest",
797+
"group": "vcast.delete",
798+
"when": "testId =~ /^vcast:.*$/ && !(testId =~ /.*coded_tests_driver.*/) && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
799+
},
800+
{
801+
"command": "vectorcastTestExplorer.deleteTestsuite",
802+
"group": "vcast.delete",
803+
"when": "testId in vectorcastTestExplorer.globalProjectTestsuites"
804+
},
805+
{
806+
"command": "vectorcastTestExplorer.deleteCompiler",
807+
"group": "vcast.delete",
808+
"when": "testId in vectorcastTestExplorer.globalProjectCompilers"
809+
},
810+
{
811+
"command": "vectorcastTestExplorer.viewResults",
812+
"group": "vcast.results",
813+
"when": "testId =~ /^vcast:.*$/ && testId not in vectorcastTestExplorer.vcastEnviroList && testId not in vectorcastTestExplorer.vcastUnbuiltEnviroList"
814+
}
815+
]
802816
},
803817
"submenus": [
804818
{

src/extension.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import {
9595
buildExecuteIncremental,
9696
cleanProjectEnvironment,
9797
addEnvToTestsuite,
98+
deleteEnvironmentFromProject,
9899
} from "./manage/manageSrc/manageCommands";
99100

100101
import {
@@ -868,6 +869,33 @@ function configureExtension(context: vscode.ExtensionContext) {
868869
);
869870
context.subscriptions.push(deleteCompilerCommand);
870871

872+
// Command: vectorcastTestExplorer.deleteEnviroFromProject ////////////////////////////////////////////////////////
873+
let deleteEnviroFromProject = vscode.commands.registerCommand(
874+
"vectorcastTestExplorer.deleteEnviroFromProject",
875+
async (enviroNode: any) => {
876+
const enviroPath = enviroNode.id.split("vcast:")[1];
877+
const enviroName = path.basename(enviroPath);
878+
const enviroData: environmentNodeDataType = getEnviroNodeData(enviroPath);
879+
// always ask for confirmation before deleting an environment
880+
const message =
881+
"Environment: " +
882+
enviroName +
883+
" will be deleted from the project, and this action cannot be undone.";
884+
vscode.window
885+
.showInformationMessage(message, "Delete", "Cancel")
886+
.then(async (answer) => {
887+
if (answer === "Delete") {
888+
// Delete the env completely from the project
889+
await deleteEnvironmentFromProject(
890+
enviroData.projectPath,
891+
enviroName
892+
);
893+
}
894+
});
895+
}
896+
);
897+
context.subscriptions.push(deleteEnviroFromProject);
898+
871899
// Command: vectorcastTestExplorer.removeTestsuite ////////////////////////////////////////////////////////
872900
let removeTestsuite = vscode.commands.registerCommand(
873901
"vectorcastTestExplorer.removeTestsuite",

src/manage/manageSrc/manageCommands.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
} from "../../../src-common/vcastServer";
3535

3636
import {
37-
globalController,
3837
globalProjectDataCache,
3938
refreshAllExtensionData,
4039
runTests,
@@ -190,6 +189,35 @@ export async function removeTestsuiteFromProject(
190189
);
191190
}
192191

192+
/**
193+
* Deletes the environment from the project
194+
* @param projectPath Path to the project
195+
* @param enviroName Name of the environment
196+
*/
197+
export async function deleteEnvironmentFromProject(
198+
projectPath: string,
199+
enviroName: string
200+
) {
201+
const projectName = path.basename(projectPath);
202+
const projectLocation = path.dirname(projectPath);
203+
const manageArgs = [
204+
`-p${projectName}`,
205+
`-e${enviroName}`,
206+
`--delete`,
207+
`--force`,
208+
];
209+
210+
const message = `Deleting ${enviroName} from Project ${projectName} ...`;
211+
212+
await executeWithRealTimeEchoWithProgress(
213+
manageCommandToUse,
214+
manageArgs,
215+
projectLocation,
216+
message
217+
);
218+
await refreshAllExtensionData();
219+
}
220+
193221
export async function createTestsuiteInCompiler(
194222
projectPath: string,
195223
compilerName: string,

0 commit comments

Comments
 (0)