From 995a40e7dd627b9920c1b00214844d0f039bc0a1 Mon Sep 17 00:00:00 2001 From: Jorijn van der Graaf Date: Sat, 3 Oct 2026 20:09:22 +0200 Subject: [PATCH] test(incremental): a compiler update perturbs VariantId Two toolchains that differ only in the clang release, as the Flatpak's do across an update, must give one Configuration two variants; so must the same release installed under another prefix. The no-argument form is checked to be the variant under the running toolchain, and BuildDir to be named for it. Co-Authored-By: Claude Fable 5.1 --- tests/VariantId/main.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/VariantId/main.cpp b/tests/VariantId/main.cpp index 022b0d6..e4d2a36 100644 --- a/tests/VariantId/main.cpp +++ b/tests/VariantId/main.cpp @@ -133,6 +133,33 @@ int main() { Check(a.BuildDir() != b.BuildDir(), "different VariantId yields different BuildDir"); Check(a.BinDir() != b.BinDir(), "different VariantId yields different BinDir"); } + { + // The compiler is compile state as much as any flag: a PCM can only + // be read by the clang release that wrote it, and nothing in a + // project's sources changes when the compiler does. With the + // toolchain left out of the id, a project built with clang 22 kept + // its PCMs after crafter-build moved to clang 23; the build after + // the update found nothing stale, and the first edit failed with + // "module file ... uses an older format that is no longer supported" + // until the project was cleaned by hand. + Configuration cfg = MakeBase(); + Toolchain older; + older.clangxx = "/app/bin/clang++"; + older.clangVersion = "clang version 22.1.8"; + Toolchain newer = older; + newer.clangVersion = "clang version 23.1.2"; + Check(cfg.VariantId(older) != cfg.VariantId(newer), "a compiler update at the same path perturbs VariantId"); + Check(cfg.VariantId(older) == cfg.VariantId(older), "VariantId under one toolchain is deterministic"); + + // Two installs of one release are still two toolchains: their + // libc++ need not be the same build. + Toolchain elsewhere = older; + elsewhere.clangxx = "/usr/bin/clang++"; + Check(cfg.VariantId(older) != cfg.VariantId(elsewhere), "the same release installed elsewhere perturbs VariantId"); + + Check(cfg.VariantId() == cfg.VariantId(GetToolchain()), "VariantId() is the variant under the running toolchain"); + Check(cfg.BuildDir().filename() == cfg.VariantId(GetToolchain()), "BuildDir is named for the running toolchain's variant"); + } if (Failures > 0) { std::println(std::cerr, "{} assertions failed", Failures);