Skip to content

Commit 51b66ce

Browse files
committed
tests: the new fixtures write host spellings into the manifests they generate
`00_fixture_path_hygiene.sh` caught three of them: 873 and 874 interpolated `$work` into a `[build-dependencies]` path, and 875 wrote the toolchain root, the linker wrapper and a driver straight from shell variables. MSYS rewrites paths in argv and the environment but not in file content, so on Windows a native mcpp would read `/d/a/...` and resolve it against the current drive -- the failure the helper's own header records costing a day. Each path now goes through `host_path`, and the assertions that compare mcpp's output compare host spellings too.
1 parent 136eb2a commit 51b66ce

3 files changed

Lines changed: 23 additions & 11 deletions

File tree

‎tests/e2e/873_payload_overrides.sh‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ set -e
1313

1414
MCPP="${MCPP:-mcpp}"
1515
work="$(mktemp -d)"
16+
# A path written INTO a manifest goes through host_path (see _host_path.sh).
17+
source "$(dirname "$0")/_host_path.sh"
18+
work_HOST="$(host_path "$work")"
1619
trap 'rm -rf "$work"' EXIT
1720
export NO_COLOR=1
1821

@@ -48,7 +51,7 @@ name = "app"
4851
version = "0.1.0"
4952
5053
[build-dependencies.e2e]
51-
plug = { path = "$work/plug", features = ["tools-x"], host-module = true }
54+
plug = { path = "$work_HOST/plug", features = ["tools-x"], host-module = true }
5255
5356
[targets.app]
5457
kind = "bin"
@@ -83,9 +86,9 @@ grep -q "mcpp-e2e-absent-tool" <<<"$out" || fail "the refusal does not name the
8386
# The environment variable.
8487
out="$(MCPP_XLINGS_OVERRIDE_XIM_MCPP_E2E_ABSENT_TOOL="$work/opt/bin/absent-tool" probe build)"
8588
grep -q "Finished" <<<"$out" || fail "an env override still needed the payload"
86-
grep -q "Using xim:mcpp-e2e-absent-tool ← $work/opt/bin/absent-tool \[custom · env MCPP_XLINGS_OVERRIDE_XIM_MCPP_E2E_ABSENT_TOOL\]" <<<"$out" \
89+
grep -q "Using xim:mcpp-e2e-absent-tool ← $work_HOST/opt/bin/absent-tool \[custom · env MCPP_XLINGS_OVERRIDE_XIM_MCPP_E2E_ABSENT_TOOL\]" <<<"$out" \
8790
|| fail "no Using line naming the env override"
88-
grep -q "dir=$work/opt source=override program=$work/opt/bin/absent-tool" <<<"$out" \
91+
grep -q "dir=$work_HOST/opt source=override program=$work_HOST/opt/bin/absent-tool" <<<"$out" \
8992
|| fail "the build program did not receive the override (root, source, program)"
9093
grep -q "Finished .* · custom: xim:mcpp-e2e-absent-tool" <<<"$out" || fail "Finished does not summarise the source"
9194

‎tests/e2e/874_payload_on_request.sh‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ set -e
1111

1212
MCPP="${MCPP:-mcpp}"
1313
work="$(mktemp -d)"
14+
# A path written INTO a manifest goes through host_path (see _host_path.sh).
15+
source "$(dirname "$0")/_host_path.sh"
16+
work_HOST="$(host_path "$work")"
1417
trap 'rm -rf "$work"' EXIT
1518
export NO_COLOR=1
1619

@@ -44,7 +47,7 @@ name = "app"
4447
version = "0.1.0"
4548
4649
[build-dependencies.e2e]
47-
plug = { path = "$work/plug", features = ["tools-x"], host-module = true }
50+
plug = { path = "$work_HOST/plug", features = ["tools-x"], host-module = true }
4851
4952
[targets.app]
5053
kind = "bin"

‎tests/e2e/875_toolchain_by_path.sh‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ if [[ ! -x "$LLVM_ROOT/bin/clang++" ]]; then
1616
echo "SKIP: no llvm payload installed ($LLVM_ROOT)"; exit 0
1717
fi
1818
work="$(mktemp -d)"
19+
# Paths written INTO a manifest go through host_path (see _host_path.sh).
20+
source "$(dirname "$0")/_host_path.sh"
1921
trap 'rm -rf "$work"' EXIT
2022
export NO_COLOR=1
2123

2224
T="$work/llvm"
25+
T_HOST="$(host_path "$T")"
2326
mkdir -p "$T/bin"
2427
for f in "$LLVM_ROOT"/bin/*; do
2528
case "$f" in *.cfg) ;; *) ln -s "$f" "$T/bin/" ;; esac
@@ -28,35 +31,37 @@ for d in include lib share libexec; do [ -e "$LLVM_ROOT/$d" ] && ln -s "$LLVM_RO
2831
# A linker stated by role, as a wrapper the test can change in place.
2932
printf '#!/bin/sh\nexec "%s/bin/ld.lld" "$@"\n' "$LLVM_ROOT" > "$work/ld-wrapper"
3033
chmod +x "$work/ld-wrapper"
34+
wrapper_HOST="$(host_path "$work/ld-wrapper")"
3135

3236
mkdir -p "$work/app/src"
3337
cat > "$work/app/src/main.cpp" <<'CPP'
3438
#include <cstdio>
3539
int main() { std::puts("built by a toolchain named by path"); return 0; }
3640
CPP
3741
write_manifest() {
42+
local root_HOST; root_HOST="$(host_path "$1")"
3843
cat > "$work/app/mcpp.toml" <<TOML
3944
[package]
4045
name = "app"
4146
version = "0.1.0"
4247
4348
[toolchain]
44-
default = { path = "$1"$2 }
49+
default = { path = "$root_HOST"$2 }
4550
TOML
4651
}
4752
cd "$work/app"
4853
fail() { echo "FAIL: $*"; echo "----"; echo "$out"; exit 1; }
4954

50-
write_manifest "$T" ', launcher = "/usr/bin/env", tools = { ld = "'"$work/ld-wrapper"'" }'
55+
write_manifest "$T" ', launcher = "/usr/bin/env", tools = { ld = "'"$wrapper_HOST"'" }'
5156
rm -rf target
5257
out="$("$MCPP" build 2>&1)" || fail "the build failed"
53-
grep -q "Using toolchain clang .* ← $T \[custom · mcpp.toml:[0-9]*\]" <<<"$out" || fail "no Using line for the toolchain"
58+
grep -q "Using toolchain clang .* ← $T_HOST \[custom · mcpp.toml:[0-9]*\]" <<<"$out" || fail "no Using line for the toolchain"
5459
grep -q "Finished .* · custom: toolchain" <<<"$out" || fail "Finished does not summarise the source"
5560
run="$(./target/*/*/bin/app)"
5661
[[ "$run" == "built by a toolchain named by path" ]] || fail "the program did not run: $run"
5762
ninja="$(cat target/*/*/build.ninja)"
58-
grep -q "^cxx *= /usr/bin/env $T/bin/clang++" <<<"$ninja" || fail "the launcher does not prefix the compiler"
59-
grep -q -- "--ld-path=$work/ld-wrapper" <<<"$ninja" || fail "the stated linker is not used"
63+
grep -q "^cxx *= /usr/bin/env $T_HOST/bin/clang++" <<<"$ninja" || fail "the launcher does not prefix the compiler"
64+
grep -q -- "--ld-path=$wrapper_HOST" <<<"$ninja" || fail "the stated linker is not used"
6065
[[ -z "$(find "$T/" -maxdepth 2 -name '*.cfg' -print -quit)" ]] || fail "mcpp wrote a cfg into the tree"
6166

6267
# The fast path serves an unchanged tree, and declines once a program of it changed.
@@ -77,7 +82,8 @@ out="$(MCPP_TOOLCHAIN="path:$T" "$MCPP" build 2>&1)" || fail "MCPP_TOOLCHAIN=pat
7782
grep -q "\[custom · env MCPP_TOOLCHAIN\]" <<<"$out" || fail "the env-named toolchain is not reported"
7883

7984
# A stated family the drivers contradict is refused.
80-
write_manifest "$T" ', family = "gcc", tools = { cxx = "'"$T/bin/clang++"'" }'
85+
driver_HOST="$(host_path "$T/bin/clang++")"
86+
write_manifest "$T" ', family = "gcc", tools = { cxx = "'"$driver_HOST"'" }'
8187
rm -rf target
8288
out="$("$MCPP" build 2>&1 || true)"
8389
grep -q 'stated as family "gcc"' <<<"$out" || fail "a contradicting family was accepted"
@@ -96,7 +102,7 @@ gcc_base="$HOME/.mcpp/registry/data/xpkgs/xim-x-gcc"
96102
[[ -d "$gcc_base" && -n "${USERPROFILE:-}" ]] || true
97103
gcc_ver="$(ls -1 "$gcc_base" 2>/dev/null | grep -E '^[0-9]+(\.[0-9]+)*$' | sort -V | tail -1)"
98104
if [[ -n "$gcc_ver" && -x "$gcc_base/$gcc_ver/bin/g++" ]]; then
99-
write_manifest "$gcc_base/$gcc_ver" ', tools = { ld = "'"$work/ld-wrapper"'" }'
105+
write_manifest "$gcc_base/$gcc_ver" ', tools = { ld = "'"$wrapper_HOST"'" }'
100106
rm -rf target
101107
out="$("$MCPP" build 2>&1 || true)"
102108
grep -q "this is a gcc toolchain" <<<"$out" \

0 commit comments

Comments
 (0)