merge-recursive: flush output buffer even when erroring out
[gitweb.git] / t / test-lib-functions.sh
index 15ef3f816c64521628157a5a1d96d42fa5ca8720..4f7eadb5963e7d698f9ee6e265b1657e543cdb44 100644 (file)
@@ -612,7 +612,7 @@ test_must_fail () {
        then
                echo >&2 "test_must_fail: command succeeded: $*"
                return 1
-       elif test $exit_code -eq 141 && list_contains "$_test_ok" sigpipe
+       elif test_match_signal 13 $exit_code && list_contains "$_test_ok" sigpipe
        then
                return 0
        elif test $exit_code -gt 129 && test $exit_code -le 192
@@ -976,3 +976,17 @@ test_match_signal () {
        fi
        return 1
 }
+
+# Read up to "$1" bytes (or to EOF) from stdin and write them to stdout.
+test_copy_bytes () {
+       perl -e '
+               my $len = $ARGV[1];
+               while ($len > 0) {
+                       my $s;
+                       my $nread = sysread(STDIN, $s, $len);
+                       die "cannot read: $!" unless defined($nread);
+                       print $s;
+                       $len -= $nread;
+               }
+       ' - "$1"
+}