MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / writePackageReceiptFixture

Function writePackageReceiptFixture

Tests/Tools/ToolsTest.cpp:69–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67 info.hostPlatform = "test";
68 info.packageVariant = "host";
69 info.source = "test";
70 info.sourceHash = "";
71 info.validation = "passed";
72 const StringView phases[] = {"installFakeRegistryPackage", "writeReceipt"};
73 info.phases = phases;
74 const Tools::PackageReceiptExport exports[] = {
75 {Tools::PackageExportKind::Tool, "fake-tool", "bin/fake-tool"},
76 {Tools::PackageExportKind::Capability, "tool.fake", "bin/fake-tool"},
77 };
78 return Tools::writePackageReceipt(package, info, exports);
79}
80
81static Result writePackageReceiptFixture(StringView packageRoot, StringView packageName,
82 Span<const Tools::PackageReceiptExport> exports)
83{
84 FileSystem fs;
85 SC_TRY(fs.init("."));
86 if (fs.existsAndIsDirectory(packageRoot))
87 {
88 SC_TRY(fs.removeDirectoriesRecursive(packageRoot));
89 }
90 SC_TRY(fs.makeDirectoryRecursive(packageRoot));
91
92 for (const Tools::PackageReceiptExport& packageExport : exports)
93 {
94 if (packageExport.relativePath == "."_a8)
95 {
96 continue;
97 }
98
99 String exportedPath = StringEncoding::Utf8;
100 SC_TRY(Path::join(exportedPath, {packageRoot, packageExport.relativePath}));
101 SC_TRY(fs.makeDirectoryRecursive(Path::dirname(exportedPath.view(), Path::AsNative)));
102 SC_TRY(fs.writeString(exportedPath.view(), "fake"));
103 }
104
105 Tools::Package package;
106 package.installDirectoryLink = packageRoot;
107
108 Tools::PackageReceiptInfo info;
109 info.packageName = packageName;
110 info.packageVersion = "1";
111 info.recipeVersion = "1";

Callers 1

SupportToolsTestMethod · 0.85

Calls 8

dirnameFunction · 0.85
existsAndIsDirectoryMethod · 0.80
joinFunction · 0.50
initMethod · 0.45
viewMethod · 0.45
writeStringMethod · 0.45

Tested by

no test coverage detected