diff --git a/backend/FwHeadless/Dockerfile b/backend/FwHeadless/Dockerfile index 965961f51e..e5f0eb552a 100644 --- a/backend/FwHeadless/Dockerfile +++ b/backend/FwHeadless/Dockerfile @@ -43,6 +43,11 @@ RUN test -f FixFwData \ && python3 -c "import zipfile; open('/tmp/smoke.fwdata','wb').write(zipfile.ZipFile('/tmp/test-template-repo.zip').read('kevin-test-01.fwdata'))" \ && ./FixFwData /tmp/smoke.fwdata; ec=$?; rm -f /tmp/test-template-repo.zip /tmp/smoke.fwdata; \ if [ $ec -gt 1 ]; then echo "FixFwData smoke test failed with exit $ec"; exit 1; fi +# Smoke-test: chorusmerge must engage the FieldWorks merge handler, not silently keep one +# whole file (#2508). Runs the real wrapper from a non-/app cwd, exactly as hg does. +# Bind-mount rather than COPY so the fixture/script don't ship in the runtime image. +RUN --mount=type=bind,source=FwHeadless/chorusmerge-smoke,target=/opt/chorusmerge-smoke \ + bash /opt/chorusmerge-smoke/run.sh USER www-data:www-data ENV XDG_DATA_HOME=/var/www/.local/share ENTRYPOINT ["tini", "--"] diff --git a/backend/FwHeadless/chorusmerge b/backend/FwHeadless/chorusmerge index fdf1c1160b..62f77d0e8b 100755 --- a/backend/FwHeadless/chorusmerge +++ b/backend/FwHeadless/chorusmerge @@ -1,6 +1,12 @@ #!/bin/bash -# cwd while running script is inside hg repo, so ensure we look for ChorusMerge.dll in right place +# cwd while running script is inside the hg repo. ChorusMerge finds its FieldWorks merge +# handlers by scanning the cwd for *-ChorusPlugin.dll (MEF DirectoryCatalog(".")), so cd to +# where they sit next to ChorusMerge.dll, else merges silently fall back to "keep ours". +# hg passes absolute file paths to the merge tool, so changing cwd is safe. SCRIPT_DIR=$(dirname $(readlink -f "$0")) +# Fail loudly rather than merge from the wrong cwd: a merge without the handlers silently +# keeps "ours" (the #2508 data loss); a non-zero exit makes Chorus roll back and throw. +cd "$SCRIPT_DIR" || { echo "chorusmerge: cannot cd to $SCRIPT_DIR; refusing to merge without the FieldWorks handlers" >&2; exit 1; } exec dotnet "${SCRIPT_DIR}/ChorusMerge.dll" "$@" diff --git a/backend/FwHeadless/chorusmerge-smoke/PartsOfSpeech.base.list b/backend/FwHeadless/chorusmerge-smoke/PartsOfSpeech.base.list new file mode 100644 index 0000000000..fbee34c375 --- /dev/null +++ b/backend/FwHeadless/chorusmerge-smoke/PartsOfSpeech.base.list @@ -0,0 +1,246 @@ + + + + + Pos + + + + + + + + + + + + Parts Of Speech + + + + + adv + + + + Adverb + + + + + + An adverb, narrowly defined, is a part of speech whose members modify verbs for such categories as time, manner, place, or direction. An adverb, broadly defined, is a part of speech whose members modify any constituent class of words other than nouns, such as verbs, adjectives, adverbs, phrases, clauses, or sentences. Under this definition, the possible type of modification depends on the class of the constituent being modified. + + + + + + + Adverb + + + + + + + + n + + + + Noun + + + + + + A noun is a broad classification of parts of speech which include substantives and nominals. + + + + + + + Noun + + + + + + + + pro-form + + + + Pro-form + + + + + + A pro-form is a part of speech whose members usually substitute for other constituents, including phrases, clauses, or sentences, and whose meaning is recoverable from the linguistic or extralinguistic context. + + + + + + + Pro-form + + + + + + pro + + + + Pronoun + + + + + + A pronoun is a pro-form which functions like a noun and substitutes for a noun or noun phrase. + + + + + + + Pronoun + + + + + + + + + + + + v + + + + Verb + + + + + + A verb is a part of speech whose members typically signal events and actions; constitute, singly or in a phrase, a minimal predicate in a clause; govern the number and types of other constituents which may occur in the clause; and, in inflectional languages, may be inflected for tense, aspect, voice, modality, or agreement with other constituents in person, number, or grammatical gender. + + + + + + + Verb + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/FwHeadless/chorusmerge-smoke/run.sh b/backend/FwHeadless/chorusmerge-smoke/run.sh new file mode 100644 index 0000000000..640c9f8960 --- /dev/null +++ b/backend/FwHeadless/chorusmerge-smoke/run.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# Smoke-test: does chorusmerge actually engage the FieldWorks merge handler, or silently +# fall back to keeping one whole file? See sillsdev/languageforge-lexbox#2508 / #2509. +# +# PartsOfSpeech.base.list is the FLExBridge split (nested) form of a possibility list — what +# hg actually versions and merges. Regenerate from a .fwdata with the FLExBridge split CLI. +# +# The handler is discovered by scanning the *current working directory* for *-ChorusPlugin.dll, +# and hg runs the merge tool with cwd = the repo (not /app). So this MUST run from a non-/app +# cwd to be meaningful — running it from /app would hide the bug and pass falsely. +set -euo pipefail + +APP=${APP:-/app} +SMOKE="$(dirname "$(readlink -f "$0")")" +BASE="$SMOKE/PartsOfSpeech.base.list" +WORK="$(mktemp -d)" +trap 'rm -rf "$WORK"' EXIT + +# Two edits to DIFFERENT possibility items (different guids) => they must auto-merge cleanly. +# A real 3-way merge keeps both; the whole-file "keep ours" fallback drops the theirs edit. +sed 's#>Adverb#>Adverb_OURS#' "$BASE" > "$WORK/ours.list" +sed 's#>Verb#>Verb_THEIRS#' "$BASE" > "$WORK/theirs.list" +cp "$WORK/ours.list" "$WORK/merged.list" # ChorusMerge writes the result back to arg 0 + +cd "$WORK" # a non-/app cwd, exactly as hg runs the merge tool inside the repo +rc=0 +ChorusPathToRepository="$WORK" "$APP/chorusmerge" "$WORK/merged.list" "$BASE" "$WORK/theirs.list" || rc=$? + +if grep -q Adverb_OURS "$WORK/merged.list" && grep -q Verb_THEIRS "$WORK/merged.list"; then + echo "chorusmerge smoke OK: FieldWorks 3-way merge engaged; both edits preserved" +else + echo "chorusmerge smoke FAILED: merge dropped a side (FieldWorks handler not engaged; chorusmerge exit=$rc)" + echo " Adverb_OURS=$(grep -c Adverb_OURS "$WORK/merged.list" || true) Verb_THEIRS=$(grep -c Verb_THEIRS "$WORK/merged.list" || true)" + exit 1 +fi