Ensure correct working dir for the tasks

This commit is contained in:
southerntofu 2020-11-25 17:51:31 +01:00
parent cbc8fd60eb
commit 63745cdf54
2 changed files with 31 additions and 0 deletions

View File

@ -33,6 +33,9 @@ function setup {
echo "$GITREPO" > $FORGEBUILDDIR/branch.source
echo "cat \$GITBUILDDIR/.branch/branch > /tmp/forgebuild-branch" > $FORGEBUILDDIR/branch
chmod +x $FORGEBUILDDIR/branch
echo "echo \$(pwd) > /tmp/forgebuild-pwd" > $FORGEBUILDDIR/pwd
chmod +x $FORGEBUILDDIR/pwd
echo "$GITREPO" > $FORGEBUILDDIR/pwd.source
# Setup settings
mkdir $FORGEBUILDDIR/config
@ -51,6 +54,7 @@ function clean {
if [ -f /tmp/forgebuild-time ]; then rm /tmp/forgebuild-time; fi
if [ -f /tmp/forgebuild-host ]; then rm /tmp/forgebuild-host; fi
if [ -f /tmp/forgebuild-branch ]; then rm /tmp/forgebuild-branch; fi
if [ -f /tmp/forgebuild-pwd ]; then rm /tmp/forgebuild-pwd; fi
}
# Simple repository
@ -65,6 +69,18 @@ function clean {
[ -f /tmp/forgebuild-time ]
}
@test "task is run from within its source folder" {
$FORGEBUILD -b $FORGEBUILDDIR pwd
PWD="$(cat /tmp/forgebuild-pwd)"
[[ "$PWD" = "$FORGEBUILDDIR/.pwd" ]]
}
@test "after running, back to the previous working dir" {
cd /tmp
$FORGEBUILD -b $FORGEBUILDDIR pwd
[[ "$(pwd)" = "/tmp" ]]
}
@test "no update does not trigger task" {
$FORGEBUILD -b $FORGEBUILDDIR time
[ -f /tmp/forgebuild-time ]

View File

@ -17,6 +17,8 @@ function setup {
mkdir $FORGEBUILDDIR
echo "date +%s%N > /tmp/forgebuild-time" > $FORGEBUILDDIR/time
chmod +x $FORGEBUILDDIR/time
echo "echo \$(pwd) > /tmp/forgebuild-pwd" > $FORGEBUILDDIR/pwd
chmod +x $FORGEBUILDDIR/pwd
# Setup settings
mkdir $FORGEBUILDDIR/config
@ -47,6 +49,19 @@ function clean {
[[ "$TIME" = "$NEWTIME" ]]
}
@test "sourceless task working dir is FORGEBUILDDIR" {
$FORGEBUILD -b $FORGEBUILDDIR pwd
PWD="$(cat /tmp/forgebuild-pwd)"
cp /tmp/forgebuild-pwd{,-2}
[[ "$PWD" = "$FORGEBUILDDIR" ]]
}
@test "after running, back to the previous working dir" {
cd /tmp
$FORGEBUILD -b $FORGEBUILDDIR pwd
[[ "$(pwd)" = "/tmp" ]]
}
@test "sourceless task is not forced triggered by --force flag" {
$FORGEBUILD -b $FORGEBUILDDIR time
[ -f /tmp/forgebuild-time ]