improve checks
This commit is contained in:
@@ -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
|
||||
@@ -56,6 +56,8 @@ while true; do
|
||||
done
|
||||
|
||||
save_config "$dir"
|
||||
# For hook_path, from lib/hooks.sh
|
||||
# shellcheck disable=SC2034
|
||||
WORKING_COPY="$dir"
|
||||
echo "Working copy: $dir (saved in $CONFIG)"
|
||||
|
||||
|
||||
+2
-1
@@ -9,7 +9,8 @@ CONFIG_DIR="$HOME/.config/coredesktop-dev"
|
||||
CONFIG="$CONFIG_DIR/config"
|
||||
|
||||
# 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"
|
||||
|
||||
die() {
|
||||
|
||||
+4
-2
@@ -107,7 +107,7 @@ select_scenarios() {
|
||||
}
|
||||
|
||||
smoketest_run() {
|
||||
local tier=pr ref=HEAD keep=0 names=()
|
||||
local tier="pr" ref=HEAD keep=0 names=()
|
||||
while (( $# > 0 )); do
|
||||
case "$1" in
|
||||
--tier) tier="${2:-}"; shift 2 || die "--tier needs pr or all" ;;
|
||||
@@ -338,7 +338,9 @@ smoketest_shell() {
|
||||
mkdir -p "$dir"
|
||||
qemu-img create -q -f qcow2 -b "$IMAGES/$image.qcow2" -F qcow2 "$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..."
|
||||
vm_wait_up
|
||||
vm_ssh -t
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
# vm_exec, vm_put, vm_reboot, VM_GIT_SSH and VM_GIT_URL.
|
||||
|
||||
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"
|
||||
# Shared with every VM as its /var/cache/pacman/pkg, so packages download once
|
||||
PKG_CACHE="$SMOKETEST_STATE/pkg"
|
||||
SSH_KEY="$SMOKETEST_STATE/id_ed25519"
|
||||
# shellcheck disable=SC2034
|
||||
KVM_DEVICE="${KVM_DEVICE:-/dev/kvm}"
|
||||
|
||||
VM_USER=tester
|
||||
@@ -43,8 +46,8 @@ ensure_ssh_key() {
|
||||
}
|
||||
|
||||
free_port() {
|
||||
local port i
|
||||
for i in $(seq 50); do
|
||||
local port
|
||||
for _ in $(seq 50); do
|
||||
port=$((20000 + RANDOM % 20000))
|
||||
[ -z "$(ss -Hltn "( sport = :$port )" 2> /dev/null)" ] && { echo "$port"; return 0; }
|
||||
done
|
||||
|
||||
@@ -27,11 +27,14 @@ setup() {
|
||||
stub ss
|
||||
stub ssh-keygen 'touch "${@: -1}" "${@: -1}.pub"'
|
||||
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
|
||||
case "$1" in -i | -o | -p) shift 2 ;; *@*) shift; break ;; *) shift ;; esac
|
||||
done
|
||||
[ $# -gt 0 ] || exit 0
|
||||
cd "$HOME" && exec bash -c "$*"'
|
||||
cd "$HOME" && exec setsid -w bash -c "$*"'
|
||||
stub scp 'dest="${*: -1}"; cp "${@: -2:1}" "${dest#*:}"'
|
||||
|
||||
SC="$WC/smoketest/scenarios"
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
# shellcheck disable=SC2034
|
||||
PROJECT="$(cd "$BATS_TEST_DIRNAME/.." && pwd)"
|
||||
|
||||
# UPSTREAM, DEPLOYED and WC are used by the .bats files
|
||||
# shellcheck disable=SC2034
|
||||
common_setup() {
|
||||
export HOME="$BATS_TEST_TMPDIR/home"
|
||||
export STUB_BIN="$BATS_TEST_TMPDIR/bin"
|
||||
|
||||
Reference in New Issue
Block a user