feat(install,ide): self-extracting installers and install tasks
This commit is contained in:
1 parent
83ec08390f
commit
d23a878eec
9 files changed
+232
-5
No files matched your search
+76
-3
@@ -846,15 +846,80 @@ void build(Void::Build::Project &p) {
|
||||
|
||||
Platform::ProcessRequest inst_req;
|
||||
inst_req.executable = vbs_bin;
|
||||
inst_req.arguments = {"install", "--project", cli_proj.string(),
|
||||
"--build-dir", cli_build.string(), "--prefix",
|
||||
cli_prefix.string(), "--package-name", "CliHiPkg"};
|
||||
const auto installer_archive = tmp / "cli_hi-installer.tar";
|
||||
inst_req.arguments = {"install",
|
||||
"--project",
|
||||
cli_proj.string(),
|
||||
"--build-dir",
|
||||
cli_build.string(),
|
||||
"--prefix",
|
||||
cli_prefix.string(),
|
||||
"--package-name",
|
||||
"CliHiPkg",
|
||||
"--bundle-dependencies",
|
||||
"--archive",
|
||||
installer_archive.string()};
|
||||
auto inst_cli = Platform::run_supervised(inst_req);
|
||||
Void::Testing::expect(inst_cli.has_value() && inst_cli->succeeded());
|
||||
Void::Testing::expect(std::filesystem::exists(cli_prefix / "bin" / "cli_hi"));
|
||||
Void::Testing::expect(
|
||||
std::filesystem::exists(cli_prefix / "share" / "vbs" / "CliHiPkg" / "package.json"));
|
||||
|
||||
// The installer archive is a deterministic, self-contained snapshot of the prefix.
|
||||
Void::Testing::expect(std::filesystem::exists(installer_archive));
|
||||
const auto unpacked = tmp / "cli_inst_unpacked";
|
||||
auto unpack = Package::extract_safe_tar(installer_archive, unpacked);
|
||||
Void::Testing::expect(unpack.has_value());
|
||||
Void::Testing::expect(std::filesystem::exists(unpacked / "bin" / "cli_hi"));
|
||||
Void::Testing::expect(
|
||||
std::filesystem::exists(unpacked / "share" / "vbs" / "CliHiPkg" / "package.json"));
|
||||
const auto archive_a = tmp / "cli_hi-installer-a.tar";
|
||||
const auto archive_b = tmp / "cli_hi-installer-b.tar";
|
||||
auto req_a = inst_req;
|
||||
auto req_b = inst_req;
|
||||
for (auto &arg : req_a.arguments) {
|
||||
if (arg == installer_archive.string()) {
|
||||
arg = archive_a.string();
|
||||
}
|
||||
}
|
||||
for (auto &arg : req_b.arguments) {
|
||||
if (arg == installer_archive.string()) {
|
||||
arg = archive_b.string();
|
||||
}
|
||||
}
|
||||
Void::Testing::expect(Platform::run_supervised(req_a).value_or(Platform::ProcessResult{})
|
||||
.succeeded());
|
||||
Void::Testing::expect(Platform::run_supervised(req_b).value_or(Platform::ProcessResult{})
|
||||
.succeeded());
|
||||
const auto bytes_a = Void::FileSystem::read_file(archive_a);
|
||||
const auto bytes_b = Void::FileSystem::read_file(archive_b);
|
||||
Void::Testing::expect(bytes_a.has_value() && bytes_b.has_value() && *bytes_a == *bytes_b);
|
||||
|
||||
// CPack-style self-extracting installer script.
|
||||
const auto script_archive = tmp / "cli_hi-installer.sh";
|
||||
auto script_req = inst_req;
|
||||
for (auto &arg : script_req.arguments) {
|
||||
if (arg == installer_archive.string()) {
|
||||
arg = script_archive.string();
|
||||
}
|
||||
}
|
||||
script_req.arguments.push_back("--archive-format");
|
||||
script_req.arguments.push_back("sh");
|
||||
auto script_res = Platform::run_supervised(script_req);
|
||||
Void::Testing::expect(script_res.has_value() && script_res->succeeded());
|
||||
Void::Testing::expect(std::filesystem::exists(script_archive));
|
||||
if (script_res && script_res->succeeded()) {
|
||||
const auto script_prefix = tmp / "cli_script_prefix";
|
||||
Platform::ProcessRequest run_script;
|
||||
run_script.executable = "/bin/sh";
|
||||
run_script.arguments = {script_archive.string(), "--prefix", script_prefix.string()};
|
||||
auto run_res = Platform::run_supervised(run_script);
|
||||
Void::Testing::expect(run_res.has_value() && run_res->succeeded());
|
||||
Void::Testing::expect(std::filesystem::exists(script_prefix / "bin" / "cli_hi"));
|
||||
Void::Testing::expect(std::filesystem::exists(
|
||||
script_prefix / "share" / "vbs" / "CliHiPkg" / "package.json"));
|
||||
}
|
||||
|
||||
Platform::ProcessRequest uninst_req;
|
||||
uninst_req.executable = vbs_bin;
|
||||
uninst_req.arguments = {"uninstall", "--prefix", cli_prefix.string()};
|
||||
@@ -2231,6 +2296,14 @@ VOID_TEST(FullV1Tests, ide_integration_compdb_build_cpp_and_editor_configs_end_t
|
||||
Void::Testing::expect(parsed.has_value());
|
||||
}
|
||||
}
|
||||
// The generated IDE tasks include install/package entries.
|
||||
if (auto tasks = Void::FileSystem::read_file(proj / ".vscode" / "tasks.json"); tasks) {
|
||||
Void::Testing::expect(tasks->find("vbs: install") != std::string::npos);
|
||||
Void::Testing::expect(tasks->find("vbs: package installer") != std::string::npos);
|
||||
}
|
||||
if (auto zed_tasks = Void::FileSystem::read_file(proj / ".zed" / "tasks.json"); zed_tasks) {
|
||||
Void::Testing::expect(zed_tasks->find("vbs: install") != std::string::npos);
|
||||
}
|
||||
|
||||
// 3. Non-destructive overwrite preservation without `--force`, and overwrite with `--force`.
|
||||
write_file(proj / ".clangd", "# user-customized clangd\n");
|
||||
|
||||
Reference in new issue
Block a user