improve checks

This commit is contained in:
2026-11-04 10:11:29 -07:00
parent c33736775b
commit b41b70619d
7 changed files with 26 additions and 6 deletions
+7
View File
@@ -0,0 +1,7 @@
# Hooks, configure items and config files are sourced from paths only known at
# run time
disable=SC1090
# mkdir -p -m only sets the mode of the last directory; every use here makes
# one directory in a parent that already exists
disable=SC2174
+2
View File
@@ -56,6 +56,8 @@ while true; do
done done
save_config "$dir" save_config "$dir"
# For hook_path, from lib/hooks.sh
# shellcheck disable=SC2034
WORKING_COPY="$dir" WORKING_COPY="$dir"
echo "Working copy: $dir (saved in $CONFIG)" echo "Working copy: $dir (saved in $CONFIG)"
+2 -1
View File
@@ -9,7 +9,8 @@ CONFIG_DIR="$HOME/.config/coredesktop-dev"
CONFIG="$CONFIG_DIR/config" CONFIG="$CONFIG_DIR/config"
# First line after the shebang of the pre-push hook this project installs, so it # First line after the shebang of the pre-push hook this project installs, so it
# never overwrites or removes a hook someone else wrote # never overwrites or removes a hook someone else wrote. Used by hooks.sh.
# shellcheck disable=SC2034
HOOK_MARKER="# Installed by coredesktop-dev; remove with: coredesktop-dev hooks remove" HOOK_MARKER="# Installed by coredesktop-dev; remove with: coredesktop-dev hooks remove"
die() { die() {
+4 -2
View File
@@ -107,7 +107,7 @@ select_scenarios() {
} }
smoketest_run() { smoketest_run() {
local tier=pr ref=HEAD keep=0 names=() local tier="pr" ref=HEAD keep=0 names=()
while (( $# > 0 )); do while (( $# > 0 )); do
case "$1" in case "$1" in
--tier) tier="${2:-}"; shift 2 || die "--tier needs pr or all" ;; --tier) tier="${2:-}"; shift 2 || die "--tier needs pr or all" ;;
@@ -338,7 +338,9 @@ smoketest_shell() {
mkdir -p "$dir" mkdir -p "$dir"
qemu-img create -q -f qcow2 -b "$IMAGES/$image.qcow2" -F qcow2 "$dir/disk.qcow2" qemu-img create -q -f qcow2 -b "$IMAGES/$image.qcow2" -F qcow2 "$dir/disk.qcow2"
vm_start "$dir" "$dir/disk.qcow2" vm_start "$dir" "$dir/disk.qcow2"
trap 'vm_kill; rm -rf "$dir"' EXIT # Expanded now: $dir is local, and gone by the time the script exits
# shellcheck disable=SC2064
trap "vm_kill; rm -rf $(printf '%q' "$dir")" EXIT
echo "Starting a throwaway copy of the $image image..." echo "Starting a throwaway copy of the $image image..."
vm_wait_up vm_wait_up
vm_ssh -t vm_ssh -t
+5 -2
View File
@@ -5,10 +5,13 @@
# vm_exec, vm_put, vm_reboot, VM_GIT_SSH and VM_GIT_URL. # vm_exec, vm_put, vm_reboot, VM_GIT_SSH and VM_GIT_URL.
SMOKETEST_STATE="${XDG_CACHE_HOME:-$HOME/.cache}/coredesktop-dev/smoketest" SMOKETEST_STATE="${XDG_CACHE_HOME:-$HOME/.cache}/coredesktop-dev/smoketest"
# IMAGES and KVM_DEVICE are used by smoketest.sh
# shellcheck disable=SC2034
IMAGES="$SMOKETEST_STATE/images" IMAGES="$SMOKETEST_STATE/images"
# Shared with every VM as its /var/cache/pacman/pkg, so packages download once # Shared with every VM as its /var/cache/pacman/pkg, so packages download once
PKG_CACHE="$SMOKETEST_STATE/pkg" PKG_CACHE="$SMOKETEST_STATE/pkg"
SSH_KEY="$SMOKETEST_STATE/id_ed25519" SSH_KEY="$SMOKETEST_STATE/id_ed25519"
# shellcheck disable=SC2034
KVM_DEVICE="${KVM_DEVICE:-/dev/kvm}" KVM_DEVICE="${KVM_DEVICE:-/dev/kvm}"
VM_USER=tester VM_USER=tester
@@ -43,8 +46,8 @@ ensure_ssh_key() {
} }
free_port() { free_port() {
local port i local port
for i in $(seq 50); do for _ in $(seq 50); do
port=$((20000 + RANDOM % 20000)) port=$((20000 + RANDOM % 20000))
[ -z "$(ss -Hltn "( sport = :$port )" 2> /dev/null)" ] && { echo "$port"; return 0; } [ -z "$(ss -Hltn "( sport = :$port )" 2> /dev/null)" ] && { echo "$port"; return 0; }
done done
+4 -1
View File
@@ -27,11 +27,14 @@ setup() {
stub ss stub ss
stub ssh-keygen 'touch "${@: -1}" "${@: -1}.pub"' stub ssh-keygen 'touch "${@: -1}" "${@: -1}.pub"'
stub systemctl stub systemctl
# Like a real SSH session, the command gets no controlling terminal: the
# driver runs bash -i, which would otherwise try to take over the one bats
# runs in, and be stopped for it
stub ssh 'while [ $# -gt 0 ]; do stub ssh 'while [ $# -gt 0 ]; do
case "$1" in -i | -o | -p) shift 2 ;; *@*) shift; break ;; *) shift ;; esac case "$1" in -i | -o | -p) shift 2 ;; *@*) shift; break ;; *) shift ;; esac
done done
[ $# -gt 0 ] || exit 0 [ $# -gt 0 ] || exit 0
cd "$HOME" && exec bash -c "$*"' cd "$HOME" && exec setsid -w bash -c "$*"'
stub scp 'dest="${*: -1}"; cp "${@: -2:1}" "${dest#*:}"' stub scp 'dest="${*: -1}"; cp "${@: -2:1}" "${dest#*:}"'
SC="$WC/smoketest/scenarios" SC="$WC/smoketest/scenarios"
+2
View File
@@ -9,6 +9,8 @@
# shellcheck disable=SC2034 # shellcheck disable=SC2034
PROJECT="$(cd "$BATS_TEST_DIRNAME/.." && pwd)" PROJECT="$(cd "$BATS_TEST_DIRNAME/.." && pwd)"
# UPSTREAM, DEPLOYED and WC are used by the .bats files
# shellcheck disable=SC2034
common_setup() { common_setup() {
export HOME="$BATS_TEST_TMPDIR/home" export HOME="$BATS_TEST_TMPDIR/home"
export STUB_BIN="$BATS_TEST_TMPDIR/bin" export STUB_BIN="$BATS_TEST_TMPDIR/bin"