Skip to content

Commit 077375c

Browse files
committed
test: read a build program's output directory from resolution.json
mcpp 2026.10.10.1 gives each configuration and package its own build-program output directory (`target/.build-mcpp/out/<configuration>/<package>`) and records it as the root package's `outDir` in resolution.json (mcpp#778, design 2026-10-10 §4). The checks that named `target/.build-mcpp/out` read it through tests/out-dir.sh, which falls back to that path for an engine that records none, so the collection measures the same on 2026.10.1.3.
1 parent e4734b8 commit 077375c

5 files changed

Lines changed: 50 additions & 30 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ jobs:
253253
# from one that does not; without the guard this is
254254
# `namespace default {` and the generated file does not parse.
255255
grep -q '^namespace default_ {' \
256-
target/.build-mcpp/out/spirv/shader_app.shaders.cppm \
256+
$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/shader_app.shaders.cppm \
257257
|| { echo "FAIL: the keyword directory did not get its trailing underscore"
258-
grep -n namespace target/.build-mcpp/out/spirv/shader_app.shaders.cppm
258+
grep -n namespace $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/shader_app.shaders.cppm
259259
exit 1; }
260260
# The point of the surface: a consumer names no generated file.
261261
if grep -rn 'scale_comp\.h\|\.inc"' src/; then
@@ -271,10 +271,10 @@ jobs:
271271
# manifest directory's leaf -- which is what this rule did before mcpp
272272
# 2026.9.7.1 gave build programs `mcpp::package_name()` -- would write
273273
# `spirv_module_consumer.shaders.cppm` and this test would find no file.
274-
iface=target/.build-mcpp/out/spirv/shader_app.shaders.cppm
274+
iface=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/shader_app.shaders.cppm
275275
test -f "$iface" || {
276276
echo "FAIL: no module interface at $iface"
277-
find target/.build-mcpp/out/spirv -name '*.cppm' -print
277+
find $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv -name '*.cppm' -print
278278
exit 1; }
279279
grep -q '^export module shader_app.shaders;' "$iface"
280280
# The interface must name no standard-library type: one that does
@@ -300,7 +300,7 @@ jobs:
300300
tar -xzf shaderc.tar.gz
301301
rm -rf target
302302
MCPP_GLSLC="$PWD/shaderc-2026.3/bin/glslc" "$MCPP" build
303-
test -f target/.build-mcpp/out/spirv/scale_comp.inc
303+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/scale_comp.inc
304304
MCPP_GLSLC="$PWD/shaderc-2026.3/bin/glslc" "$MCPP" run | tee run-glslc.log
305305
grep -q '^magic=07230203' run-glslc.log
306306
rm -rf shaderc.tar.gz shaderc-2026.3
@@ -339,7 +339,7 @@ jobs:
339339
# TWO declarations, and the directory is in the second one's name.
340340
# A build that collapsed them would also produce a working binary, so
341341
# the criterion is the generated names rather than the run.
342-
d=target/.build-mcpp/out/spirv
342+
d=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv
343343
find "$d" -name '*.h' | sort | sed 's/^/ /'
344344
grep -rq 'scale_comp_spv' "$d" || {
345345
echo "FAIL: the top-level shader lost its declaration"; exit 1; }
@@ -385,7 +385,7 @@ jobs:
385385
grep -q '^all ok' run.log
386386
# Neither artefact is written by hand.
387387
test ! -f include/island_interface.kernels.h
388-
d=target/.build-mcpp/out/island
388+
d=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/island
389389
grep -q 'extern "C" {' "$d/island_interface.kernels.h"
390390
# THE MODULE NAME AND THE NAMESPACE ARE ONE IDENTIFIER PATH, which is
391391
# the rule docs/42 states for both lanes and the one this generator
@@ -515,7 +515,7 @@ jobs:
515515
- name: the same boundary and the same names, from the half the build selected
516516
working-directory: tests/island-interface
517517
run: |
518-
d=target/.build-mcpp/out/island
518+
d=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/island
519519
cp "$d/island_interface.kernels.cppm" /tmp/device-leg.cppm
520520
rm -rf target
521521
"$MCPP" build --no-accel > cpu.log 2>&1 || {
@@ -538,7 +538,7 @@ jobs:
538538
- name: reorganising a root that does not supply the shape renames nothing
539539
working-directory: tests/island-interface
540540
run: |
541-
d=target/.build-mcpp/out/island
541+
d=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/island
542542
cp "$d/island_interface.kernels.cppm" /tmp/before-move.cppm
543543
mkdir -p src/cpu/deep && mv src/cpu/ops.c src/cpu/deep/ops.c
544544
rm -rf target
@@ -562,7 +562,7 @@ jobs:
562562
- name: a new island file reaches the boundary with nothing else touched
563563
working-directory: tests/island-interface
564564
run: |
565-
d=target/.build-mcpp/out/island
565+
d=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/island
566566
rm -rf target && "$MCPP" build > base.log 2>&1
567567
before=$(grep -c '^using ::' "$d/island_interface.kernels.cppm")
568568
mkdir -p src/kernels/audio
@@ -781,16 +781,16 @@ jobs:
781781
grep -q '^all ok' run.log
782782
# The bytes are a section, so the compiler never saw a C array: the
783783
# payload is a bare `.spv` and an `.S` names it with `.incbin`.
784-
test -f target/.build-mcpp/out/spirv/scale_comp.spv
785-
test -f target/.build-mcpp/out/spirv/spirv_object_storage.shaders.payload.S
786-
grep -q '\.incbin' target/.build-mcpp/out/spirv/spirv_object_storage.shaders.payload.S
787-
if ls target/.build-mcpp/out/spirv/*.inc >/dev/null 2>&1; then
784+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/scale_comp.spv
785+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/spirv_object_storage.shaders.payload.S
786+
grep -q '\.incbin' $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/spirv_object_storage.shaders.payload.S
787+
if ls $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/*.inc >/dev/null 2>&1; then
788788
echo "FAIL: object storage still produced a C initialiser list"
789789
exit 1
790790
fi
791791
# `pCode` wants four-byte alignment and a section directive alone does
792792
# not promise it.
793-
grep -q '\.balign 4' target/.build-mcpp/out/spirv/spirv_object_storage.shaders.payload.S
793+
grep -q '\.balign 4' $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/spirv_object_storage.shaders.payload.S
794794
echo "ok: the payload is a section, not generated source"
795795
796796
- name: rules-spirv with sidecar storage
@@ -800,7 +800,7 @@ jobs:
800800
"$MCPP" run | tee run.log
801801
grep -q '^magic=07230203' run.log
802802
grep -q '^all ok' run.log
803-
test -f target/.build-mcpp/out/spirv/scale_comp.spv
803+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/scale_comp.spv
804804
# THE REVERSE LEG, AND IT IS THE POINT OF THIS STORAGE. The accessor
805805
# opens a path relative to the working directory, so the program finds
806806
# its shaders from the package root and must not from anywhere else.
@@ -1001,7 +1001,7 @@ jobs:
10011001
exit 1
10021002
fi
10031003
grep -q '^export module slang_consumer.shaders;' \
1004-
target/.build-mcpp/out/slang/slang_consumer.shaders.cppm
1004+
$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/slang/slang_consumer.shaders.cppm
10051005
echo "ok: a Slang shader reached through the same surface as a GLSL one"
10061006
10071007
# THE NEGATIVE LEG. A `per_file` key that names no shader must refuse the
@@ -1034,7 +1034,7 @@ jobs:
10341034
"$MCPP" run | tee run.log
10351035
grep -q '^magic=07230203' run.log
10361036
grep -q '^all ok' run.log
1037-
test -f target/.build-mcpp/out/slang/scale.spv
1037+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/slang/scale.spv
10381038
if grep -q 'source-embed' target/*/*/build.ninja; then
10391039
echo "FAIL: sidecar storage still asked slangc to embed"; exit 1
10401040
fi
@@ -1115,7 +1115,7 @@ jobs:
11151115
# `key_kind::relative_path` and `element::word32` -- and `head -1`
11161116
# picked one by directory order, so the check was asserting about a
11171117
# file nothing chose.
1118-
mapfile -t headers < <(find target/.build-mcpp/out -name '*.h' | sort)
1118+
mapfile -t headers < <(find $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh") -name '*.h' | sort)
11191119
[ "${#headers[@]}" -gt 0 ] || { echo "FAIL: no generated header"; exit 1; }
11201120
echo "checking ${#headers[@]} generated header(s)"
11211121
for h in "${headers[@]}"; do
@@ -1424,7 +1424,7 @@ jobs:
14241424
working-directory: tests/hip-consumer
14251425
run: |
14261426
"$MCPP" build
1427-
test -f target/.build-mcpp/out/saxpy.hip.o
1427+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/saxpy.hip.o
14281428
"$MCPP" build --no-accel
14291429
"$MCPP" run --no-accel | tee run.log
14301430
grep -q '^12 24 36 48' run.log
@@ -1437,8 +1437,8 @@ jobs:
14371437
working-directory: tests/sycl-consumer
14381438
run: |
14391439
"$MCPP" build
1440-
test -f target/.build-mcpp/out/saxpy.sycl.o
1441-
test -f target/.build-mcpp/out/sycl_device_link.o
1440+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/saxpy.sycl.o
1441+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/sycl_device_link.o
14421442
"$MCPP" build --no-accel
14431443
"$MCPP" run --no-accel | tee run.log
14441444
grep -q '^12 24 36 48' run.log
@@ -1536,9 +1536,9 @@ jobs:
15361536
working-directory: tests/multi-rule-consumer
15371537
run: |
15381538
"$MCPP" build
1539-
test -f target/.build-mcpp/out/saxpy.cu.o
1540-
test -f target/.build-mcpp/out/spirv/scale_comp.h
1541-
test ! -f target/.build-mcpp/out/scale.cu.o
1539+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/saxpy.cu.o
1540+
test -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/spirv/scale_comp.h
1541+
test ! -f $(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/scale.cu.o
15421542
"$MCPP" run --no-accel | tee run.log
15431543
grep -q '^magic=(no shader in this build)' run.log
15441544
grep -q '^12 24 36 48' run.log
@@ -1980,7 +1980,7 @@ jobs:
19801980
"$MCPP" run | tee run.log
19811981
grep -q '^out\[0\]=6 out\[1\]=12 out\[2\]=18 out\[3\]=24' run.log
19821982
grep -q '^all ok' run.log
1983-
d=target/.build-mcpp/out/island
1983+
d=$(sh "$GITHUB_WORKSPACE/tests/out-dir.sh")/island
19841984
# The namespace is the path from the layout root to the file, so this
19851985
# is the assertion a separator mistake fails.
19861986
grep -q '^export namespace island_interface::kernels {' \

‎tests/apk-consumer-libraries/check-apk-libraries.sh‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ grep -q "android.permission.VIBRATE" libs-perm1.log || fail "the library's permi
110110
grep -q "android.permission.WAKE_LOCK" libs-perm1.log || fail "the archive's permission was not merged" libs-perm1.log
111111
grep -q "android.permission.CAMERA" libs-perm1.log && fail "the permission the application removed is in the package" libs-perm1.log
112112
grep -q 'org.mcpp.apklibs.lib.FLAVOUR' libs-xml1.log || fail "the library's meta-data was not merged" libs-xml1.log
113-
grep -q 'tools' target/.build-mcpp/out/dist-apk/AndroidManifest.xml \
114-
&& fail "the merged manifest still carries a tools: attribute" target/.build-mcpp/out/dist-apk/AndroidManifest.xml
113+
merged="$(sh "$(dirname "$0")/../out-dir.sh")/dist-apk/AndroidManifest.xml"
114+
grep -q 'tools' "$merged" \
115+
&& fail "the merged manifest still carries a tools: attribute" "$merged"
115116
echo "ok: the manifest merges the library's and the archive's permissions and meta-data, drops the removed one, and keeps no tools: attribute"
116117

117118
"$JAR" tf "$apk" > libs-list1.log

‎tests/apk-consumer/check-apk-features.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ rm -rf target
3535
unset APK_CONSUMER_TEMPLATE APK_CONSUMER_LEVEL1 || true
3636
"$MCPP" build --target "$TARGET" > build-a.log 2>&1 || fail "build failed" build-a.log
3737
"$MCPP" pack --format apk --target "$TARGET" > pack-a.log 2>&1 || fail "pack failed" pack-a.log
38-
MANIFEST=target/.build-mcpp/out/dist-apk/AndroidManifest.xml
38+
MANIFEST="$(sh "$(dirname "$0")/../out-dir.sh")/dist-apk/AndroidManifest.xml"
3939
cmp fixtures/expected-manifest-level0-0.8.0.xml "$MANIFEST" \
4040
|| fail "level 0's manifest is not byte-identical to 0.8.0's" "$MANIFEST" fixtures/expected-manifest-level0-0.8.0.xml
4141
echo "ok: level 0 with no template renders 0.8.0's manifest byte-for-byte"

‎tests/metal-consumer/check-metal.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ reading metal-version "$(xcrun --sdk macosx metal --version 2>&1 | head -1)"
4545
# ── 1. three libraries beside the program ─────────────────────────────────
4646
echo "== 1. the shaders compile to Metal libraries the program finds =="
4747
"$MCPP" build > metal-build.log 2>&1 || fail "mcpp build failed" metal-build.log
48-
gen=target/.build-mcpp/out/metal
48+
gen="$(sh "$(dirname "$0")/../out-dir.sh")/metal"
4949
for name in scale tint tint_red; do
5050
[ -f "$gen/$name.air" ] || fail "no $gen/$name.air" metal-build.log
5151
[ -f "$gen/$name.metallib" ] || fail "no $gen/$name.metallib" metal-build.log

‎tests/out-dir.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
# Where `mcpp::out_dir()` pointed in the newest build of the package in the
3+
# current directory. mcpp 2026.10.10.1 and later give each configuration its own
4+
# output directory and record it as the root package's `outDir` in
5+
# resolution.json; earlier engines use target/.build-mcpp/out.
6+
r=$(ls -t target/*/*/resolution.json 2>/dev/null | head -1)
7+
if [ -n "$r" ]; then
8+
py=$(command -v python3 || command -v python)
9+
d=$("$py" -c 'import json, sys
10+
for p in json.load(open(sys.argv[1])).get("graph", {}).get("packages", []):
11+
if p.get("root"):
12+
print(p.get("outDir", ""))
13+
break' "$r" 2>/dev/null)
14+
if [ -n "$d" ]; then
15+
echo "$d"
16+
exit 0
17+
fi
18+
fi
19+
echo "target/.build-mcpp/out"

0 commit comments

Comments
 (0)