tiny-moon-labs / guard-free-shipping

Public
Clone

https://git.dengel.dev/tiny-moon-labs/guard-free-shipping.git

Commit 0897557
#!/bin/sh
# Replay the two published versions in temporary directories. Requires Git and POSIX sh.
set -eu
repo=$(git rev-parse --show-toplevel)
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
trap 'exit 1' HUP INT TERM
replay() {
  label=$1 source=$2 expected=$3
  stage=$scratch/$label
  mkdir -p "$stage/checks"
  cp "$repo/checks/shipping.sh" "$stage/checks/shipping.sh"
  cp "$repo/$source" "$stage/shipping.sh"
  printf '\n%s (%s)\n' "$label" "$source"
  status=0
  (cd "$stage" && sh checks/shipping.sh) || status=$?
  printf 'Check exit code: %s\n' "$status"
  if [ "$status" -ne "$expected" ]; then
    echo "Expected exit code $expected. Replay did not match the published result." >&2
    exit 1
  fi
}
replay Bug examples/bug/shipping.sh 1
replay Fix shipping.sh 0