11#! /usr/bin/env bash
2- # 29_toolchain_partial_versions.sh — `mcpp toolchain {install,default}` accept
3- # partial versions and either positional or @-separated form, AND auto-install
4- # the default toolchain on a first-run `mcpp build` with no toolchain configured.
2+ # 29_toolchain_partial_versions.sh — `mcpp toolchain default` accepts partial
3+ # versions in either positional or @-separated form, AND `mcpp build`
4+ # auto-installs the default toolchain on a first run with no toolchain
5+ # configured. The full install path is covered by 26_toolchain_management.sh.
56#
6- # We isolate via MCPP_HOME so we don't touch the user's real ~/.mcpp sandbox.
7+ # We isolate config/default state via MCPP_HOME, while reusing already prepared
8+ # xlings payloads when available so CI does not redownload full toolchains.
79set -e
810
911TMP=$( mktemp -d)
1012trap " rm -rf $TMP " EXIT
1113
12- # ─── Section 1: dual-form + partial-version toolchain commands ─────────
13- export MCPP_HOME=" $TMP /h1"
14+ inherit_payloads_only () {
15+ MCPP_INHERIT_CONFIG=0 MCPP_INHERIT_SUBOS=0 source " $( dirname " $0 " ) /_inherit_toolchain.sh"
16+ }
1417
15- # Pre-install both 15 and 16 with different invocation forms.
16- " $MCPP " toolchain install gcc 15 > " $TMP /inst1.log" 2>&1 || {
17- cat " $TMP /inst1.log" ; echo " install 'gcc 15' failed" ; exit 1; }
18- grep -q ' 15.1.0' " $TMP /inst1.log" || {
19- cat " $TMP /inst1.log" ; echo " partial '15' didn't resolve to 15.1.0" ; exit 1; }
18+ configure_e2e_mirror () {
19+ if [[ -n " ${MCPP_E2E_TOOLCHAIN_MIRROR:- } " ]]; then
20+ " $MCPP " self config --mirror " $MCPP_E2E_TOOLCHAIN_MIRROR " > " $TMP /mirror.log" 2>&1 || {
21+ cat " $TMP /mirror.log"
22+ echo " failed to configure e2e mirror"
23+ exit 1
24+ }
25+ fi
26+ }
2027
21- " $MCPP " toolchain install gcc@16 > " $TMP /inst2.log " 2>&1 || {
22- cat " $TMP /inst2.log " ; echo " install 'gcc@16' failed " ; exit 1 ; }
23- grep -q ' 16.1.0 ' " $TMP /inst2.log " || {
24- cat " $TMP /inst2.log " ; echo " partial '@16' didn't resolve to 16.1.0 " ; exit 1 ; }
28+ # ─── Section 1: dual-form + partial-version toolchain commands ─────────
29+ export MCPP_HOME= " $TMP /h1 "
30+ inherit_payloads_only
31+ configure_e2e_mirror
2532
26- # Both versions should appear in `list`.
33+ # Reuse the CI-prepared gcc payload. The full install path is covered by
34+ # 26_toolchain_management.sh; this test focuses on partial/default parsing
35+ # without redownloading large toolchain archives.
2736out=$( " $MCPP " toolchain list 2>&1 )
28- [[ " $out " == * " gcc" * " 15.1.0" * ]] || { echo " gcc 15.1.0 missing from list:" ; echo " $out " ; exit 1; }
2937[[ " $out " == * " gcc" * " 16.1.0" * ]] || { echo " gcc 16.1.0 missing from list:" ; echo " $out " ; exit 1; }
3038
3139# `default gcc 16` (positional) should pick highest 16.x.y.
@@ -34,17 +42,18 @@ out=$("$MCPP" toolchain list 2>&1)
3442grep -q ' gcc@16.1.0' " $TMP /def1.log" || {
3543 cat " $TMP /def1.log" ; echo " default 'gcc 16' didn't resolve to 16.1.0" ; exit 1; }
3644
37- # `default gcc@15 ` (@-form) should switch to 15 .1.0.
38- " $MCPP " toolchain default gcc@15 > " $TMP /def2.log" 2>&1 || {
39- cat " $TMP /def2.log" ; echo " default 'gcc@15 ' failed" ; exit 1; }
40- grep -q ' gcc@15 .1.0' " $TMP /def2.log" || {
41- cat " $TMP /def2.log" ; echo " default 'gcc@15 ' didn't resolve to 15 .1.0" ; exit 1; }
45+ # `default gcc@16 ` (@-form) should also resolve to 16 .1.0.
46+ " $MCPP " toolchain default gcc@16 > " $TMP /def2.log" 2>&1 || {
47+ cat " $TMP /def2.log" ; echo " default 'gcc@16 ' failed" ; exit 1; }
48+ grep -q ' gcc@16 .1.0' " $TMP /def2.log" || {
49+ cat " $TMP /def2.log" ; echo " default 'gcc@16 ' didn't resolve to 16 .1.0" ; exit 1; }
4250
4351# ─── Section 2: first-run auto-install ──────────────────────────────────
4452# Brand-new MCPP_HOME, brand-new package with no [toolchain] declared —
4553# `mcpp build` should auto-install the canonical default (musl-gcc 15.1
4654# for portable static binaries) + use it. Output should be a static ELF.
4755export MCPP_HOME=" $TMP /h2"
56+ configure_e2e_mirror
4857mkdir -p " $TMP /proj"
4958cd " $TMP /proj"
5059" $MCPP " new hello > /dev/null
0 commit comments