Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions backend/FwHeadless/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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", "--"]
Expand Down
8 changes: 7 additions & 1 deletion backend/FwHeadless/chorusmerge
Original file line number Diff line number Diff line change
@@ -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" "$@"
246 changes: 246 additions & 0 deletions backend/FwHeadless/chorusmerge-smoke/PartsOfSpeech.base.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
<?xml version="1.0" encoding="utf-8"?>
<PartsOfSpeech>
<CmPossibilityList
guid="64dd1920-ba7a-43ca-9577-4dcc3b8ede9a">
<Abbreviation>
<AUni
ws="en">Pos</AUni>
</Abbreviation>
<DateCreated
val="2023-08-16 09:28:29.486" />
<DateModified
val="2023-08-16 09:28:29.486" />
<Depth
val="127" />
<DisplayOption
val="0" />
<IsClosed
val="False" />
<IsSorted
val="True" />
<IsVernacular
val="False" />
<ItemClsid
val="5049" />
<ListVersion
val="00000000-0000-0000-0000-000000000000" />
<Name>
<AUni
ws="en">Parts Of Speech</AUni>
</Name>
<Possibilities>
<ownseq
class="PartOfSpeech"
guid="46e4fe08-ffa0-4c8b-bf98-2c56f38904d9">
<Abbreviation>
<AUni
ws="en">adv</AUni>
</Abbreviation>
<BackColor
val="-1073741824" />
<CatalogSourceId>
<Uni>Adverb</Uni>
</CatalogSourceId>
<DateCreated
val="2023-08-16 09:28:29.490" />
<DateModified
val="2023-08-16 09:28:29.490" />
<Description>
<AStr
ws="en">
<Run
ws="en">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.</Run>
</AStr>
</Description>
<ForeColor
val="6303632" />
<Hidden
val="False" />
<IsProtected
val="False" />
<Name>
<AUni
ws="en">Adverb</AUni>
</Name>
<SortSpec
val="0" />
<UnderColor
val="-1073741824" />
<UnderStyle
val="1" />
</ownseq>
<ownseq
class="PartOfSpeech"
guid="a8e41fd3-e343-4c7c-aa05-01ea3dd5cfb5">
<Abbreviation>
<AUni
ws="en">n</AUni>
</Abbreviation>
<BackColor
val="-1073741824" />
<CatalogSourceId>
<Uni>Noun</Uni>
</CatalogSourceId>
<DateCreated
val="2023-08-16 09:28:29.491" />
<DateModified
val="2023-08-16 09:28:29.491" />
<Description>
<AStr
ws="en">
<Run
ws="en">A noun is a broad classification of parts of speech which include substantives and nominals.</Run>
</AStr>
</Description>
<ForeColor
val="6303632" />
<Hidden
val="False" />
<IsProtected
val="False" />
<Name>
<AUni
ws="en">Noun</AUni>
</Name>
<SortSpec
val="0" />
<UnderColor
val="-1073741824" />
<UnderStyle
val="1" />
</ownseq>
<ownseq
class="PartOfSpeech"
guid="a4fc78d6-7591-4fb3-8edd-82f10ae3739d">
<Abbreviation>
<AUni
ws="en">pro-form</AUni>
</Abbreviation>
<BackColor
val="-1073741824" />
<CatalogSourceId>
<Uni>Pro-form</Uni>
</CatalogSourceId>
<DateCreated
val="2023-08-16 09:28:29.491" />
<DateModified
val="2023-08-16 09:28:29.491" />
<Description>
<AStr
ws="en">
<Run
ws="en">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.</Run>
</AStr>
</Description>
<ForeColor
val="6303632" />
<Hidden
val="False" />
<IsProtected
val="False" />
<Name>
<AUni
ws="en">Pro-form</AUni>
</Name>
<SortSpec
val="0" />
<SubPossibilities>
<ownseq
class="PartOfSpeech"
guid="a3274cfd-225f-45fd-8851-a7b1a1e1037a">
<Abbreviation>
<AUni
ws="en">pro</AUni>
</Abbreviation>
<BackColor
val="-1073741824" />
<CatalogSourceId>
<Uni>Pronoun</Uni>
</CatalogSourceId>
<DateCreated
val="2023-08-16 09:28:29.491" />
<DateModified
val="2023-08-16 09:28:29.491" />
<Description>
<AStr
ws="en">
<Run
ws="en">A pronoun is a pro-form which functions like a noun and substitutes for a noun or noun phrase.</Run>
</AStr>
</Description>
<ForeColor
val="6303632" />
<Hidden
val="False" />
<IsProtected
val="False" />
<Name>
<AUni
ws="en">Pronoun</AUni>
</Name>
<SortSpec
val="0" />
<UnderColor
val="-1073741824" />
<UnderStyle
val="1" />
</ownseq>
</SubPossibilities>
<UnderColor
val="-1073741824" />
<UnderStyle
val="1" />
</ownseq>
<ownseq
class="PartOfSpeech"
guid="86ff66f6-0774-407a-a0dc-3eeaf873daf7">
<Abbreviation>
<AUni
ws="en">v</AUni>
</Abbreviation>
<BackColor
val="-1073741824" />
<CatalogSourceId>
<Uni>Verb</Uni>
</CatalogSourceId>
<DateCreated
val="2023-08-16 09:28:29.491" />
<DateModified
val="2023-08-16 09:28:29.491" />
<Description>
<AStr
ws="en">
<Run
ws="en">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.</Run>
</AStr>
</Description>
<ForeColor
val="6303632" />
<Hidden
val="False" />
<IsProtected
val="False" />
<Name>
<AUni
ws="en">Verb</AUni>
</Name>
<SortSpec
val="0" />
<UnderColor
val="-1073741824" />
<UnderStyle
val="1" />
</ownseq>
</Possibilities>
<PreventChoiceAboveLevel
val="0" />
<PreventDuplicates
val="True" />
<PreventNodeChoices
val="False" />
<UseExtendedFields
val="True" />
<WsSelector
val="-3" />
</CmPossibilityList>
</PartsOfSpeech>
35 changes: 35 additions & 0 deletions backend/FwHeadless/chorusmerge-smoke/run.sh
Original file line number Diff line number Diff line change
@@ -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</AUni>#>Adverb_OURS</AUni>#' "$BASE" > "$WORK/ours.list"
sed 's#>Verb</AUni>#>Verb_THEIRS</AUni>#' "$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
Comment thread
hahn-kev marked this conversation as resolved.
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
Loading