diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e148df..f13c3279 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ Sections dated before 2026-09-19 predate the cycle and stay as they are. Named m `docs/RELEASE-PROCESS.md` §8. ## Unreleased +- process(tests): **golden mxcli v0.32 module tables for the three module parsers**: v0.32 adds Version and Type columns after Source and a "(N modules)" / "(N pages)" trailer, and every capture in `fixtures/show-modules/` and `fixtures/rehost-list-modules/` predated both. New verbatim `show modules`, `list modules` and `SHOW PAGES IN` captures, and `test-show-modules-v032.sh` asserts `own-modules.awk` (own and marketplace), `page-scope.sh` and `review-module.sh`'s module-exists grep on them. All three already read v0.32 correctly; this pins it — real-mxcli field run (mxcli v0.32.0-374, blank Mendix 11.8.0 app + a Sales module) +- fix(describe-baseline): **an untagged mxcli build still stamps its version**: `mxcli_version` kept only a `vX.Y.Z`, and a `make build` on a shallow clone prints `mxcli version 591bcd7 (…)`, so no `-- baseline-mxcli:` line was written and a later mxcli upgrade read as DRIFT instead of RESTAMP. The commit word is now recorded when there is no tag. Fixture `test-describe-baseline.sh` on verbatim untagged and v0.32.0-374 `--version` captures — real-mxcli field run (mxcli source build v0.32.0-374) +- fix(init): **the closing leak-guard line names the denylist init actually wrote**: with `MXTK_LEAKGUARD_DENYFILE` set, init registered the project name in that file and then said "no `/.leakguard-deny` found on this machine. Create it", because the nudge tested the default path. Fixture `test-init-leakguard-nudge.sh` — real-mxcli field run (scaffold of a blank Mendix 11.8.0 app) +- fix(exec): **a rolled-back exec no longer leaves the new module's source folder behind**: the snapshot covers the `.mpr` and `mprcontents/` only, and the gate's own `mx check` generates `themesource//` (five files plus an empty `public/` on MxBuild 11.8.0) for a module the script created, so after a failed gate restored the model the folder stayed, untracked, for a module the model no longer had — one `git add -A` from being committed. After a successful auto-restore, `exec.sh` now moves the source folders of the modules this run created, read from mxcli's own exec output (`Created module: X`; an existing module prints `Module 'X' already exists` and is never touched) — `themesource/`, `javasource/`, `javascriptsource/` or ``, mxcli's own naming — into the snapshot (`.mpr-snapshots//stray-module-dirs/`) and prints where, when they did not exist at snapshot time and hold no tracked file. Any other folder, including one another session creates during the exec window, is left alone (single tree and `app/`). Fixture `test-exec-rollback-module-dirs.sh` on the verbatim generated files — real-mxcli field run (mxcli v0.32.0-374, MxBuild 11.8.0, blank Mendix 11.8.0 app), independent review of #823 +- fix(exec, _common): **the mxbuild auto-download works when `MXCLI_HOME` points elsewhere**: the toolkit looks for the cache at `${MXCLI_HOME:-~/.mxcli}`, but mxcli itself always caches under `~/.mxcli` (`os.UserHomeDir`), so `exec.sh` downloaded, printed `MxBuild ready: …`, then reported "no runnable mxbuild was found afterwards" and refused the exec. `mxtk_ensure_mxbuild` now takes the path mxcli reports when re-discovery finds nothing (same version only) and says that `MXCLI_HOME` is not mxcli's. Fixture `test-mxbuild-setup-home.sh` on a verbatim `setup mxbuild` capture — real-mxcli field run (mxcli v0.32.0-374, blank Mendix 11.8.0 app) +- fix(exec): **a refused pre-exec check keeps the cause of a v0.32 reference error in the BUILD-LOG row**: mxcli v0.32 prints a reference error as two lines under `Reference errors:` (`statement 3: microflow 'X' has reference errors:` then ` - entity not found: …`) and the 🚫 row kept only the header, which names no cause. The cause line is now appended. Fixture `test-exec-check-refusal.sh` F, on a verbatim v0.32.0 capture — real-mxcli field run (mxcli v0.32.0-374, blank Mendix 11.8.0 app) - new(doctor, bug ledger): **a guard for mxcli's silent MxBuild fallback**: when the project's Mendix version is not in `~/.mxcli/mxbuild/` (and no Studio Pro of that version exists), `mxcli docker build` / `docker check` fall back to the newest cached MxBuild and print its path but no version warning (`run --local` is exact-or-refuse); `bin/doctor.sh` now warns, naming the model version, the cached ones and `./mxcli setup mxbuild -p .mpr` (`mxtk_mxbuild_cache_gap`, warning only, never changes a gate). Ledger entry `BUG-DRAFT-mxbuild-silent-version-fallback`; upstream issue not filed. — a four-app Mendix build (field run), independent review - fix(gate-check): **a fresh clone no longer FAILs Stage 3 as "stale render"**: `blueprint.html` / `process-map.html` freshness used `[ render -ot source ]`, a nanosecond mtime compare, and a checkout stamps files in directory order (`process-map.html` lands before `process-model.json`), so an unedited project read stale on every clone (reproduced: 200-wireframe checkout, 10 of 10 clones). New `bin/lib/render-fresh.sh` keeps `-ot` as the first test (a pass never flips, no git call) and, only where `-ot` would FAIL, asks git once per render (one `log`, one `status`) whether the source was committed after the render's commit; measured 0.19 s for 200 sources all `-ot`-stale on a 300-commit history (a per-source git version cost 12.9 s). Limit: a depth-1 clone cannot see a genuinely stale render. Field run: a four-app Mendix build checked out on a second machine. — a four-app Mendix build (field run), independent review - fix(test-stack-up, e2e-harness-base): **the app port follows the app's configured port, and a multi-app start is no longer pinned to 8080**: with no `APP_PORTS`, `test-stack-up.sh` puts `RUN_LOCAL_APP_PORT`, then `APP_PORT` from the `.docker/.env` beside the `.mpr` (`apps//.docker/.env`; the project-root one as fallback) first, ahead of the old fixed `8080 8081 8084` tail. A fresh `run --local` start for a model under `apps/` with no handshake and no configured port used to fall back to 8080 for every app (`--app-port 8080`); it now exits 4 naming `RUN_LOCAL_APP_PORT`. `e2e-harness-base.md` states that a PAD/Docker runtime listens on 8080 *inside* the container only. Fixtures T28–T32 added. Field run: a four-app Mendix build on 8081–8084 whose fresh start failed with every app pinned to 8080. — a four-app Mendix build (field run), independent review diff --git a/bin/init-project.sh b/bin/init-project.sh index 85671931..2f591376 100755 --- a/bin/init-project.sh +++ b/bin/init-project.sh @@ -791,12 +791,14 @@ echo "Machine preflight (bin/doctor.sh):" # three lines, never a prompt, never a failure: the denylist protects the TOOLKIT repo, and # a project scaffold must not block on it (kickoff is just the cheapest moment to remember). echo "" -if [ -f "$TOOLKIT_ROOT/.leakguard-deny" ]; then +# $DENYFILE, not $TOOLKIT_ROOT/.leakguard-deny: with MXTK_LEAKGUARD_DENYFILE set, the registration above +# wrote that file and this line then said "no …/.leakguard-deny found" (real-mxcli scaffold, 2026-11-20). +if [ -f "$DENYFILE" ]; then echo "Leak guard: if this project is for a new client, add their name (and codename) to" - echo " $TOOLKIT_ROOT/.leakguard-deny — one regex per line — and update the toolkit repo's" + echo " $DENYFILE — one regex per line — and update the toolkit repo's" echo " LEAKGUARD_DENY GitHub Actions secret to match. 30 seconds now beats a scrub later." else - echo "Leak guard: no $TOOLKIT_ROOT/.leakguard-deny found on this machine. Create it (one" + echo "Leak guard: no $DENYFILE found on this machine. Create it (one" echo " client-name regex per line, gitignored) so check-no-client-data.sh can catch client" echo " names before they reach the public toolkit repo — see that script's header." fi diff --git a/project-bin/_common.sh b/project-bin/_common.sh index 8fa01072..b3db6f08 100755 --- a/project-bin/_common.sh +++ b/project-bin/_common.sh @@ -1771,15 +1771,31 @@ mxtk_ensure_mxbuild() { fi echo "→ mxbuild not found — downloading the toolchain for this model's Mendix version" >&2 echo " ($mxcli setup mxbuild — the same download bin/doctor.sh --install runs; cached under ~/.mxcli/mxbuild/)" >&2 - if (cd "$root" && "$mxcli" setup mxbuild -p "$(basename "$mpr")" >&2); then + # mxcli always caches under its own home (~/.mxcli, os.UserHomeDir) and ignores MXCLI_HOME, which only + # the toolkit reads. So the path mxcli prints last ("MxBuild ready: ", mxcli v0.32 setup.go; capture + # in tests/wave2/fixtures/mxbuild-setup/) is taken as the answer when re-discovery under MXCLI_HOME finds + # nothing: before, a "successful" download was followed by "no runnable mxbuild found" and a refused exec. + local _sout _src _ready _vdir + _sout="$(mktemp "${TMPDIR:-/tmp}/mxbuild-setup.XXXXXX")" + (cd "$root" && "$mxcli" setup mxbuild -p "$(basename "$mpr")") 2>&1 | tee "$_sout" >&2; _src=${PIPESTATUS[0]} + _ready="$(tr -d '\r' < "$_sout" | sed -n 's/^MxBuild ready: //p' | tail -1)"; rm -f "$_sout" + if [ "$_src" -eq 0 ]; then found="$(find_mxbuild 2>/dev/null || true)" - if [ -n "$found" ] && [ -x "$found" ]; then - if [ -n "$ver" ] && ! mxtk_mxbuild_for_version "$ver" >/dev/null 2>&1; then - echo " ⚠ download finished but there is still no mxbuild for $ver — using $found; the gate will report the refusal as unverified." >&2 + if [ -n "$found" ] && [ -x "$found" ] && { [ -z "$ver" ] || mxtk_mxbuild_for_version "$ver" >/dev/null 2>&1; }; then + printf '%s\n' "$found"; return 0 + fi + if [ -n "$_ready" ] && [ -x "$_ready" ]; then + _vdir="${_ready%/modeler/mxbuild*}" + if [ -z "$ver" ] || mxtk_version_in_name "$_vdir" "$ver"; then + [ -n "${MXCLI_HOME:-}" ] && echo " note: mxcli caches under ~/.mxcli whatever MXCLI_HOME says (MXCLI_HOME=$MXCLI_HOME); using the mxbuild it reported: $_ready" >&2 + printf '%s\n' "$_ready"; return 0 fi + fi + if [ -n "$found" ] && [ -x "$found" ]; then + echo " ⚠ download finished but there is still no mxbuild for $ver — using $found; the gate will report the refusal as unverified." >&2 printf '%s\n' "$found"; return 0 fi - echo " download reported success but no runnable mxbuild was found afterwards (looked under ${MXCLI_HOME:-$HOME/.mxcli}/mxbuild/)." >&2 + echo " download reported success but no runnable mxbuild was found afterwards (looked under ${MXCLI_HOME:-$HOME/.mxcli}/mxbuild/${_ready:+ and at $_ready, the path mxcli reported})." >&2 else echo " '$mxcli setup mxbuild' failed — a blocked network or proxy is the usual cause (the download comes from the Mendix CDN)." >&2 fi diff --git a/project-bin/describe-baseline.sh b/project-bin/describe-baseline.sh index 3154da80..10eb9a93 100755 --- a/project-bin/describe-baseline.sh +++ b/project-bin/describe-baseline.sh @@ -125,7 +125,16 @@ describe_hash() { # $1 = KIND, $2 = Doc echo "sha256=$h" } # "v0.26.0" from `mxcli --version` (captured: "mxcli version v0.26.0 (2026-10-11T18:37:07Z)"). -mxcli_version() { "$MXCLI" --version 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1; } +# A build with no release tag in reach (a `make build` on a shallow clone) prints only a commit: +# "mxcli version 591bcd7 (2026-11-20T18:49:18Z)" (captured, tests/wave2/fixtures/restatement-guard/). +# That word is recorded as it is; before, nothing was stamped and an upgrade read as DRIFT. +mxcli_version() { + local line v + line="$("$MXCLI" --version 2>/dev/null | grep -m1 '^mxcli version ')" + v="$(printf '%s\n' "$line" | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1)" + [ -n "$v" ] || v="$(printf '%s\n' "$line" | awk '{ print $3 }')" + printf '%s\n' "$v" +} if [ "$CMD" = live ]; then need_mxcli || exit 3 @@ -165,7 +174,7 @@ fi need_mxcli || exit 3 KINDS="$(restated)" KEY="$(script_key "$SCRIPT")" -WAS_V="$(sed -nE 's/^[[:space:]]*--[[:space:]]*baseline-mxcli:[[:space:]]*(v[0-9.]+).*$/\1/p' "$SCRIPT" | head -1)" +WAS_V="$(sed -nE 's/^[[:space:]]*--[[:space:]]*baseline-mxcli:[[:space:]]*([^[:space:]]+).*$/\1/p' "$SCRIPT" | head -1)" NOW_V=""; [ -n "$WAS_V" ] && NOW_V="$(mxcli_version)" RC=0 while read -r doc want; do diff --git a/project-bin/exec.sh b/project-bin/exec.sh index c4a721a7..eeb3a6ce 100755 --- a/project-bin/exec.sh +++ b/project-bin/exec.sh @@ -1066,7 +1066,8 @@ if [ "$LOCK_TAKEN" != 1 ]; then echo " → Wait for the other exec to finish, then re-run. Nothing was written." exit 1 fi -trap 'mxtk_resume_watchers; exec_lock_release; [ "$_PROFILING" != 1 ] || _prof_report' EXIT +EXEC_OUT="" # never an inherited value: the EXIT trap removes it +trap 'mxtk_resume_watchers; exec_lock_release; [ -z "${EXEC_OUT:-}" ] || rm -f -- "$EXEC_OUT"; [ "$_PROFILING" != 1 ] || _prof_report' EXIT mxtk_resume_leftover "$PROJECT_ROOT" # a watcher an earlier, SIGKILLed exec.sh left stopped # 3. A raw `mxcli exec` elsewhere on the machine is NOT this project's business. The old guard @@ -1589,11 +1590,15 @@ step_done guards # Shapes are real mxcli v0.26.0 captures (tests/wave2/fixtures/exec-check-refusal/): an error # violation is "✗ [RULE]" after any warnings, in ANSI colour even when piped; a parse # failure is "- line N:M ..." under "Syntax errors found:". Rule id first, so truncation keeps it. +# v0.32 reference errors take two lines under "Reference errors:", a header ending in ":" and the +# cause as " - ..." (fixtures/exec-check-refusal/reference-v0.32.0.out); both go in the row, +# because the header alone ("microflow 'X' has reference errors:") names no cause. check_refusal_reason() { # $1 = captured check output _esc="$(printf '\033')" tr -d '\r' < "$1" 2>/dev/null | sed "s/${_esc}\[[0-9;]*m//g" | awk ' /^(Syntax|Reference) errors( found)?:$/ { hdr = 1; next } - hdr && h == "" && NF { h = $0 } + hd == 1 { hd = 2; if ($0 ~ /^ *- /) { d = $0; sub(/^ *- */, "", d); h = h " " d } } + hdr && h == "" && NF { h = $0; if (h ~ /:$/) hd = 1 } e == "" && /^ *✗ / && !/ found$/ { e = $0 } f == "" && /[Ee]rror/ && !/^WARNING: / { f = $0 } END { r = (e != "") ? e : ((h != "") ? h : f); print r }' \ @@ -1737,10 +1742,56 @@ if [ ! -x "$MXBUILD" ] || [ ! -x "$JAVA_EXE" ]; then fi fi +# The snapshot holds the .mpr and mprcontents/ only. A module the script creates gets source folders +# beside the .mpr that the snapshot does not cover: the gate's own `mx check` generates +# themesource// (settings.json, web/*, native/*, public/) for every module that lacks one +# (mxcli v0.32 + MxBuild 11.8.0, captured in fixtures/exec-rollback-module-dirs/). After a rollback +# those folders stayed, untracked, for a module the model no longer has. So after a successful restore, +# the folders of the modules THIS RUN created (`Created module: X`: themesource/, javasource/, +# javascriptsource/ or , the names mxcli's removeModuleSourceDirs uses) are moved into the +# snapshot (stray-module-dirs/), when they were not there at snapshot time and hold no tracked file. +# "Creates" is read from mxcli's own exec output (script_created_modules), not from the script text. +# Nothing else is touched: another session's or the user's new folder in the same window stays put. +module_dirs() { + local d + for d in "$MODEL_DIR"/themesource/*/ "$MODEL_DIR"/javasource/*/ "$MODEL_DIR"/javascriptsource/*/; do + [ -d "$d" ] && printf '%s\n' "${d%/}" + done + return 0 +} +# Modules mxcli actually created in this run, from its exec stdout (captured verbatim, mxcli v0.32: +# "Created module: X"; an existing module prints "Module 'X' already exists", `if not exists` on an +# existing one "module X already exists, skipped (if not exists)", a module role "Created module role: +# M.R" — none of those match). Not the script text: `create or modify module Sales` on an existing +# module named a folder the gate regenerates, and the move then claimed the script created it. +# No captured exec output (a --patch run, or no write) = no names = nothing is moved. +script_created_modules() { + [ -n "${EXEC_OUT:-}" ] && [ -f "$EXEC_OUT" ] || return 0 + tr -d '\r' < "$EXEC_OUT" | sed -n 's/^Created module: \([A-Za-z_][A-Za-z0-9_]*\)$/\1/p' || true +} +move_stray_module_dirs() { + local m lm d rel dest + [ -n "${NEWEST_SNAP:-}" ] || return 0 + for m in $(script_created_modules); do + lm="$(printf '%s' "$m" | tr '[:upper:]' '[:lower:]')" + for d in "$MODEL_DIR/themesource/$lm" "$MODEL_DIR/javasource/$lm" \ + "$MODEL_DIR/javascriptsource/$m" "$MODEL_DIR/javascriptsource/$lm"; do + [ -d "$d" ] && [ ! -L "$d" ] || continue + printf '%s\n' "$MODDIRS_BEFORE" | grep -qxF -- "$d" && continue + rel="${d#"$PROJECT_ROOT"/}" + [ -n "$(git -C "$PROJECT_ROOT" ls-files -- "$rel" 2>/dev/null | head -1)" ] && continue + dest="${NEWEST_SNAP%/}/stray-module-dirs/$rel" + mkdir -p "$(dirname "$dest")" && mv -- "$d" "$dest" \ + && echo " → Moved $rel/ (source folder of module $m, which this run created: mxcli printed \"Created module: $m\") to $dest" + done + done +} step_done check echo "→ Snapshotting model..." ./bin/snapshot-mpr.sh step_done snapshot +# Module source folders as they stand before the write (see module_dirs / move_stray_module_dirs above). +MODDIRS_BEFORE="$(module_dirs)" # The snapshot just taken. A --patch run hands it to the script as MXPATCH_BACKUP_DIR, so the # .bak that bin/mxpatch.py keeps of each unit it rewrites lands beside the snapshot, OUTSIDE # the model tree, and is pruned with it. Until 2026-10-15 it was .mxunit.bak inside @@ -1772,6 +1823,7 @@ restore_snapshot() { elif R_OUT=$(MXTK_RESTORE_SAME_LEDGER=1 bash "$RESTORER" "$NEWEST_SNAP" 2>&1); then RESTORED=1 printf '%s\n' "$R_OUT" | sed 's/^/ → /' + [ -n "${MODDIRS_BEFORE+x}" ] && move_stray_module_dirs echo " → Auto-restored from: $NEWEST_SNAP" else printf '%s\n' "$R_OUT" | sed 's/^/ /' @@ -2324,7 +2376,23 @@ EOF_HV rm -f "$HV_BASE" "$HV_POST" fi else - "${PMXCLI:-./mxcli}" exec "$SCRIPT" -p "$MPR" || EXEC_STATUS=$? + # stdout is kept (EXEC_OUT) for move_stray_module_dirs, which reads its "Created module:" lines, + # but only when the script can create a module: mktemp + tee are two process starts, a per-row cost + # every other exec must not pay (test-exec-process-budget.sh). The test reads the script with the + # `read` builtin and a bash pattern (case-insensitive by bracket classes; bash 3.2-safe, no fork). + # It may over-match (a comment, `create module role`): that only captures, the moves still need + # mxcli's own "Created module:" line. Otherwise exec runs exactly as before the capture existed. + # Neither the capture nor tee may stop exec.sh under set -e once mxcli has written: a failed + # mktemp leaves EXEC_OUT empty (tee then only passes stdout through, and nothing is moved later), + # and a failed tee is swallowed. EXEC_STATUS is mxcli's own exit code either way. + _SCRIPT_TXT=""; IFS= read -r -d '' _SCRIPT_TXT < "$SCRIPT" || true + if [[ "$_SCRIPT_TXT" == *[Cc][Rr][Ee][Aa][Tt][Ee][[:space:]]*[Mm][Oo][Dd][Uu][Ll][Ee]* ]]; then + EXEC_OUT="$(mktemp "${TMPDIR:-/tmp}/exec-out.XXXXXX" 2>/dev/null)" || EXEC_OUT="" + { "${PMXCLI:-./mxcli}" exec "$SCRIPT" -p "$MPR" | tee ${EXEC_OUT:+"$EXEC_OUT"}; EXEC_STATUS=${PIPESTATUS[0]}; } || true + else + "${PMXCLI:-./mxcli}" exec "$SCRIPT" -p "$MPR" || EXEC_STATUS=$? + fi + unset _SCRIPT_TXT fi if [ "$EXEC_STATUS" -ne 0 ]; then diff --git a/tests/wave2/fixtures/exec-check-refusal/reference-v0.32.0.mdl b/tests/wave2/fixtures/exec-check-refusal/reference-v0.32.0.mdl new file mode 100644 index 00000000..69352334 --- /dev/null +++ b/tests/wave2/fixtures/exec-check-refusal/reference-v0.32.0.mdl @@ -0,0 +1,27 @@ +mdl 1; +create module Broken2; + +create persistent entity Broken2.Thing ( + Name: string(100) +); + +create microflow Broken2.ACT_Thing () +returns boolean as $ok +begin + $T = create Broken2.Thing (Nmae = 'x'); + $L = create Broken2.Missing (Name = 'y'); + declare $ok boolean = true; + return $ok; +end; + +create page Broken2.Thing_Edit +( + title: 'Edit', + layout: Atlas_Core.NoSuchLayout, + params: { $Thing: Broken2.Thing } +) +{ + dataview dv1 (datasource: $Thing) { + textbox tb1 (label: 'Name', attribute: Nmae) + } +}; diff --git a/tests/wave2/fixtures/exec-check-refusal/reference-v0.32.0.out b/tests/wave2/fixtures/exec-check-refusal/reference-v0.32.0.out new file mode 100644 index 00000000..6542297a --- /dev/null +++ b/tests/wave2/fixtures/exec-check-refusal/reference-v0.32.0.out @@ -0,0 +1,27 @@ +WARNING: This is a vibe-coded PoC, alpha quality, use with caution. +Checking syntax: mdl/02-broken.mdl +✓ Syntax OK (4 statements) +Connected to: ProbeApp.mpr (Mendix 11.8.0) + +(no module) +----------- + ⚠ page Broken2.Thing_Edit: DataView `dv1` contains input fields but is not inside a layout grid — label and input widths only render correctly inside a layoutgrid [MPR010] + at  + → Wrap dataview `dv1` in `layoutgrid { row { column (desktopwidth: autofill) { … } } }` + + ⚠ line 21: `Params: { $P: M.E } / Variables: { $v: Boolean = 'true' }` is deprecated; write `Params: ( $P: M.E ) / Variables: ( $v: Boolean = 'true' )` — same meaning. Refused from `mdl 2`. (mxcli help MDL-DEPR123) [MDL-DEPR123] + at  + → Rewrite the header map: the braces become ( ). In a page's and a snippet's header. A map is a property list, so it is in ( ); { } holds children (R2). + + +Validating references against: ProbeApp.mpr +(Note: References to objects created within the script are skipped) +Reference errors: + statement 3: microflow 'Broken2.ACT_Thing' has reference errors: + - entity not found: Broken2.Missing (referenced by create) + statement 4: page 'Broken2.Thing_Edit' has attribute binding errors: + - widget `tb1` (textbox) binds `Nmae`, but Broken2.Thing has no attribute Nmae (attributes: Name) — mxbuild reports CE1613 "The selected attribute 'Broken2.Thing.Nmae' no longer exists" + +✗ 2 reference error(s) found + +4 issues: 2 errors, 2 warnings, 0 info diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/exec-existing-and-ifnotexists-v0.32.0.mdl b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-existing-and-ifnotexists-v0.32.0.mdl new file mode 100644 index 00000000..e037090d --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-existing-and-ifnotexists-v0.32.0.mdl @@ -0,0 +1,3 @@ +mdl 1; +create or modify module Sales; +create module if not exists Foo; diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/exec-existing-and-ifnotexists-v0.32.0.out b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-existing-and-ifnotexists-v0.32.0.out new file mode 100644 index 00000000..32cca25c --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-existing-and-ifnotexists-v0.32.0.out @@ -0,0 +1,3 @@ +Connected to: ProbeApp.mpr (Mendix 11.8.0) +Module 'Sales' already exists +Created module: Foo diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/exec-sliptwo-v0.32.0.mdl b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-sliptwo-v0.32.0.mdl new file mode 100644 index 00000000..44efeb7a --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-sliptwo-v0.32.0.mdl @@ -0,0 +1,12 @@ +mdl 1; +create module SlipTwo; +create persistent entity SlipTwo.Thing ( + Name: string(100) +); +create microflow SlipTwo.ACT_Thing () +returns boolean as $ok +begin + $T = create SlipTwo.Thing (Nmae = 'x'); + declare $ok boolean = true; + return $ok; +end; diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/exec-sliptwo-v0.32.0.out b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-sliptwo-v0.32.0.out new file mode 100644 index 00000000..8ebf8310 --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/exec-sliptwo-v0.32.0.out @@ -0,0 +1,4 @@ +Connected to: ProbeApp.mpr (Mendix 11.8.0) +Created module: SlipTwo +Created entity: SlipTwo.Thing +Created microflow: SlipTwo.ACT_Thing diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/native/design-properties.json b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/native/design-properties.json new file mode 100644 index 00000000..49d1a202 --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/native/design-properties.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/native/main.js b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/native/main.js new file mode 100644 index 00000000..b611ae1e --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/native/main.js @@ -0,0 +1,2 @@ +import * as variables from "../../../theme/native/custom-variables"; + diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/settings.json b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/settings.json new file mode 100644 index 00000000..49d1a202 --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/settings.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/web/design-properties.json b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/web/design-properties.json new file mode 100644 index 00000000..49d1a202 --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/web/design-properties.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/web/main.scss b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/web/main.scss new file mode 100644 index 00000000..122370f7 --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/generated-by-mx-check/sliptwo/web/main.scss @@ -0,0 +1,2 @@ +@import '../../../theme/web/custom-variables'; + diff --git a/tests/wave2/fixtures/exec-rollback-module-dirs/rollback-untracked-v0.32.0.txt b/tests/wave2/fixtures/exec-rollback-module-dirs/rollback-untracked-v0.32.0.txt new file mode 100644 index 00000000..dbf772af --- /dev/null +++ b/tests/wave2/fixtures/exec-rollback-module-dirs/rollback-untracked-v0.32.0.txt @@ -0,0 +1,7 @@ + M .claude/loop/metrics-ledger.tsv + M docs/BUILD-LOG.md +?? themesource/sliptwo/native/design-properties.json +?? themesource/sliptwo/native/main.js +?? themesource/sliptwo/settings.json +?? themesource/sliptwo/web/design-properties.json +?? themesource/sliptwo/web/main.scss diff --git a/tests/wave2/fixtures/mxbuild-setup/setup-mxbuild-cached-v0.32.0.out b/tests/wave2/fixtures/mxbuild-setup/setup-mxbuild-cached-v0.32.0.out new file mode 100644 index 00000000..b3976a38 --- /dev/null +++ b/tests/wave2/fixtures/mxbuild-setup/setup-mxbuild-cached-v0.32.0.out @@ -0,0 +1,5 @@ +WARNING: This is a vibe-coded PoC, alpha quality, use with caution. +Detected Mendix version: 11.8.0 + MxBuild 11.8.0 already cached at /root/.mxcli/mxbuild/11.8.0/modeler/mxbuild + +MxBuild ready: /root/.mxcli/mxbuild/11.8.0/modeler/mxbuild diff --git a/tests/wave2/fixtures/rehost-list-modules/CAPTURE.txt b/tests/wave2/fixtures/rehost-list-modules/CAPTURE.txt index e20c16f6..1670df2a 100644 --- a/tests/wave2/fixtures/rehost-list-modules/CAPTURE.txt +++ b/tests/wave2/fixtures/rehost-list-modules/CAPTURE.txt @@ -23,3 +23,10 @@ v0.29.0 additions (2026-10-30; binary sha256 in fixtures/property-sets/CAPTURE-v list-modules-marketplace-protected-v0.29.0.txt the same on mkt/TestApp.mpr Models: fixtures/mxpatch/model/ with MyFirstModule set Protected, and additionally marked a Marketplace module v2.1.0 — exact mutations in fixtures/show-modules/CAPTURE.txt. + +v0.32.0 addition (2026-11-20): + list-modules-v0.32.0.txt `mxcli -p ProbeApp.mpr list modules > file 2>&1` with mxcli v0.32.0-374-g591bcd73e, + on the model described in fixtures/show-modules/CAPTURE.txt (v0.32.0 additions). New Version and Type + columns after Source, "(10 modules)" trailer. Own modules: MyFirstModule, Sales (2). Marketplace: 7 + (Administration, Atlas_Core, Atlas_Web_Content, DataWidgets, FeedbackModule, NanoflowCommons, + WebActions are "Marketplace vX"; System excluded). diff --git a/tests/wave2/fixtures/rehost-list-modules/list-modules-v0.32.0.txt b/tests/wave2/fixtures/rehost-list-modules/list-modules-v0.32.0.txt new file mode 100644 index 00000000..923b4cbe --- /dev/null +++ b/tests/wave2/fixtures/rehost-list-modules/list-modules-v0.32.0.txt @@ -0,0 +1,16 @@ +WARNING: This is a vibe-coded PoC, alpha quality, use with caution. +Connected to: ProbeApp.mpr (Mendix 11.8.0) +| Module | Source | Version | Type | Entities | Enums | Pages | Snippets | Microflows | Nanoflows | Workflows | Constants | JavaActions | PubREST | PubOData | ConOData | BizEvents | ExtDB | +|-------------------|---------------------|---------|------|----------|-------|-------|----------|------------|-----------|-----------|-----------|-------------|---------|----------|----------|-----------|-------| +| Administration | Marketplace v4.3.2 | 1.0.0 | App | 2 | 0 | 9 | 1 | 8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| Atlas_Core | Marketplace v4.1.3 | 1.0.0 | App | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| Atlas_Web_Content | Marketplace v4.1.0 | 1.0.0 | App | 1 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| DataWidgets | Marketplace v3.5.0 | 1.0.0 | App | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| FeedbackModule | Marketplace v4.0.2 | 1.0.0 | App | 2 | 2 | 6 | 1 | 7 | 11 | 0 | 2 | 2 | 0 | 0 | 0 | 0 | 0 | +| MyFirstModule | | 1.0.0 | App | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| NanoflowCommons | Marketplace v6.0.0 | 1.0.0 | App | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| Sales | | 1.0.0 | App | 2 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| System | | | | 41 | 16 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | +| WebActions | Marketplace v2.11.0 | 1.0.0 | App | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | + +(10 modules) diff --git a/tests/wave2/fixtures/restatement-guard/mxcli-version-untagged-591bcd7.txt b/tests/wave2/fixtures/restatement-guard/mxcli-version-untagged-591bcd7.txt new file mode 100644 index 00000000..606ab5ba --- /dev/null +++ b/tests/wave2/fixtures/restatement-guard/mxcli-version-untagged-591bcd7.txt @@ -0,0 +1 @@ +mxcli version 591bcd7 (2026-11-20T18:49:18Z) diff --git a/tests/wave2/fixtures/restatement-guard/mxcli-version-v0.32.0-374.txt b/tests/wave2/fixtures/restatement-guard/mxcli-version-v0.32.0-374.txt new file mode 100644 index 00000000..8a9c9ffb --- /dev/null +++ b/tests/wave2/fixtures/restatement-guard/mxcli-version-v0.32.0-374.txt @@ -0,0 +1 @@ +mxcli version v0.32.0-374-g591bcd73e (2026-11-20T18:31:01Z) diff --git a/tests/wave2/fixtures/show-modules/CAPTURE.txt b/tests/wave2/fixtures/show-modules/CAPTURE.txt index 3ec4487f..f5712c9a 100644 --- a/tests/wave2/fixtures/show-modules/CAPTURE.txt +++ b/tests/wave2/fixtures/show-modules/CAPTURE.txt @@ -13,3 +13,14 @@ written with project-bin/mxpatch.py (ContentsHash kept in step; `fix hashes` cle v0.29.0 alike — mendixlabs/mxcli#1498, since v0.28) show-modules-marketplace-protected-v0.29.0 "marketplace": "Marketplace v2.1.0, Protected AddOn" show-pages-in-myfirstmodule-v0.29.0.out mxcli -c 'SHOW PAGES IN MyFirstModule' on "protected" + +v0.32.0 additions (2026-11-20, Linux x86-64): mxcli source build `mxcli version v0.32.0-374-g591bcd73e +(2026-11-20T18:31:01Z)`, sha256 e3e841024add7a2b65488d9c4f8851802902a83933d31ae3e5f33d79e70ead7f. +Model: a blank Mendix 11.8.0 app (`mxcli new ProbeApp --version 11.8.0 --skip-build`: Atlas, +Administration and seven marketplace modules), then a `Sales` module (2 entities, 1 enumeration, +the page Sales.Customer_Edit, 1 microflow) written through bin/exec.sh. v0.32 adds the Version and +Type columns after Source, leaves both empty for System, and ends the table with "(N modules)" / +"(N pages)". + show-modules-v0.32.0.out / .exit mxcli -p ProbeApp.mpr -c 'show modules' (stdout; exit code) + show-pages-in-sales-v0.32.0.out mxcli -p ProbeApp.mpr -c 'SHOW PAGES IN Sales' (stdout) + show-pages-in-myfirstmodule-v0.32.0.out mxcli -p ProbeApp.mpr -c 'SHOW PAGES IN MyFirstModule' (stdout) diff --git a/tests/wave2/fixtures/show-modules/show-modules-v0.32.0.exit b/tests/wave2/fixtures/show-modules/show-modules-v0.32.0.exit new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/wave2/fixtures/show-modules/show-modules-v0.32.0.exit @@ -0,0 +1 @@ +0 diff --git a/tests/wave2/fixtures/show-modules/show-modules-v0.32.0.out b/tests/wave2/fixtures/show-modules/show-modules-v0.32.0.out new file mode 100644 index 00000000..5787c3dc --- /dev/null +++ b/tests/wave2/fixtures/show-modules/show-modules-v0.32.0.out @@ -0,0 +1,14 @@ +| Module | Source | Version | Type | Entities | Enums | Pages | Snippets | Microflows | Nanoflows | Workflows | Constants | JavaActions | PubREST | PubOData | ConOData | BizEvents | ExtDB | +|-------------------|---------------------|---------|------|----------|-------|-------|----------|------------|-----------|-----------|-----------|-------------|---------|----------|----------|-----------|-------| +| Administration | Marketplace v4.3.2 | 1.0.0 | App | 2 | 0 | 9 | 1 | 8 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| Atlas_Core | Marketplace v4.1.3 | 1.0.0 | App | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| Atlas_Web_Content | Marketplace v4.1.0 | 1.0.0 | App | 1 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| DataWidgets | Marketplace v3.5.0 | 1.0.0 | App | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| FeedbackModule | Marketplace v4.0.2 | 1.0.0 | App | 2 | 2 | 6 | 1 | 7 | 11 | 0 | 2 | 2 | 0 | 0 | 0 | 0 | 0 | +| MyFirstModule | | 1.0.0 | App | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| NanoflowCommons | Marketplace v6.0.0 | 1.0.0 | App | 2 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| Sales | | 1.0.0 | App | 2 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | +| System | | | | 41 | 16 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | +| WebActions | Marketplace v2.11.0 | 1.0.0 | App | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | + +(10 modules) diff --git a/tests/wave2/fixtures/show-modules/show-pages-in-myfirstmodule-v0.32.0.out b/tests/wave2/fixtures/show-modules/show-pages-in-myfirstmodule-v0.32.0.out new file mode 100644 index 00000000..745dc0a2 --- /dev/null +++ b/tests/wave2/fixtures/show-modules/show-pages-in-myfirstmodule-v0.32.0.out @@ -0,0 +1,5 @@ +| Qualified Name | Module | Name | Excluded | Folder | Title | url | Params | +|------------------------|---------------|----------|----------|--------|----------|-----|--------| +| MyFirstModule.Home_Web | MyFirstModule | Home_Web | false | | Homepage | | 0 | + +(1 pages) diff --git a/tests/wave2/fixtures/show-modules/show-pages-in-sales-v0.32.0.out b/tests/wave2/fixtures/show-modules/show-pages-in-sales-v0.32.0.out new file mode 100644 index 00000000..80739c71 --- /dev/null +++ b/tests/wave2/fixtures/show-modules/show-pages-in-sales-v0.32.0.out @@ -0,0 +1,5 @@ +| Qualified Name | Module | Name | Excluded | Folder | Title | url | Params | +|---------------------|--------|---------------|----------|--------|---------------|-----|--------| +| Sales.Customer_Edit | Sales | Customer_Edit | false | | Edit customer | | 1 | + +(1 pages) diff --git a/tests/wave2/test-describe-baseline.sh b/tests/wave2/test-describe-baseline.sh index d4ebd797..9bf44956 100755 --- a/tests/wave2/test-describe-baseline.sh +++ b/tests/wave2/test-describe-baseline.sh @@ -13,7 +13,9 @@ # verify: SAME on the same model; DRIFT with a diff when the live message changed (the #261 # shape); DRIFT when an absent document appeared; SAME for a re-run by the last # recorded writer and on a fresh model; STALEHEADER alone is a warn (exit 1); after an -# mxcli upgrade a changed hash is RESTAMP, not DRIFT. +# mxcli upgrade a changed hash is RESTAMP, not DRIFT — also from an untagged build, whose +# `--version` names only a commit (captured from a real v0.32.0-374 build relinked with +# VERSION=591bcd7, which is what `make build` stamps on a shallow clone). # exec.sh: WARN + BUILD-LOG cell, exit 0; `ask` approval stays exit 0; =off silent; a script # without a header costs zero DESCRIBE calls. # NOTHING here touches a real .mpr, mxcli or mxbuild. @@ -62,7 +64,8 @@ MXCLI cat >> "$P/mxcli" <<'MXCLI' D="$(cd "$(dirname "$0")" && pwd)" case "${1:-}" in - --version) sed "s/v0\.26\.0/${FAKE_VERSION:-v0.26.0}/" "$CAP26/mxcli-version-v0.26.0.txt"; exit 0 ;; + --version) [ -n "${FAKE_VERSION_FILE:-}" ] && { cat "$CAP26/$FAKE_VERSION_FILE"; exit 0; } + sed "s/v0\.26\.0/${FAKE_VERSION:-v0.26.0}/" "$CAP26/mxcli-version-v0.26.0.txt"; exit 0 ;; check) exit 0 ;; exec) echo "fake mxcli exec"; echo "written by the script" >> "$D/Fixture.mpr" [ -n "${FAKE_APPLY:-}" ] && cp "${FAKE_APPLY%%=*}" "$D/live/${FAKE_APPLY#*=}"; exit 0 ;; @@ -115,6 +118,16 @@ hasnt "the unchanged microflow is not reported" "$OUT" "DRIFT Sales.ACT_Approval OUT="$(FAKE_VERSION=v0.27.0 db verify "$S")"; RC=$? [ "$RC" -eq 1 ] && has "after an mxcli upgrade: RESTAMP, not DRIFT" "$OUT" "RESTAMP Sales.ACT_ApprovalStep_Reject re-stamp after mxcli upgrade (v0.26.0 → v0.27.0)" || bad "upgrade rc $RC: $OUT" hasnt " no DRIFT row then" "$OUT" "DRIFT" +# Untagged build (a `make build` on a shallow clone): the captured --version line names only a +# commit. It is stamped as it is, and a later tagged build reads as an upgrade, not as drift. +U="$WORK/untagged.mdl"; cp "$S" "$U" +cp "$REJ" "$P/live/MICROFLOW__Sales.ACT_ApprovalStep_Reject.out"; rm -f "$P/live/MICROFLOW__Sales.ACT_ApprovalStep_Hold.out" +FAKE_VERSION_FILE=mxcli-version-untagged-591bcd7.txt db stamp "$U" >/dev/null +grep -q '^-- baseline-mxcli: 591bcd7$' "$U" && ok "untagged build: its commit is recorded as the version" || bad "untagged build: no baseline-mxcli line ($(grep '^-- baseline-mxcli' "$U"))" +sed "s/A comment is required to reject./Please add a comment before rejecting./" "$REJ" > "$P/live/MICROFLOW__Sales.ACT_ApprovalStep_Reject.out" +OUT="$(FAKE_VERSION_FILE=mxcli-version-v0.32.0-374.txt db verify "$U")"; RC=$? +[ "$RC" -eq 1 ] && has "untagged -> tagged build: RESTAMP, not DRIFT" "$OUT" "re-stamp after mxcli upgrade (591bcd7 → v0.32.0)" || bad "untagged upgrade rc $RC: $OUT" +rm -f "$U" rm -f "$P/live/MICROFLOW__Sales.ACT_ApprovalStep_Hold.out" H="$P/mdlsource/13-header-only.mdl" { grep '^-- baseline' "$S"; cat "$APP"; } > "$H"; cp "$APP" "$P/live/" diff --git a/tests/wave2/test-exec-check-refusal.sh b/tests/wave2/test-exec-check-refusal.sh index e627c67b..6b8e4136 100644 --- a/tests/wave2/test-exec-check-refusal.sh +++ b/tests/wave2/test-exec-check-refusal.sh @@ -21,6 +21,12 @@ # C the screen still shows mxcli's own output, and mxcli check ran exactly once # D a plain one-line refusal (no rule bracket) is recorded too # E a reason in non-Latin text longer than 160 bytes is cut on a character boundary, not to "..." +# F a v0.32 two-line reference error keeps its cause, not only the header line +# +# reference-v0.32.0.out is `mxcli check reference-v0.32.0.mdl -p ProbeApp.mpr --references`, stdout +# and stderr as exec.sh captures them, from a real mxcli v0.32.0-374-g591bcd73e on a blank Mendix +# 11.8.0 app (2026-11-20). Under "Reference errors:" each error is a header ending in ":" and the +# cause on the next line as " - ...". Before the fix the row kept only the header. # # Synthetic project, stub mxcli replaying the capture. Nothing real runs. set -uo pipefail @@ -102,6 +108,13 @@ if printf '%s' "$_why" | iconv -f UTF-8 -t UTF-8 >/dev/null 2>&1 && [ "$(printf && [ "$(printf '%s' "$_why" | wc -c)" -ge 157 ]; then ok "E: cut is valid UTF-8, 157-160 bytes" else bad "E: cut is valid UTF-8, 157-160 bytes" "$(printf '%s' "$_why" | wc -c) bytes"; fi +# F +run "$GOLD/reference-v0.32.0.out" +case "$ROW" in *"check: statement 3: microflow 'Broken2.ACT_Thing' has reference errors: entity not found: Broken2.Missing (referenced by create)"*) + ok "F: v0.32 reference error keeps its cause line" ;; + *) bad "F: v0.32 reference error keeps its cause line" "$ROW" ;; esac +[ "$(cells "$ROW")" = 6 ] && ok "F: row still has 5 cells" || bad "F: row still has 5 cells" "$(cells "$ROW") bars: $ROW" + echo "" echo "== $PASS passed, $FAIL failed" [ "$FAIL" -eq 0 ] diff --git a/tests/wave2/test-exec-result-line.sh b/tests/wave2/test-exec-result-line.sh index fa655cca..4fd255ba 100644 --- a/tests/wave2/test-exec-result-line.sh +++ b/tests/wave2/test-exec-result-line.sh @@ -16,6 +16,10 @@ # I exec exit 3 + gate error + broken restore -> verdict=failed applied=unknown (same as H); I2 restore ok -> restored # J-L --patch: clean applied; script fails half-way -> restored (K) / failed when the restore is broken (K2); unverified gate -> restored (L) # M lint_new words: skipped (SKIP_LINT, lint not installed), blind (lint-gate fault); B: unknown (rise not itemised) +# N the exec-output capture fails AFTER mxcli wrote (#823 review): mktemp of exec-out.* fails (N1, N3) +# or tee into it fails (N2); exec.sh still reaches the gate / restore, prints its RESULT line, +# and keeps mxcli's own exit code (N3: exec exit 3 -> partial). PATH wrappers fail only for the +# exec-out.* capture; every other mktemp/tee call runs the real tool. # Every case: exactly one RESULT line, and it is not the last line. # # Synthetic only: throwaway git repo, stub mxcli, stub mxbuild, stub java. Nothing real runs. @@ -229,6 +233,32 @@ RC=$(LINT_MODE=fault run M3 ok,ok) [ "$RC" -eq 0 ] && kept && ok "exit 0" || bad "M3 rc=$RC" "$(tail -6 "$WORK/out.M3")" res M3 "MXTK-RESULT exec verdict=applied applied=yes verified=yes lint_new=blind exit=0" +echo "== N: exec-output capture fails after the write ==" +W="$WORK/wrap"; mkdir -p "$W" +RMK="$(command -v mktemp)"; RTEE="$(command -v tee)" +cat > "$W/mktemp" <&2; exit 1; } ;; esac +exec "$RMK" "\$@" +WR +cat > "$W/tee" < gate ran, restored, exit 1" || bad "N1 rc=$RC" "$(tail -6 "$WORK/out.N1")" +res N1 "MXTK-RESULT exec verdict=restored applied=no verified=no lint_new=na exit=1" +grep -q 'fake mxcli exec' "$WORK/out.N1" && ok "N1: mxcli's stdout still on screen" || bad "N1: exec stdout lost" +RC=$(PATH="$W:$PATH" FAIL_TEE=1 run N2 ok,err,ok) +[ "$RC" -eq 1 ] && ! kept && ok "N2: tee fails -> gate ran, restored, exit 1" || bad "N2 rc=$RC" "$(tail -6 "$WORK/out.N2")" +res N2 "MXTK-RESULT exec verdict=restored applied=no verified=no lint_new=na exit=1" +RC=$(PATH="$W:$PATH" FAIL_MKTEMP=1 MXCLI_EXEC_RC=3 run N3 ok,ok) +[ "$RC" -eq 1 ] && kept && ok "N3: mxcli exit 3 kept through a failed capture -> partial" || bad "N3 rc=$RC" "$(tail -6 "$WORK/out.N3")" +res N3 "MXTK-RESULT exec verdict=partial applied=partial verified=yes lint_new=na exit=1" +ls "$WORK/tmp"/exec-out.* >/dev/null 2>&1 && bad "N: an exec-out.* temp file was left behind" || ok "N: no exec-out.* temp file left" + echo "" echo "PASS: $PASS FAIL: $FAIL" [ "$FAIL" -eq 0 ] diff --git a/tests/wave2/test-exec-rollback-module-dirs.sh b/tests/wave2/test-exec-rollback-module-dirs.sh new file mode 100755 index 00000000..bbe231c9 --- /dev/null +++ b/tests/wave2/test-exec-rollback-module-dirs.sh @@ -0,0 +1,170 @@ +#!/usr/bin/env bash +# test-exec-rollback-module-dirs.sh - a rolled-back exec leaves no module source folder behind. +# +# usage: bash tests/wave2/test-exec-rollback-module-dirs.sh [path-to-exec.sh] +# +# Field (real-mxcli run, mxcli v0.32.0-374, MxBuild 11.8.0, 2026-11-20): `create module SlipTwo` plus a +# microflow with a member typo passed `mxcli check`, was written, failed the mx check gate (CE1613) +# and was rolled back. The gate's own `mx check` generates themesource// for every module +# that lacks one (mxcli exec writes nothing there); the snapshot covers the .mpr and mprcontents/ +# only, so themesource/sliptwo/ stayed behind, untracked, for a module the model no longer has. +# +# Golden input, captured verbatim from that run, in fixtures/exec-rollback-module-dirs/: +# rollback-untracked-v0.32.0.txt `git status --porcelain --untracked-files=all` after the rollback +# generated-by-mx-check/sliptwo/ the five files themselves, byte for byte (the real folder also +# holds an empty public/, which git cannot carry) +# The stub mxbuild copies that folder into themesource/ beside the .mpr whenever the model holds the +# script's write, as the real `mx check` does. +# +# A single tree: gate fails -> restored, themesource/sliptwo/ moved into the snapshot (fails on master) +# B .mpr under app/: same, app/themesource/sliptwo/ moved (fails on master) +# C a folder that existed before the write is kept: tracked, untracked, and ignored ones +# D a clean apply keeps the new module's folder +# E a folder something else created during the exec window (themesource/peerwork/, made by +# the stub mxbuild) survives the rollback: only the script's own module is moved +# F `create or modify module Sales` on an existing module ("Module 'Sales' already exists") whose +# folder the gate generates in the window is NOT moved; `create module if not exists Foo` +# ("Created module: Foo") is. Names come from mxcli's exec stdout, never the script text. +# +# The stub `mxcli exec` replays captured stdout (exec-*-v0.32.0.out, from the .mdl beside each, run +# with the real mxcli v0.32.0-374 on a scaffolded Mendix 11.8.0 app that has a Sales module). +# +# Synthetic project, stub mxcli / mxbuild / java. The real snapshot-mpr.sh and restore-mpr.sh run. +set -uo pipefail + +TOOLKIT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +SUBJECT="${1:-$TOOLKIT/project-bin/exec.sh}" +case "$SUBJECT" in /*) ;; *) SUBJECT="$PWD/$SUBJECT" ;; esac +GOLD="$TOOLKIT/tests/wave2/fixtures/exec-rollback-module-dirs" +WORK="$(cd "$(mktemp -d "${TMPDIR:-/tmp}/exec-moddirs.XXXXXX")" && pwd -P)" || exit 2 +trap 'rm -rf "$WORK"' EXIT +PASS=0; FAIL=0 +ok() { PASS=$((PASS+1)); echo " ok - $1"; } +bad() { FAIL=$((FAIL+1)); echo " FAIL - $1${2:+: $2}"; } +echo "== subject: $SUBJECT" + +# The captured status lists exactly the files the captured folder holds. +_want="$(sed -n 's#^?? themesource/##p' "$GOLD/rollback-untracked-v0.32.0.txt" | LC_ALL=C sort)" +_have="$(cd "$GOLD/generated-by-mx-check" && find . -type f | sed 's#^\./##' | LC_ALL=C sort)" +[ -n "$_want" ] && [ "$_want" = "$_have" ] && ok "[golden] status capture and folder capture agree ($(printf '%s\n' "$_want" | grep -c .) files)" \ + || bad "[golden] status capture and folder capture disagree" "$_want / $_have" + +mkdir -p "$WORK/jdk/bin"; printf '#!/usr/bin/env bash\nexit 0\n' > "$WORK/jdk/bin/java" +cat > "$WORK/mxbuild" <> "$WORK/mxbuild" <<'MXB' +err=""; proj=""; for a in "$@"; do case "$a" in --write-errors=*) err="${a#--write-errors=}" ;; *.mpr) proj="$a" ;; esac; done +n=$(( $(cat "$MXB_N" 2>/dev/null || echo 0) + 1 )); echo "$n" > "$MXB_N" +mode="$(printf '%s\n' "$MXB_MODES" | tr ',' '\n' | sed -n "${n}p")"; mode="${mode:-ok}" +# Like the real mx check: generate themesource// for a module that has none. The model +# holds module SlipTwo once the script's write is in it. +M="$(dirname "${proj:-$MXB_MODEL}")"; [ -f "$M/Fixture.mpr" ] || M="$MXB_MODEL" +# MXB_GEN: the module folders this "mx check" generates (default sliptwo), each from the captured set. +if grep -q written "$M/Fixture.mpr" 2>/dev/null; then + for g in ${MXB_GEN:-sliptwo}; do + [ -d "$M/themesource/$g" ] || cp -R "$GOLD/generated-by-mx-check/sliptwo" "$M/themesource/$g" + done +fi +# E: another session writes its own new folder during the window. +if [ -n "${MXB_PEER:-}" ] && [ "$mode" = err ]; then mkdir -p "$M/themesource/peerwork"; printf 'peer\n' > "$M/themesource/peerwork/x.scss"; fi +case "$mode" in + ok) [ -n "$err" ] && printf '{"problems":[]}' > "$err"; exit 0 ;; + err) [ -n "$err" ] && printf '{"problems":[{"severity":"Error","code":"CE1613","message":"The selected attribute '"'"'SlipTwo.Thing.Nmae'"'"' no longer exists.","element":{"document":"SlipTwo.ACT_Thing"}}]}' > "$err"; exit 1 ;; +esac +MXB +chmod +x "$WORK/mxbuild" "$WORK/jdk/bin/java" + +# mk : a committed project with tracked themesource/sales, an untracked +# themesource/userwork (theme work not yet committed) and an ignored javasource/sales/proxies. +mk() { + P="$1"; M="$P${2:+/$2}" + mkdir -p "$P/bin" "$P/mdlsource" "$M/mprcontents" "$M/themesource/sales" "$M/javasource/sales/proxies" + printf 'not a real model\n' > "$M/Fixture.mpr"; printf 'bson\n' > "$M/mprcontents/a.mxunit" + printf '{}\n' > "$M/themesource/sales/settings.json"; printf 'x\n' > "$M/javasource/sales/proxies/P.java" + printf 'mdl 1;\ncreate module SlipTwo;\n' > "$P/mdlsource/test.mdl" + cp "$TOOLKIT/project-bin/_common.sh" "$TOOLKIT/project-bin/restore-mpr.sh" "$TOOLKIT/project-bin/snapshot-mpr.sh" "$P/bin/" + cp "$SUBJECT" "$P/bin/exec.sh" + cat > "$P/mxcli" <> "$M/Fixture.mpr"; echo x >> "$M/mprcontents/a.mxunit" + cat "$GOLD/\${EXEC_CAP:-exec-sliptwo-v0.32.0.out}"; exit 0 ;; +esac +exit 0 +MXCLI + chmod +x "$P/bin/"*.sh "$P/mxcli" + ( cd "$P" && git init -q . && printf '.mpr-snapshots/\ndocs/\n.claude/\n/javasource/*/proxies/\n/app/javasource/*/proxies/\n' > .gitignore \ + && git add -A && git -c user.email=t@t -c user.name=t commit -qm fixture ) >/dev/null 2>&1 + mkdir -p "$M/themesource/userwork"; printf 'mine\n' > "$M/themesource/userwork/main.scss" +} +run() { # run -> RC (MXB_MODEL: the model dir, for the stub mxbuild) + rm -f "$WORK/n"; mkdir -p "$WORK/tmp" + _m="$1"; [ -d "$1/app" ] && _m="$1/app" + ( cd "$1" && MXB_MODEL="$_m" MXB_PEER="${MXB_PEER:-}" MXB_GEN="${MXB_GEN:-}" EXEC_CAP="${EXEC_CAP:-}" TMPDIR="$WORK/tmp" SP_RESTART=0 MXTK_NO_INSTALL=1 SKIP_LINT=fixture MXB_N="$WORK/n" MXB_MODES="$2" \ + MXBUILD_PATH="$WORK/mxbuild" JAVA_HOME="$WORK/jdk" ./bin/exec.sh mdlsource/test.mdl ) >"$WORK/out" 2>&1 + RC=$? +} +kept_old() { # kept_old