Fix macOS compatibility: Add portable timeout helper

- Add utils.sh with cross-platform timeout functions for macOS compatibility
- Fix sf-logs-tail to use portable_timeout instead of GNU timeout command
- Fix test-all-wrappers.sh to use portable_timeout_seconds for testing
- Update README.md with macOS compatibility documentation

The timeout command is not available by default on macOS, causing
sf-logs-tail and test scripts to fail. The new utils.sh provides
fallback timeout functionality that works on Linux, macOS with/without
GNU coreutils, maintaining exit code 124 compatibility.
This commit is contained in:
reynold
2025-08-28 21:08:58 +08:00
parent 159ede3794
commit ca98742891
4 changed files with 125 additions and 2 deletions

View File

@@ -4,6 +4,9 @@ set -euo pipefail
# Comprehensive Test Suite for SF CLI Wrapper Scripts
# Tests all scenarios with 100% coverage using PWC-TEAM-DEV org
# Source utilities for cross-platform compatibility
source "$(dirname "$0")/utils.sh"
readonly TEST_ORG="PWC-TEAM-DEV"
readonly GREEN='\033[0;32m'
readonly RED='\033[0;31m'
@@ -182,7 +185,7 @@ echo ""
echo -e "${BLUE}=== Testing sf-logs-tail (quick test) ===${NC}"
# Test logs tail for a very short duration
run_test "sf-logs-tail short duration" "timeout 5s ./sf-logs-tail -to $TEST_ORG --duration 1 || true"
run_test "sf-logs-tail short duration" "portable_timeout_seconds 5 ./sf-logs-tail -to $TEST_ORG --duration 1 || true"
echo ""
echo -e "${BLUE}=== Test Results Summary ===${NC}"