Tests: Refactoring: Extract invalidate_action() into actions-test-lib

We don't "shamelessly steal" code, we refactoring it ;-)
This commit is contained in:
Ingo Karkat
2022-06-18 10:55:04 +02:00
parent 1a5600c79c
commit bab2af9501
2 changed files with 18 additions and 17 deletions

View File

@@ -34,3 +34,19 @@ echo "custom action $1 in folder $1"
EOF EOF
chmod +x ".todo.actions.d/$1/$1" chmod +x ".todo.actions.d/$1/$1"
} }
invalidate_action()
{
local customActionFilespec="${1:?}"; shift
local testName="${1:?}"; shift
chmod -x "$customActionFilespec"
# On Cygwin, clearing the executable flag may have no effect, as the Windows
# ACL may still grant execution rights. In this case, we skip the test, and
# remove the (still valid) custom action so that it doesn't break following
# tests.
if [ -x "$customActionFilespec" ]; then
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }${testName}"
rm -- "$customActionFilespec"
fi
}

View File

@@ -28,14 +28,7 @@ ls
quux quux
EOF EOF
chmod -x .todo.actions.d/foo invalidate_action .todo.actions.d/foo t8010.4
# On Cygwin, clearing the executable flag may have no effect, as the Windows ACL
# may still grant execution rights. In this case, we skip the test, and remove
# the (still valid) custom action so that it doesn't break following tests.
if [ -x .todo.actions.d/foo ]; then
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }t8010.4"
rm .todo.actions.d/foo
fi
test_todo_session 'nonexecutable action' <<EOF test_todo_session 'nonexecutable action' <<EOF
>>> todo.sh listaddons >>> todo.sh listaddons
bar bar
@@ -68,15 +61,7 @@ norris
quux quux
EOF EOF
# nthorne: shamelessly stolen from above.. invalidate_action .todo.actions.d/norris/norris t8010.8
chmod -x .todo.actions.d/norris/norris
# On Cygwin, clearing the executable flag may have no effect, as the Windows ACL
# may still grant execution rights. In this case, we skip the test, and remove
# the (still valid) custom action so that it doesn't break following tests.
if [ -x .todo.actions.d/norris/norris ]; then
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }t8010.8"
rm .todo.actions.d/norris/norris
fi
test_todo_session 'nonexecutable action in subfolder' <<EOF test_todo_session 'nonexecutable action in subfolder' <<EOF
>>> todo.sh listaddons >>> todo.sh listaddons
bar bar