From 924951e426f1a5b113a0475f671854d20d8edef6 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Mon, 10 Aug 2020 15:41:49 -0400 Subject: [PATCH] Shell: Add test for 37d5e3e0df6 / #3073 --- Shell/Tests/sigpipe.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Shell/Tests/sigpipe.sh diff --git a/Shell/Tests/sigpipe.sh b/Shell/Tests/sigpipe.sh new file mode 100644 index 0000000000..e24fd731fb --- /dev/null +++ b/Shell/Tests/sigpipe.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# `head -n 1` should close stdout of the `Shell -c` command, which means the +# second echo should exit unsuccessfully and sigpipe.sh.out should not be +# created. +rm -f sigpipe.sh.out + +# FIXME: It'd be nice if there was a way to create a subshell that makes +# fewer assumptions about cwd and the build directory name. +Build/Meta/Lagom/shell -c 'echo foo && echo bar && echo baz > sigpipe.sh.out' | head -n 1 > /dev/null + +# Failing commands don't make the test fail, just an explicit `exit 1` does. +# So the test only fails if sigpipe.sh.out exists (since then `exit 1` runs), +# not if the `test` statement returns false. +test -e sigpipe.sh.out && exit 1