diff --git a/bin/panama b/bin/panama index 6db8338..0779d9f 100755 --- a/bin/panama +++ b/bin/panama @@ -451,11 +451,16 @@ CONTRACT_CAPABILITIES=(hermetic live-host live-compositor live-desktop network p contract_paths() { local candidate + # The manifest is kept in byte order, so both the discovery sort and the + # comparison below have to be byte order too. A UTF-8 collation folds the + # punctuation away -- `calendar_agenda_bridge_test.py` sorts before + # `calendar-agenda-helper-contract` under en_US and after it under C -- and + # a gate that passes or fails on the machine's LANG is not a gate. while IFS= read -r candidate; do [[ -x "$candidate" || "$candidate" == *_test.py ]] || continue printf 'tests/%s\n' "${candidate#"$PANAMA_DIR/tests/"}" done < <(find "$PANAMA_DIR/tests" -type f \ - -not -path '*/fixtures/*' -not -path '*__pycache__*' | sort) + -not -path '*/fixtures/*' -not -path '*__pycache__*' | LC_ALL=C sort) } contract_manifest_entries() { @@ -478,6 +483,8 @@ validate_contract_manifest() { require_contract_manifest || return 1 local manifest="$PANAMA_DIR/$CONTRACT_MANIFEST" + # Byte order, for the same reason contract_paths sorts in it. + local LC_ALL=C local line capabilities path extra previous_comment="" previous_was_comment=0 local previous_path="" capability discovered local -a capability_list=() findings=() diff --git a/tests/setup/contract-manifest-contract b/tests/setup/contract-manifest-contract index eb26af0..a4a5755 100755 --- a/tests/setup/contract-manifest-contract +++ b/tests/setup/contract-manifest-contract @@ -11,16 +11,22 @@ manifest="$repo_dir/tests/contracts.manifest" discover_contracts() { discovered_contracts=() + # Byte order, exactly as the runner discovers them. A UTF-8 collation folds + # the punctuation away and reorders the pairs that differ only by `-` and + # `_`, so a manifest correct here would be wrong on a machine with a + # different LANG. while IFS= read -r path; do [[ -x "$path" || "$path" == *_test.py ]] || continue discovered_contracts+=("tests/${path#"$repo_dir/tests/"}") done < <(find "$repo_dir/tests" -type f \ - -not -path '*/fixtures/*' -not -path '*__pycache__*' | sort) + -not -path '*/fixtures/*' -not -path '*__pycache__*' | LC_ALL=C sort) } validate_manifest() { local candidate="$1" local -n expected_contracts="$2" + # Byte order, for the same reason discover_contracts sorts in it. + local LC_ALL=C local line capabilities path extra previous_comment="" previous_was_comment=0 local -a capability_list=() local -A manifest_paths=() capability_counts=()