tests for allow/deny list for tasks
This commit is contained in:
parent
0b3e7e282a
commit
17f4b3e150
|
@ -51,18 +51,7 @@ function clean {
|
|||
if [ -f /tmp/forgebuild-host ]; then rm /tmp/forgebuild-host; fi
|
||||
}
|
||||
|
||||
function setup_submodule {
|
||||
SUBMODULE="$(mktemp -d)"
|
||||
cd $SUBMODULE
|
||||
git init
|
||||
echo "SUB" > README
|
||||
git add README
|
||||
git commit -m "first commit"
|
||||
|
||||
cd $GITREPO
|
||||
git submodule add $SUBMODULE sub
|
||||
git commit -m "add submodule"
|
||||
}
|
||||
# Simple repository
|
||||
|
||||
@test "repository is cloned" {
|
||||
$FORGEBUILD -b $FORGEBUILDDIR time
|
||||
|
@ -107,6 +96,8 @@ function setup_submodule {
|
|||
[[ "$TIME" != "$NEWTIME" ]]
|
||||
}
|
||||
|
||||
# Task settings
|
||||
|
||||
@test "host-based settings are loaded" {
|
||||
$FORGEBUILD -b $FORGEBUILDDIR host
|
||||
[[ "$(cat /tmp/forgebuild-host)" = "host" ]]
|
||||
|
@ -117,6 +108,49 @@ function setup_submodule {
|
|||
[[ "$(cat /tmp/forgebuild-host)" = "default" ]]
|
||||
}
|
||||
|
||||
@test "task only runs in allowlisted hosts" {
|
||||
# When t.hosts exist, only this (line-separated) list of hosts
|
||||
# runs the task
|
||||
echo "$HOSTNAME" > $FORGEBUILDDIR/time.hosts
|
||||
$FORGEBUILD -b $FORGEBUILDDIR time
|
||||
TIME="$(cat /tmp/forgebuild-time)"
|
||||
|
||||
# Doesn't run on unknown host
|
||||
HOST="UNKNOWN" $FORGEBUILD -b $FORGEBUILDDIR time
|
||||
NEWTIME="$(cat /tmp/forgebuild-time)"
|
||||
[[ "$TIME" = "$NEWTIME" ]]
|
||||
|
||||
echo "TESTHOST" >> $FORGEBUILDDIR/time.hosts
|
||||
# Force trigger because repo was not updated
|
||||
HOST="TESTHOST" $FORGEBUILD -f -b $FORGEBUILDDIR time
|
||||
NEWTIME="$(cat /tmp/forgebuild-time)"
|
||||
[[ "$TIME" != "$NEWTIME" ]]
|
||||
}
|
||||
|
||||
@test "task doesn't run in ignored host" {
|
||||
touch $FORGEBUILDDIR/$HOSTNAME/time.ignore
|
||||
$FORGEBUILD -b $FORGEBUILDDIR time
|
||||
[ ! -f /tmp/forgebuild-time ]
|
||||
|
||||
HOST="TESTHOST" $FORGEBUILD -f -b $FORGEBUILDDIR time
|
||||
[ -f /tmp/forgebuild-time ]
|
||||
}
|
||||
|
||||
# Repository with submodules
|
||||
|
||||
function setup_submodule {
|
||||
SUBMODULE="$(mktemp -d)"
|
||||
cd $SUBMODULE
|
||||
git init
|
||||
echo "SUB" > README
|
||||
git add README
|
||||
git commit -m "first commit"
|
||||
|
||||
cd $GITREPO
|
||||
git submodule add $SUBMODULE sub
|
||||
git commit -m "add submodule"
|
||||
}
|
||||
|
||||
@test "submodule is cloned" {
|
||||
setup_submodule
|
||||
$FORGEBUILD -b $FORGEBUILDDIR time
|
||||
|
|
Loading…
Reference in New Issue