Skip to content

Commit 17d9cc1

Browse files
fix(test): mcpp test announces a dependency with its resolved version
Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent 49e2bb1 commit 17d9cc1

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/build/execute.cppm‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4021,7 +4021,11 @@ static void test_announce(const BuildContext& ctx) {
40214021
auto announce = [&](const std::string& name,
40224022
const mcpp::manifest::DependencySpec& spec,
40234023
std::string_view suffix) {
4024-
std::string ver = spec.isPath() ? "(path)" : std::string("v") + spec.version;
4024+
// The resolved version, as the build's own banner reads it (mcpp#363):
4025+
// `spec.version` is the constraint as written (`^0.3.1`).
4026+
const auto resolved = ctx.resolvedVersions.find(name);
4027+
std::string ver = spec.isPath() ? "(path)"
4028+
: std::string("v") + (resolved != ctx.resolvedVersions.end() ? resolved->second : spec.version);
40254029
auto it = cachedUnits.find(name);
40264030
if (it == cachedUnits.end()) {
40274031
mcpp::ui::status("Compiling",

‎tests/e2e/196_version_identity_and_lock.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ rm -f mcpp.lock
210210
"$MCPP" build > c1.log 2>&1 || fail "build with a dev-dep failed" c1.log
211211
cp mcpp.lock lock.build
212212
"$MCPP" test > c2.log 2>&1 || fail "test with a dev-dep failed" c2.log
213+
# `mcpp test` announces the resolved version too, as the build's banner does.
214+
grep -q 'acme\.im v\^' c2.log \
215+
&& fail "mcpp test announced a constraint as a version" c2.log
213216
cmp -s mcpp.lock lock.build \
214217
|| { diff lock.build mcpp.lock || true
215218
fail "mcpp test rewrote mcpp.lock — the lock must not depend on the command"; }

0 commit comments

Comments
 (0)