|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +if [[ $# -ne 3 ]]; then |
| 6 | + echo "usage: $0 <version> <commit> <archive-directory>" >&2 |
| 7 | + exit 2 |
| 8 | +fi |
| 9 | + |
| 10 | +version=$1 |
| 11 | +commit=$2 |
| 12 | +archive_directory=$3 |
| 13 | + |
| 14 | +case "$(uname -s)/$(uname -m)" in |
| 15 | + Darwin/x86_64) target=darwin_amd64 ;; |
| 16 | + Darwin/arm64) target=darwin_arm64 ;; |
| 17 | + Linux/x86_64) target=linux_amd64 ;; |
| 18 | + Linux/aarch64 | Linux/arm64) target=linux_arm64 ;; |
| 19 | + *) |
| 20 | + echo "unsupported smoke-test platform: $(uname -s)/$(uname -m)" >&2 |
| 21 | + exit 2 |
| 22 | + ;; |
| 23 | +esac |
| 24 | + |
| 25 | +archive="bible-terminal_${version#v}_${target}.tar.gz" |
| 26 | +archive_path="$archive_directory/$archive" |
| 27 | +checksums_path="$archive_directory/checksums.txt" |
| 28 | +if [[ ! -f $archive_path || ! -f $checksums_path ]]; then |
| 29 | + echo "release archive or checksum file is missing for $target" >&2 |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +( |
| 34 | + cd "$archive_directory" |
| 35 | + checksum_line=$( |
| 36 | + awk -v archive="$archive" ' |
| 37 | + $2 == archive { print; found = 1 } |
| 38 | + END { if (!found) exit 1 } |
| 39 | + ' checksums.txt |
| 40 | + ) |
| 41 | + if command -v sha256sum >/dev/null 2>&1; then |
| 42 | + printf '%s\n' "$checksum_line" | sha256sum --check - |
| 43 | + else |
| 44 | + printf '%s\n' "$checksum_line" | shasum -a 256 --check - |
| 45 | + fi |
| 46 | +) |
| 47 | + |
| 48 | +temp_root=${TMPDIR:-/tmp} |
| 49 | +temp_root=${temp_root%/} |
| 50 | +work=$(mktemp -d "$temp_root/bible-terminal-smoke.XXXXXX") |
| 51 | +trap 'rm -rf "$work"' EXIT |
| 52 | +tar -xzf "$archive_path" -C "$work" |
| 53 | +bible="$work/bible" |
| 54 | +config_home="$work/config" |
| 55 | + |
| 56 | +test -x "$bible" |
| 57 | +version_output=$("$bible" version) |
| 58 | +grep -F "bible $version" <<<"$version_output" |
| 59 | +grep -F "commit: $commit" <<<"$version_output" |
| 60 | + |
| 61 | +config_path=$(BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" config path) |
| 62 | +test "$config_path" = "$config_home/config.json" |
| 63 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" config set plain true |
| 64 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" config set color false |
| 65 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" --plain config show | |
| 66 | + grep -F $'translation\tengwebp' |
| 67 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" --plain config show | |
| 68 | + grep -F $'plain\ttrue' |
| 69 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" --plain config show | |
| 70 | + grep -F $'color\tfalse' |
| 71 | + |
| 72 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" read "John 3:16" | |
| 73 | + grep -F "For God so loved the world" |
| 74 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" search "God loved world" --limit 1 | |
| 75 | + grep -F "John 3:16" |
| 76 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" completion bash | |
| 77 | + grep -F "__start_bible" |
| 78 | + |
| 79 | +BIBLE_TERMINAL_CONFIG_HOME="$config_home" "$bible" config reset |
| 80 | +test ! -e "$config_home/config.json" |
0 commit comments