From 617d77eccbb6c871c7653a879c6c6973a6b32e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstro=CC=88m?= Date: Thu, 22 Jan 2026 20:34:48 +0000 Subject: [PATCH] fix: make test_doc.sh pass on macOS The skip_if example in README.adoc produced different output on Linux vs macOS due to alphabetical test ordering. Renamed the test functions to sort consistently and added platform-specific output markers (`output-linux` and `output-darwin`) that `test_doc.sh` selects based on uname. --- README.adoc | 19 +++++++++++++------ tests/test_doc.sh | 6 +++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/README.adoc b/README.adoc index 84f847e..61d23db 100644 --- a/README.adoc +++ b/README.adoc @@ -671,19 +671,26 @@ This can be useful when one has tests that are dependent on system environment, skip_if "uname | grep Darwin" linux skip_if "uname | grep Linux" darwin -test_linux_proc_exists() { +test_1_linux_proc_exists() { assert "ls /proc/" "there should exist /proc on Linux" } -test_darwin_proc_does_not_exist() { +test_2_darwin_proc_does_not_exist() { assert_fail "ls /proc/" "there should not exist /proc on Darwin" } ``` -will output, on a Linux system: +will output on Linux: -```output - Running test_darwin_proc_does_not_exist ... SKIPPED - Running test_linux_proc_exists ... SUCCESS +```output-linux + Running test_1_linux_proc_exists ... SUCCESS + Running test_2_darwin_proc_does_not_exist ... SKIPPED +``` + +and on Darwin: + +```output-darwin + Running test_1_linux_proc_exists ... SKIPPED + Running test_2_darwin_proc_does_not_exist ... SUCCESS ``` == *fake* function diff --git a/tests/test_doc.sh b/tests/test_doc.sh index 47d086b..f5ce0ca 100644 --- a/tests/test_doc.sh +++ b/tests/test_doc.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash TEST_PATTERN='```test' -OUTPUT_PATTERN='```output' +if [[ "$(uname)" == "Darwin" ]]; then + OUTPUT_PATTERN='```output(-darwin)?' +else + OUTPUT_PATTERN='```output(-linux)?' +fi LANG=C.UTF-8 unset LC_ALL LANGUAGE