diff --git a/tools/projmgr/include/ProjMgrWorker.h b/tools/projmgr/include/ProjMgrWorker.h index 672080d2a..c7d299408 100644 --- a/tools/projmgr/include/ProjMgrWorker.h +++ b/tools/projmgr/include/ProjMgrWorker.h @@ -1242,6 +1242,7 @@ class ProjMgrWorker { m_missingFiles.clear(); m_types = {}; m_activeTargetType.clear(); + m_activeTargetSet = {}; m_missingToolchains.clear(); m_undefCompiler = false; m_isSetupCommand = false; diff --git a/tools/projmgr/test/data/TestRpc/minimal2.cproject.yml b/tools/projmgr/test/data/TestRpc/minimal2.cproject.yml new file mode 100644 index 000000000..42a444d17 --- /dev/null +++ b/tools/projmgr/test/data/TestRpc/minimal2.cproject.yml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/cproject.schema.json + +project: + + components: + - component: Startup + - component: CORE diff --git a/tools/projmgr/test/data/TestRpc/minimal2.csolution.yml b/tools/projmgr/test/data/TestRpc/minimal2.csolution.yml new file mode 100644 index 000000000..864a09f0d --- /dev/null +++ b/tools/projmgr/test/data/TestRpc/minimal2.csolution.yml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json + +solution: + + compiler: AC6 + + target-types: + - type: TestHW + device: RteTest_ARMCM4_NOFP + + projects: + - project: minimal2.cproject.yml + + packs: + - pack: ARM::RteTest_DFP diff --git a/tools/projmgr/test/src/ProjMgrRpcTests.cpp b/tools/projmgr/test/src/ProjMgrRpcTests.cpp index 6ca9d090b..c7114e741 100644 --- a/tools/projmgr/test/src/ProjMgrRpcTests.cpp +++ b/tools/projmgr/test/src/ProjMgrRpcTests.cpp @@ -160,6 +160,18 @@ TEST_F(ProjMgrRpcTests, RpcLoadUndefinedSolution) { EXPECT_TRUE(msg.find("failed to load and process solution") == 0); } +TEST_F(ProjMgrRpcTests, RpcLoadSolutionResetActiveTargetSet) { + auto csolutionPath = testinput_folder + "/TestRpc/minimal.csolution.yml"; + auto csolutionPath2 = testinput_folder + "/TestRpc/minimal2.csolution.yml"; + const auto requests = + FormatRequest(1, "LoadPacks") + + FormatRequest(2, "LoadSolution", json({{ "solution", csolutionPath }, { "activeTarget", "TestHW" }})) + + FormatRequest(3, "LoadSolution", json({{ "solution", csolutionPath2 }, { "activeTarget", "TestHW" }})); + const auto& responses = RunRpcMethods(requests); + // ensure loading 'minimal2' solution does fail due to m_activeTargetSet set when previously loading 'minimal' + EXPECT_TRUE(responses[2]["result"]["success"]); +} + TEST_F(ProjMgrRpcTests, RpcLoadNotSolution) { const auto& requests = CreateLoadRequests("/TestRpc/undefined.yml"); const auto& responses = RunRpcMethods(requests);