From 876eb04219ea0d56d7d7047bb7a5f91511f01ae0 Mon Sep 17 00:00:00 2001 From: Juan Pelaez Date: Mon, 17 Aug 2026 18:40:03 -0600 Subject: [PATCH] =?UTF-8?q?fix(tests):=20portable=20perms=20check=20?= =?UTF-8?q?=E2=80=94=20GNU=20stat=20first,=20BSD=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit register_flow "correct permissions" used `stat -f '%Lp' || stat -c '%a'`. On Linux `stat -f` prints filesystem status and exits 0, so the BSD-first form never falls through to the GNU form and the assert compared garbage instead of the mode — the test failed on the Linux CI runner (the code's chmod 600 is correct). Try GNU `stat -c` first, BSD `stat -f` as the macOS fallback. Co-Authored-By: Claude Opus 4.8 --- tests/integration/register_flow.bats | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration/register_flow.bats b/tests/integration/register_flow.bats index 6764e1a..5290425 100644 --- a/tests/integration/register_flow.bats +++ b/tests/integration/register_flow.bats @@ -45,9 +45,12 @@ setup() { run bash "${SCRIPTS_DIR}/amp-register.sh" --provider crabmail.ai --user-key "uk_testkey123" assert_success - # Check permissions (should be 600 - owner read/write only) + # Check permissions (should be 600 - owner read/write only). + # GNU stat (-c) first, BSD/macOS stat (-f) as fallback: on Linux `stat -f` + # does NOT fail (it prints filesystem status and exits 0), so a BSD-first + # order never reaches the GNU fallback and the assert compares garbage. local perms - perms=$(stat -f '%Lp' "${AMP_DIR}/registrations/crabmail.ai.json" 2>/dev/null || stat -c '%a' "${AMP_DIR}/registrations/crabmail.ai.json" 2>/dev/null) + perms=$(stat -c '%a' "${AMP_DIR}/registrations/crabmail.ai.json" 2>/dev/null || stat -f '%Lp' "${AMP_DIR}/registrations/crabmail.ai.json" 2>/dev/null) assert_equal "$perms" "600" }