Files
radicle-native-ci/test.sh
T
2024-01-04 19:19:39 +02:00

53 lines
946 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
die() {
echo "$@" 2>&1
exit 1
}
expect_failure() {
if cargo run -q <"$tmp/test-request.yaml" >"$tmp/test.stdout" 2>"$tmp/test.stderr"; then
echo "$tmp/test.log:"
cat "$tmp/test.log"
echo
echo "test.stdout:"
cat "$tmp/test.stdout"
echo
echo "test.stderr:"
cat "$tmp/test.stderr"
die "success, when expected failure"
fi
}
cargo build --all-targets --quiet
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
export TMPDIR="$tmp"
cat <<EOF >"$tmp/config.yaml"
state: $tmp/test.state
log: $tmp/test.log
EOF
export RADICLE_NATIVE_CI="$tmp/config.yaml"
export RADICLE_NATIVE_CI_LOG=debug
python3 test.py --commit b3a9a809420c89d08460046683f33d8a5bdfdc0a >"$tmp/test-request.yaml"
expect_failure
# find "$tmp/test.state" -type f | grep -vF /.git/
# cat "$tmp/test.state/index.html"
# echo "test.log"
# cat "$tmp/test.log"
# echo
# echo "log.txt"
# cat "$tmp/test.state"/*/log.txt
echo All good.