misc, test: Some quality of life improvements

Add a fold in github actions output around the ragel build.

Run the commit-message test locally, so that error can be detected
before pushing to CI. We also now accept two-letter topics.

Some minor improvement in the testing scripts.
This commit is contained in:
Felix Frank
2024-03-01 19:28:38 +01:00
committed by James Shubin
parent 29ec867ac7
commit edcb04d1a9
4 changed files with 23 additions and 11 deletions

View File

@@ -114,6 +114,7 @@ if ! in_env; then
fi fi
if in_env; then if in_env; then
fold_start "Build ragel"
# TODO: consider bumping to new package manager version # TODO: consider bumping to new package manager version
RAGEL_VERSION='6.10' # current stable version RAGEL_VERSION='6.10' # current stable version
RAGEL_TMP='/tmp/ragel/' RAGEL_TMP='/tmp/ragel/'
@@ -129,6 +130,7 @@ if in_env; then
make make
sudo make install sudo make install
cd - cd -
fold_end "Build ragel"
fi fi
# attempt to workaround old ubuntu # attempt to workaround old ubuntu

View File

@@ -31,7 +31,8 @@ function run-testsuite() {
# if not running all tests or if this test is not explicitly selected, skip it # if not running all tests or if this test is not explicitly selected, skip it
if test -z "$testsuite" || test "test-$testsuite" = "$testname"; then if test -z "$testsuite" || test "test-$testsuite" = "$testname"; then
fold_start "$testname" fold_start "$testname"
"$@" || failures=$([ -n "$failures" ] && echo "$failures\\n$@" || echo "$@") description="$testname ($@)"
"$@" || failures=$([ -n "$failures" ] && echo "$failures\\n$description" || echo "$description")
fold_end "$testname" fold_end "$testname"
fi fi
} }

View File

@@ -10,11 +10,12 @@ echo running "$0"
ROOT=$(dirname "${BASH_SOURCE}")/.. ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${ROOT}" || exit 1 cd "${ROOT}" || exit 1
commit_title_regex='^\([a-z0-9]\(\(, \)\|[a-z0-9]\)\+[a-z0-9]: \)\+[A-Z0-9][^:]\+[^:.]$' commit_title_regex='^\([a-z0-9]\(\(, \)\|[a-z0-9]\)*[a-z0-9]: \)\+[A-Z0-9][^:]\+[^:.]$'
# Testing the regex itself. # Testing the regex itself.
# Correct patterns. # Correct patterns.
[[ $(echo "ci: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
[[ $(echo "foo, bar: Bar" | grep -c "$commit_title_regex") -eq 1 ]] [[ $(echo "foo, bar: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
[[ $(echo "foo: Bar" | grep -c "$commit_title_regex") -eq 1 ]] [[ $(echo "foo: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
[[ $(echo "f1oo, b2ar: Bar" | grep -c "$commit_title_regex") -eq 1 ]] [[ $(echo "f1oo, b2ar: Bar" | grep -c "$commit_title_regex") -eq 1 ]]
@@ -183,5 +184,13 @@ then
test_commit_message_common_bugs $commit test_commit_message_common_bugs $commit
done done
fi fi
else # assume local branch
commits=$(git log --no-merges --format=%H origin/master..HEAD)
for commit in $commits
do
test_commit_message $commit
test_commit_message_body $commit
test_commit_message_common_bugs $commit
done
fi fi
echo 'PASS' echo 'PASS'

View File

@@ -26,20 +26,20 @@ failures=""
count=0 count=0
# loop through tests # loop through tests
for i in $DIR/test/shell/*.sh; do for test_script in $DIR/test/shell/*.sh; do
[ -x "$i" ] || continue # file must be executable [ -x "$test_script" ] || continue # file must be executable
ii=`basename "$i"` # short name test_name=`basename "$test_script"` # short name
# if ARGV has test names, only execute those! # if ARGV has test names, only execute those!
if [ "$1" != '' ]; then if [ "$1" != '' ]; then
[ "$ii" != "$1" ] && continue [ "$test_name" != "$1" ] && continue
fi fi
cd $DIR/test/shell/ >/dev/null # shush the cd operation cd $DIR/test/shell/ >/dev/null # shush the cd operation
mkdir -p '/tmp/mgmt/' # directory for mgmt to put files in mkdir -p '/tmp/mgmt/' # directory for mgmt to put files in
#echo "Running: $ii" #echo "Running: $test_name"
export MGMT_TMPDIR='/tmp/mgmt/' # we can add to env like this export MGMT_TMPDIR='/tmp/mgmt/' # we can add to env like this
count=`expr $count + 1` count=`expr $count + 1`
set +o errexit # don't kill script on test failure set +o errexit # don't kill script on test failure
out=$($i 2>&1) # run and capture stdout & stderr out=$($test_script 2>&1) # run and capture stdout & stderr
e=$? # save exit code e=$? # save exit code
set -o errexit # re-enable killing on script failure set -o errexit # re-enable killing on script failure
cd - >/dev/null cd - >/dev/null
@@ -48,12 +48,12 @@ for i in $DIR/test/shell/*.sh; do
fi fi
rm -rf '/tmp/mgmt/' # clean up after test rm -rf '/tmp/mgmt/' # clean up after test
if [ $e -ne 0 ]; then if [ $e -ne 0 ]; then
echo -e "FAIL\t$ii" # fail echo -e "FAIL\t$test_name" # fail
# store failures... # store failures...
failures=$( failures=$(
# prepend previous failures if any # prepend previous failures if any
[ -n "${failures}" ] && echo "$failures" && echo "$LINE" [ -n "${failures}" ] && echo "$failures" && echo "$LINE"
echo "Script: $ii" echo "Script: $test_name"
# if we see 124, it might be the exit value of timeout! # if we see 124, it might be the exit value of timeout!
[ $e -eq 124 ] && echo "Exited: $e (timeout?)" || echo "Exited: $e" [ $e -eq 124 ] && echo "Exited: $e (timeout?)" || echo "Exited: $e"
if [ "$out" = "" ]; then if [ "$out" = "" ]; then
@@ -64,7 +64,7 @@ for i in $DIR/test/shell/*.sh; do
fi fi
) )
else else
echo -e "ok\t$ii" # pass echo -e "ok\t$test_name" # pass
fi fi
done done