feat(ide): package the VS Code extension as a VSIX
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 8s
VoidBuildSystem CI / sanitizers-gcc16 (push) Failing after 6s
VoidBuildSystem CI / fuzz-clang (push) Failing after 6s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 11s
VoidBuildSystem CI / wine-windows-gcc16 (push) Failing after 48s

This commit is contained in:
faumaray committed 2026-12-05 13:39:57 +03:00
1 parent 3f5b21a570
commit f032c9f7fe
10 files changed
+269 -74

No files matched your search

+67
View File
@@ -1218,6 +1218,73 @@ VOID_TEST(FullV1Tests, ide_plugin_assets_export_vscode_extension) {
Void::Testing::expect(manifest_text->find("\"test\": \"node test/extension.test.js\"") !=
std::string::npos);
// VSIX packaging: a ZIP with the VS Code extension layout and valid CRCs.
{
auto vsix_options = options;
vsix_options.output_dir = tmp / "vbs-tools-vsix";
vsix_options.vsix_path = tmp / "dist" / "vbs-tools.vsix";
auto vsix_report = Editor::generate_ide_plugin_assets(vsix_options);
Void::Testing::require(vsix_report.has_value());
auto vsix_bytes = Void::FileSystem::read_file(*vsix_options.vsix_path);
Void::Testing::require(vsix_bytes.has_value());
const std::string_view zip = *vsix_bytes;
const auto read_u16 = [&](std::size_t o) {
return static_cast<std::uint16_t>(static_cast<unsigned char>(zip[o]) |
(static_cast<unsigned char>(zip[o + 1]) << 8));
};
const auto read_u32 = [&](std::size_t o) {
std::uint32_t v = 0;
for (int i = 3; i >= 0; --i) {
v = (v << 8) | static_cast<unsigned char>(zip[o + static_cast<std::size_t>(i)]);
}
return v;
};
const auto eocd = zip.rfind(std::string_view{"PK\x05\x06", 4});
Void::Testing::require(eocd != std::string_view::npos);
const auto entry_count = read_u16(eocd + 10);
std::size_t offset = read_u32(eocd + 16);
std::vector<std::string> names;
std::size_t checked = 0;
for (std::uint16_t i = 0; i < entry_count; ++i) {
Void::Testing::require(zip.substr(offset, 4) == std::string_view{"PK\x01\x02", 4});
const auto crc_expected = read_u32(offset + 16);
const auto name_len = read_u16(offset + 28);
const auto extra_len = read_u16(offset + 30);
const auto comment_len = read_u16(offset + 32);
const auto local_offset = read_u32(offset + 42);
names.emplace_back(zip.substr(offset + 46, name_len));
// Recompute the CRC from the local entry data.
const auto local_name_len = read_u16(local_offset + 26);
const auto local_extra_len = read_u16(local_offset + 28);
const auto data_size = read_u32(local_offset + 22);
const auto data_start =
static_cast<std::size_t>(local_offset) + 30 + local_name_len + local_extra_len;
std::uint32_t crc = 0xFFFFFFFFu;
for (std::size_t b = data_start; b < data_start + data_size; ++b) {
crc ^= static_cast<unsigned char>(zip[b]);
for (int bit = 0; bit < 8; ++bit) {
crc = (crc >> 1) ^ (0xEDB88320u & (0u - (crc & 1u)));
}
}
Void::Testing::expect_eq(~crc, crc_expected);
++checked;
offset += 46 + name_len + extra_len + comment_len;
}
Void::Testing::expect_eq(checked, std::size_t{6});
const auto has_entry = [&](std::string_view name) {
return std::ranges::contains(names, name);
};
Void::Testing::expect(has_entry("extension.vsixmanifest"));
Void::Testing::expect(has_entry("[Content_Types].xml"));
Void::Testing::expect(has_entry("extension/package.json"));
Void::Testing::expect(has_entry("extension/extension.js"));
Void::Testing::expect(has_entry("extension/test/extension.test.js"));
Void::Testing::expect(zip.find("Id=\"vbs-tools\"") != std::string_view::npos);
Void::Testing::expect(zip.find("Path=\"extension/package.json\"") !=
std::string_view::npos);
Void::Testing::expect(!std::filesystem::exists(vsix_options.output_dir / ".vsix"));
}
auto zed_options = options;
zed_options.editor = Editor::IdeKind::Zed;
zed_options.output_dir = tmp / "vbs-zed";