Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Thunderbird/scripts/ci/pr-sentinel/tests/   (Thunderbird Email Client Version 5.6©)  Datei vom 22.9.2026 mit Größe 1 kB image not shown  

Quelle  dryrun_test.sh   Sprache: Shell

 

#!/usr/bin/env bash
set -uo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "${DIR}/tests/_asserts.sh"

# Fake `gh` on PATH that records each invocation to a log file.
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
cat >"${tmp}/gh" <<'EOF'
#!/usr/bin/env bash
echo "REAL_GH $*" >>"$GH_CALL_LOG"
EOF
chmod +x "${tmp}/gh"
export PATH="${tmp}:${PATH}"
export GH_CALL_LOG="${tmp}/calls.log"

source "${DIR}/lib.sh"

test_dry_run_skips_gh() { # gh must NOT be invoked; a notice is printed to stderr
  local err
  : >"$GH_CALL_LOG"
  DRY_RUN=1
  err="$(gh_write api -X POST 'repos/o/r/issues/1/comments' -f body=x 2>&1 >/dev/null)"
  assert_eq       "$(wc -l <"$GH_CALL_LOG" | tr -d ' ')" "0" "dry-run does not invoke gh"
  assert_contains "$err" "[dry-run]" "dry-run prints a notice"
}

test_real_mode_invokes_gh() { # gh IS invoked
  : >"$GH_CALL_LOG"
  DRY_RUN=0
  gh_write api -X POST 'repos/o/r/issues/1/comments' -f body=x
  assert_contains "$(cat "$GH_CALL_LOG")" "REAL_GH api -X POST" "real mode invokes gh"
}

main() {
  test_dry_run_skips_gh
  test_real_mode_invokes_gh

  if [[ "$fail" -ne 0 ]]; then echo "TESTS FAILED"; exit 1; fi
  echo "ALL TESTS PASSED"
}

main

Messung
CHZG
859110092

¤ Dauer der Verarbeitung: 0.1 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.