Skip to content

Commit 617d77e

Browse files
committed
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.
1 parent fc682d5 commit 617d77e

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

README.adoc

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,19 +671,26 @@ This can be useful when one has tests that are dependent on system environment,
671671
skip_if "uname | grep Darwin" linux
672672
skip_if "uname | grep Linux" darwin
673673

674-
test_linux_proc_exists() {
674+
test_1_linux_proc_exists() {
675675
assert "ls /proc/" "there should exist /proc on Linux"
676676
}
677-
test_darwin_proc_does_not_exist() {
677+
test_2_darwin_proc_does_not_exist() {
678678
assert_fail "ls /proc/" "there should not exist /proc on Darwin"
679679
}
680680
```
681681

682-
will output, on a Linux system:
682+
will output on Linux:
683683

684-
```output
685-
Running test_darwin_proc_does_not_exist ... SKIPPED
686-
Running test_linux_proc_exists ... SUCCESS
684+
```output-linux
685+
Running test_1_linux_proc_exists ... SUCCESS
686+
Running test_2_darwin_proc_does_not_exist ... SKIPPED
687+
```
688+
689+
and on Darwin:
690+
691+
```output-darwin
692+
Running test_1_linux_proc_exists ... SKIPPED
693+
Running test_2_darwin_proc_does_not_exist ... SUCCESS
687694
```
688695

689696
== *fake* function

tests/test_doc.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/usr/bin/env bash
22

33
TEST_PATTERN='```test'
4-
OUTPUT_PATTERN='```output'
4+
if [[ "$(uname)" == "Darwin" ]]; then
5+
OUTPUT_PATTERN='```output(-darwin)?'
6+
else
7+
OUTPUT_PATTERN='```output(-linux)?'
8+
fi
59
LANG=C.UTF-8
610
unset LC_ALL LANGUAGE
711

0 commit comments

Comments
 (0)