#!/bin/sh
cd "$(dirname "$0")"

# rsync's runtests.sh expects (per upstream Makefile.in installcheck target):
#   rsync_bin   path to rsync to test (we use the installed one)
#   srcdir      directory containing the testsuite/ subdir
#   TOOLDIR     directory containing the test helper binaries (tls, ...)
# runtests.sh also sources ./shconfig (generated by configure at build time).
#
# rsync emits "PASS    name", "FAIL    name", "SKIP    name (reason)",
# "XFAIL   name"; ptest-runner expects "PASS: name" / "FAIL: name" /
# "SKIP: name". Transform on the fly. XFAIL is rsync's "expected fail"
# and is counted as failure upstream, but it is a known-bad test and not
# a regression, so report it as SKIP here so ptest does not fail on it.
POSIXLY_CORRECT=1 \
rsync_bin="$(command -v rsync)" \
srcdir="$(pwd)" \
TOOLDIR="$(pwd)" \
./runtests.sh 2>&1 | sed \
    -e 's/^PASS    \(.*\)/PASS: \1/' \
    -e 's/^FAIL    \(.*\)/FAIL: \1/' \
    -e 's/^XFAIL   \(.*\)/SKIP: \1 (xfail)/' \
    -e 's/^SKIP    \(.*\)/SKIP: \1/'
