Skip to content

Commit 859cb6c

Browse files
authored
[csolution-rpc] Clean active target set before loading a solution (#2496)
## Fixes <!-- List the issue(s) this PR resolves --> - Open-CMSIS-Pack/vscode-cmsis-solution#302 ## Changes <!-- List the changes this PR introduces --> - Clean active target set before loading a solution, ensuring a previously loaded target set (and its project-context selection) is not inadvertently reused. - Add test case. ## Checklist <!-- Put an `x` in the boxes. All tasks must be completed and boxes checked before merging. --> - [x] 🤖 This change is covered by unit tests (if applicable). - [x] 🤹 Manual testing has been performed (if necessary). - [x] 🛡️ Security impacts have been considered (if relevant). - [x] 📖 Documentation updates are complete (if required). - [x] 🧠 Third-party dependencies and TPIP updated (if required).
1 parent 7b35e61 commit 859cb6c

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

tools/projmgr/include/ProjMgrWorker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ class ProjMgrWorker {
12421242
m_missingFiles.clear();
12431243
m_types = {};
12441244
m_activeTargetType.clear();
1245+
m_activeTargetSet = {};
12451246
m_missingToolchains.clear();
12461247
m_undefCompiler = false;
12471248
m_isSetupCommand = false;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json
2+
3+
project:
4+
5+
components:
6+
- component: Startup
7+
- component: CORE
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
5+
compiler: AC6
6+
7+
target-types:
8+
- type: TestHW
9+
device: RteTest_ARMCM4_NOFP
10+
11+
projects:
12+
- project: minimal2.cproject.yml
13+
14+
packs:
15+
- pack: ARM::RteTest_DFP

tools/projmgr/test/src/ProjMgrRpcTests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ TEST_F(ProjMgrRpcTests, RpcLoadUndefinedSolution) {
160160
EXPECT_TRUE(msg.find("failed to load and process solution") == 0);
161161
}
162162

163+
TEST_F(ProjMgrRpcTests, RpcLoadSolutionResetActiveTargetSet) {
164+
auto csolutionPath = testinput_folder + "/TestRpc/minimal.csolution.yml";
165+
auto csolutionPath2 = testinput_folder + "/TestRpc/minimal2.csolution.yml";
166+
const auto requests =
167+
FormatRequest(1, "LoadPacks") +
168+
FormatRequest(2, "LoadSolution", json({{ "solution", csolutionPath }, { "activeTarget", "TestHW" }})) +
169+
FormatRequest(3, "LoadSolution", json({{ "solution", csolutionPath2 }, { "activeTarget", "TestHW" }}));
170+
const auto& responses = RunRpcMethods(requests);
171+
// ensure loading 'minimal2' solution does fail due to m_activeTargetSet set when previously loading 'minimal'
172+
EXPECT_TRUE(responses[2]["result"]["success"]);
173+
}
174+
163175
TEST_F(ProjMgrRpcTests, RpcLoadNotSolution) {
164176
const auto& requests = CreateLoadRequests("/TestRpc/undefined.yml");
165177
const auto& responses = RunRpcMethods(requests);

0 commit comments

Comments
 (0)