From 63fba988ada5d54cafe8e276914ce6a5791a4ae1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 30 Dec 2019 12:50:30 +0000 Subject: [PATCH] tests: Provide advance-tested script Useful for our own testing. Signed-off-by: Ian Jackson --- tests/advance-tested | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 tests/advance-tested diff --git a/tests/advance-tested b/tests/advance-tested new file mode 100755 index 0000000..fc38869 --- /dev/null +++ b/tests/advance-tested @@ -0,0 +1,39 @@ +#!/bin/bash +# subdirmk - test suite runner helper script +# Copyright various contributors - see top level README. +# SPDX-License-Identifier: LGPL-2.0-or-later +# There is NO WARRANTY. + +set -e + +branch=$(git symbolic-ref -q HEAD || test $? = 1) +base=$(git merge-base tested HEAD) + +git branch -D test-failed 2>&1 ||: + +case "$branch" in +refs/heads/tested|refs/heads/test-failed) + echo >&2 "unexpectedly on branch $branch"; exit 1 ;; +refs/heads/*) + branch=${branch#refs/heads/} ;; +*) + branch=''; +esac + +restore-branch () { + if [ "$branch" ]; then git checkout $branch; fi +} + +git checkout --detach +git clean -xdff + +if ! git rebase --exec 'tests/check && git branch -f tested' $base; then + git branch -f test-failed + git rebase --abort + echo >&2 '^ ignore previous message from git-rebase!' + echo >&2 'Test failed, made local branch ref test-failed' + restore-branch + exit 1 +fi + +restore-branch -- 2.30.2