From 6137fc209dec361ff4e42a1be06ec03f33fdf11d Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 24 Feb 2009 22:05:04 +0100 Subject: [PATCH] Add tests for BSD which on Mac OS X. This is additional to 4cb251564b860a64b316aba2cb3ab376ce6c36de. --- tests/lib.sh.test | 16 +++++++++++++++- tests/lib.sh.test.out | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/lib.sh.test b/tests/lib.sh.test index 03184a0..91aef01 100644 --- a/tests/lib.sh.test +++ b/tests/lib.sh.test @@ -1,7 +1,21 @@ +# Tests for lib.sh. . ../lib.sh -# Tests for installed(). +# Tests for installed() with hopefully proper exit codes (1 if the program was +# not found). +installed ls && echo ls installed +installed doesnt-exist && echo doesnt-exist installed +# Simulate BSD `which` like on Mac OS X which doesn't use exit codes. +function which() { + echo Mac OS X which for $1 >&2 + if [ $1 = ls ]; then + echo /bin/ls + else + echo no doesnt-exist in /usr/bin /bin /usr/sbin /sbin + fi +} +# Tests for installed() without exit codes. installed ls && echo ls installed installed doesnt-exist && echo doesnt-exist installed diff --git a/tests/lib.sh.test.out b/tests/lib.sh.test.out index faa564d..8d39aab 100644 --- a/tests/lib.sh.test.out +++ b/tests/lib.sh.test.out @@ -1 +1,4 @@ ls installed +Mac OS X which for ls +ls installed +Mac OS X which for doesnt-exist -- 2.44.1