From: Simon Ruderich Date: Tue, 24 Feb 2009 21:05:04 +0000 (+0100) Subject: Add tests for BSD which on Mac OS X. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=6137fc209dec361ff4e42a1be06ec03f33fdf11d;p=config%2Fdotfiles.git Add tests for BSD which on Mac OS X. This is additional to 4cb251564b860a64b316aba2cb3ab376ce6c36de. --- 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