Skip to content

Commit 21f2570

Browse files
grasci-armedriouk
andauthored
Add upgrade pack version test for cbuild-pack.yml (#1353) (#2271)
cbuild-pack.yml reflects change of explicit version in csolution.yml Co-authored-by: Evgueni Driouk <[email protected]>
1 parent 4105f2c commit 21f2570

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cbuild-pack:
2+
resolved-packs:
3+
- resolved-pack: ARM::[email protected]
4+
selected-by-pack:
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Open-CMSIS-Pack/devtools/main/tools/projmgr/schemas/csolution.schema.json
2+
3+
solution:
4+
target-types:
5+
- type: CM0
6+
device: RteTest_ARMCM0
7+
packs:
8+
- pack: ARM::[email protected]
9+
projects:
10+
- project: ./project_with_dfp_components.cproject.yml

tools/projmgr/test/src/ProjMgrUnitTests.cpp

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,37 @@ TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockPackVersion) {
943943
RteFsUtils::RemoveFile(cbuildPackBackup);
944944
}
945945

946+
947+
TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockPackVersionUpgrade) {
948+
char* argv[6];
949+
950+
// convert --solution solution.yml
951+
const string csolution = testinput_folder + "/TestSolution/PackLocking/lock_pack_version_upgrade.csolution.yml";
952+
const string cbuildPack = testinput_folder + "/TestSolution/PackLocking/lock_pack_version_upgrade.cbuild-pack.yml";
953+
954+
string buf1;
955+
RteFsUtils::ReadFile(cbuildPack, buf1);
956+
957+
const string output = testoutput_folder + "/testpacklock";
958+
argv[1] = (char*)"convert";
959+
argv[2] = (char*)"--solution";
960+
argv[3] = (char*)csolution.c_str();
961+
argv[4] = (char*)"-o";
962+
argv[5] = (char*)output.c_str();
963+
EXPECT_EQ(0, RunProjMgr(6, argv, m_envp));
964+
965+
string buf2;
966+
RteFsUtils::ReadFile(cbuildPack, buf2);
967+
RteUtils::ReplaceAll(buf2, "\r\n", "\n");
968+
// Check that the cbuild-pack file has been modified by this operation to reflect version change in csolution.yml
969+
EXPECT_NE(buf2, buf1); // expected 0.0.1 != 0.2.0
970+
971+
// replace buf1 versions with expected values
972+
RteUtils::ReplaceAll(buf1, "@0.1.1", "@0.2.0");
973+
EXPECT_EQ(buf2, buf1);
974+
}
975+
976+
946977
TEST_F(ProjMgrUnitTests, RunProjMgrSolution_MultiplePackEntries) {
947978
char* argv[3];
948979
const string csolution = testinput_folder + "/TestSolution/PackLocking/multiple_pack_entries.csolution.yml";
@@ -1502,8 +1533,7 @@ TEST_F(ProjMgrUnitTests, RunProjMgrSolution_LockedPackVersionNotChangedByAddedPa
15021533
argv[3] = (char*)csolution.c_str();
15031534
argv[4] = (char*)"-o";
15041535
argv[5] = (char*)output.c_str();
1505-
argv[6] = (char*)"--cbuildgen";
1506-
EXPECT_EQ(0, RunProjMgr(7, argv, m_envp));
1536+
EXPECT_EQ(0, RunProjMgr(6, argv, m_envp));
15071537

15081538
// Check that the cbuild-pack file contains both packs and that the first still has the same version
15091539
EXPECT_TRUE(RteFsUtils::ReadFile(cbuildPack, buf));

0 commit comments

Comments
 (0)