Skip to content

Commit 401462a

Browse files
committed
fix(e2e): update tests for 0.0.10 changes
- 05_errors.sh: remove naming prefix enforcement test (relaxed in 0.0.10) - 12_add_command.sh: mcpplibs is now default ns, no subtable header - 21_ninja_dyndep.sh: P1 per-file dyndep replaces global build.ninja.dd
1 parent 13e885b commit 401462a

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

tests/e2e/05_errors.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ EOF
5555
out=$("$MCPP" build 2>&1) && { echo "expected failure"; exit 1; }
5656
[[ "$out" == *"header units"* ]] || { echo "wrong error: $out"; exit 1; }
5757

58-
# 5. Naming violation (public package without prefix)
58+
# 5. Module naming is the library author's choice (0.0.10+).
59+
# No prefix enforcement — this test just verifies we REMOVED the check.
5960
cd "$TMP"
60-
"$MCPP" new bad-naming > /dev/null
61-
cd bad-naming
62-
sed -i 's/name = "bad-naming"/name = "myorg.badname"/' mcpp.toml
61+
"$MCPP" new naming-ok > /dev/null
62+
cd naming-ok
63+
sed -i 's/name = "naming-ok"/name = "myorg.something"/' mcpp.toml
6364
cat > src/foo.cppm <<'EOF'
64-
export module wrongprefix;
65+
export module differentprefix;
6566
import std;
6667
EOF
67-
out=$("$MCPP" build 2>&1) && { echo "expected failure"; exit 1; }
68-
[[ "$out" == *"prefixed by package name"* ]] || { echo "wrong error: $out"; exit 1; }
68+
# This should succeed now (no naming violation error).
69+
"$MCPP" build > /dev/null 2>&1 || { echo "expected success but build failed"; exit 1; }
6970

7071
echo "OK"

tests/e2e/12_add_command.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@ header_count=$(grep -cE '^\[dependencies\]$' mcpp.toml)
2525
[[ "$header_count" == "1" ]] || { cat mcpp.toml; echo "[dependencies] header duplicated"; exit 1; }
2626
grep -qE '^another = "0\.2\.0"$' mcpp.toml || { cat mcpp.toml; echo "another not set"; exit 1; }
2727

28-
# (3) Namespaced dep via `<ns>:<name>@<ver>` lands in [dependencies.<ns>].
28+
# (3) Default-ns dep via `<ns>:<name>@<ver>` where ns is the default (mcpplibs).
29+
# Since 0.0.10+ default namespace is "mcpplibs", this lands as a bare key
30+
# under [dependencies], NOT in [dependencies.mcpplibs].
2931
"$MCPP" add mcpplibs:cmdline@0.0.2 > /dev/null
30-
grep -qE '^\[dependencies\.mcpplibs\]$' mcpp.toml || { cat mcpp.toml; echo "missing [dependencies.mcpplibs] section"; exit 1; }
31-
grep -qE '^cmdline = "0\.0\.2"$' mcpp.toml || { cat mcpp.toml; echo "cmdline entry missing"; exit 1; }
32+
grep -qE '^cmdline = "0\.0\.2"$' mcpp.toml || { cat mcpp.toml; echo "cmdline entry missing"; exit 1; }
3233

33-
# (4) A second package in the same namespace — appends under the existing subtable.
34+
# (4) A second default-ns package — also goes under [dependencies].
3435
"$MCPP" add mcpplibs:templates@0.0.1 > /dev/null
35-
ns_count=$(grep -cE '^\[dependencies\.mcpplibs\]$' mcpp.toml)
36-
[[ "$ns_count" == "1" ]] || { cat mcpp.toml; echo "[dependencies.mcpplibs] header duplicated"; exit 1; }
3736
grep -qE '^templates = "0\.0\.1"$' mcpp.toml || { cat mcpp.toml; echo "templates entry missing"; exit 1; }
3837

3938
# (5) Legacy dotted form is still accepted on input — written out as namespaced subtable.

tests/e2e/21_ninja_dyndep.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,19 @@ if [[ "$out_static" != "$out_dyndep" ]]; then
6767
exit 1
6868
fi
6969

70-
# Dyndep mode must have created the dyndep file.
71-
[[ -f "${triple}${fp_dir}/build.ninja.dd" ]] || {
72-
echo "FAIL: build.ninja.dd not produced under MCPP_NINJA_DYNDEP=1"
70+
# P1 (0.0.10+): per-file dyndep — each .cppm gets its own .dd file.
71+
dd_files=$(find "${triple}${fp_dir}" -name '*.ddi.dd' | wc -l)
72+
[[ "$dd_files" -gt 0 ]] || {
73+
echo "FAIL: no per-file .ddi.dd files produced under MCPP_NINJA_DYNDEP=1"
7374
exit 1
7475
}
7576

76-
# Dyndep mode must have emitted scan rules.
77+
# Dyndep mode must have emitted scan + per-file dyndep rules.
7778
grep -q '^rule cxx_scan' ${triple}${fp_dir}/build.ninja || {
7879
echo "FAIL: build.ninja missing cxx_scan rule"; exit 1; }
79-
grep -q '^rule cxx_collect' ${triple}${fp_dir}/build.ninja || {
80-
echo "FAIL: build.ninja missing cxx_collect rule"; exit 1; }
81-
grep -q ' dyndep = build.ninja.dd' ${triple}${fp_dir}/build.ninja || {
80+
grep -q '^rule cxx_dyndep' ${triple}${fp_dir}/build.ninja || {
81+
echo "FAIL: build.ninja missing cxx_dyndep rule"; exit 1; }
82+
grep -q ' dyndep = ' ${triple}${fp_dir}/build.ninja || {
8283
echo "FAIL: compile edges missing dyndep ="; exit 1; }
8384

8485
# Static mode must NOT have those rules (sanity).
@@ -91,12 +92,11 @@ ddi=$(find target -name '*.cppm.ddi' | head -1)
9192
grep -q '"rules"' "$ddi" || { echo "FAIL: .ddi missing rules"; exit 1; }
9293
grep -q '"primary-output"' "$ddi" || { echo "FAIL: .ddi missing primary-output"; exit 1; }
9394

94-
# build.ninja.dd content sanity.
95-
ddep="${triple}${fp_dir}/build.ninja.dd"
95+
# Per-file .dd content sanity.
96+
ddep=$(find "${triple}${fp_dir}" -name '*.ddi.dd' | head -1)
97+
[[ -n "$ddep" ]] || { echo "FAIL: no .ddi.dd file"; exit 1; }
9698
grep -q 'ninja_dyndep_version = 1' "$ddep" || {
9799
echo "FAIL: dyndep file missing version header"; exit 1; }
98-
grep -q 'gcm.cache/myapp.lib-greet.gcm' "$ddep" || {
99-
echo "FAIL: dyndep file missing partition BMI"; cat "$ddep"; exit 1; }
100100

101101
# Incremental: re-run dyndep build → must be noop.
102102
out2=$(MCPP_NINJA_DYNDEP=1 "$MCPP" build 2>&1)

0 commit comments

Comments
 (0)