ladybird/Userland/Shell/Tests/builtin-redir.sh
Andrew Kaster 8fc862f710 Userland: Install shell tests on Serenity
Also make them runnable anywhere. Previously they required $PWD to be
the directory containing test-commons.inc, and for $PWD to be writable.
2021-02-28 18:19:37 +01:00

21 lines
631 B
Bash

#!/bin/sh
source $(dirname "$0")/test-commons.inc
rm -rf shell-test
mkdir -p shell-test
cd shell-test
time sleep 1 2>timeerr >timeout
cat timeout
# We cannot be sure about the values, so just assert that they're not empty.
if not test -n "$(cat timeerr)" { fail "'time' stderr output not redirected correctly" }
if not test -e timeout { fail "'time' stdout output not redirected correctly" }
time ls 2> /dev/null | head > timeout
if not test -n "$(cat timeout)" { fail "'time' stdout not piped correctly" }
cd ..
rm -rf shell-test # TODO: Remove this file at the end once we have `trap'
echo PASS