test(provider): verify the Conan2 provider against a live conan install
VoidBuildSystem CI / build-and-test-gcc16 (push) Failing after 5s
VoidBuildSystem CI / signing-openssl-gcc16 (push) Failing after 9s

This commit is contained in:
faumaray committed 2026-12-04 01:14:11 +03:00
1 parent e990f44037
commit 7fd8fe9f6d
4 files changed
+110 -2

No files matched your search

+90
View File
@@ -20,12 +20,14 @@
#include <Void/Build/State/StateStore.hpp>
#include <Void/Build/Toolchain/Driver.hpp>
#include <Void/Build/Watch/Watcher.hpp>
#include <Void/Core/Scope.hpp>
#include <Void/Data/StrictJson.hpp>
#include <Void/System/Path.hpp>
#include <Void/System/TempDir.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <fstream>
@@ -2310,3 +2312,91 @@ VOID_TEST(FullV1Tests, ide_integration_compdb_build_cpp_and_editor_configs_end_t
std::string::npos);
}
}
// Live Conan2 verification (Track B3): a real local package is built into an isolated
// CONAN_HOME and the provider performs a real `conan install`.
VOID_TEST(FullV1Tests, track_b3_live_conan_provider_install) {
if (!Platform::resolve_executable("conan").has_value()) {
return;
}
Void::FileSystem::TempDir tmp{"vbs_conan_live_"};
const auto conan_home = tmp / "conan_home";
const auto profile = tmp / "conan.profile";
write_file(profile, "[settings]\nos=Linux\narch=x86_64\ncompiler=gcc\nbuild_type=Debug\n");
// Isolate the global conan cache and restore the environment afterwards.
const char *previous_home = std::getenv("CONAN_HOME");
const std::string saved_home = previous_home == nullptr ? std::string{} : previous_home;
const bool had_home = previous_home != nullptr;
(void)::setenv("CONAN_HOME", conan_home.c_str(), 1);
const auto restore_home = Void::Scope::on_exit([&] {
if (had_home) {
(void)::setenv("CONAN_HOME", saved_home.c_str(), 1);
} else {
(void)::unsetenv("CONAN_HOME");
}
});
write_file(tmp / "pkg" / "conanfile.py", R"py(from conan import ConanFile
from conan.tools.files import copy
class DemoPkg(ConanFile):
name = "vbs-demo"
version = "1.0.0"
package_type = "header-library"
def package(self):
copy(self, "*.hpp", self.source_folder, self.package_folder + "/include")
)py");
write_file(tmp / "pkg" / "demo.hpp",
"#pragma once\ninline int vbs_demo_value() { return 5; }\n");
Platform::ProcessRequest create;
auto conan = Platform::resolve_executable("conan");
Void::Testing::require(conan.has_value());
create.executable = *conan;
create.arguments = {
"create", (tmp / "pkg").string(), "--name", "vbs-demo", "--version",
"1.0.0", "--profile:host", profile.string(), "--profile:build", profile.string()};
create.timeout = std::chrono::seconds{240};
auto created = Platform::run_supervised(create);
Void::Testing::expect(created.has_value() && created->succeeded());
if (!created || !created->succeeded()) {
return;
}
auto ctx = default_profiles().resolve("debug", CompilerFamily::Gcc, Toolchain::host_os_name(),
Toolchain::host_architecture_name());
auto tc = Toolchain::discover_and_probe(ctx, tmp / "probes");
Void::Testing::expect(tc.has_value());
if (!tc) {
return;
}
DependencyRecord conan_dep;
conan_dep.name = "demo";
conan_dep.source_kind = DependencySourceKind::Conan;
conan_dep.package = "vbs-demo/1.0.0";
conan_dep.builder = "conan";
Package::MaterializedSource dummy{"demo", tmp / "src", "dummy", true};
auto exported = Provider::resolve_foreign_provider(
{conan_dep, dummy, ctx, *tc, tmp / "prov", Provider::ProviderMode::FullBuild, {}});
Void::Testing::expect(exported.has_value());
if (exported) {
Void::Testing::expect_eq(exported->builder, std::string{"conan"});
std::error_code ec;
bool found_profile = false;
bool found_install_output = false;
for (const auto &entry : std::filesystem::recursive_directory_iterator(tmp / "prov", ec)) {
if (entry.path().filename() == "conan_host.profile") {
found_profile = true;
}
if (entry.path().filename() == "conanbuild.sh") {
found_install_output = true;
}
}
Void::Testing::expect(found_profile);
// Generated env scripts prove `conan install` really executed.
Void::Testing::expect(found_install_output);
}
}