Don't leak temp files
This commit is contained in:
parent
977a20da88
commit
cbc8fd60eb
|
@ -6,17 +6,15 @@
|
|||
|
||||
function setup {
|
||||
ORIGDIR="$(pwd)"
|
||||
TMPDIR="$(mktemp -d)"
|
||||
|
||||
# If no $FORGEBUILD is supplied in ENV, use the default
|
||||
# (otherwise you can't `bats ./tests/` manually)
|
||||
[ -z "$FORGEBUILD" ] && FORGEBUILD="forgebuild"
|
||||
|
||||
# Ensure output from previous test does not exist
|
||||
# (in case something crashed)
|
||||
clean
|
||||
|
||||
# Setup simple git repository
|
||||
GITREPO="$(mktemp -d)"
|
||||
GITREPO="$TMPDIR"/git
|
||||
mkdir $GITREPO
|
||||
cd $GITREPO
|
||||
git init
|
||||
echo "first commit" > README
|
||||
|
@ -24,7 +22,8 @@ function setup {
|
|||
git commit -m "first commit"
|
||||
|
||||
# Setup forgebuild tasks
|
||||
FORGEBUILDDIR="$(mktemp -d)"
|
||||
FORGEBUILDDIR="$TMPDIR"/forgebuild
|
||||
mkdir $FORGEBUILDDIR
|
||||
echo "$GITREPO" > $FORGEBUILDDIR/time.source
|
||||
echo "date +%s%N > /tmp/forgebuild-time" > $FORGEBUILDDIR/time
|
||||
chmod +x $FORGEBUILDDIR/time
|
||||
|
@ -48,9 +47,7 @@ function teardown {
|
|||
}
|
||||
|
||||
function clean {
|
||||
if [ -d $GITREPO ]; then rm -rf $GITREPO; fi
|
||||
if [ -d $FORGEBUILDDIR ]; then rm -rf $FORGEBUILDDIR; fi
|
||||
if [ -d $SUBMODULE ]; then rm -rf $SUBMODULE; fi
|
||||
if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi
|
||||
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
|
||||
|
@ -101,8 +98,8 @@ function clean {
|
|||
}
|
||||
|
||||
@test "update can mix source URL and task name" {
|
||||
git init $BATS_TMPDIR/newrepo
|
||||
echo "$BATS_TMPDIR/newrepo" > "$FORGEBUILDDIR"/branch.source
|
||||
git init $TMPDIR/newrepo
|
||||
echo "$TMPDIR/newrepo" > "$FORGEBUILDDIR"/branch.source
|
||||
$FORGEBUILD -b $FORGEBUILDDIR "$GITREPO" "branch"
|
||||
[ -f /tmp/forgebuild-host ]
|
||||
[ -f /tmp/forgebuild-time ]
|
||||
|
@ -179,7 +176,8 @@ function clean {
|
|||
# Repository with submodules
|
||||
|
||||
function setup_submodule {
|
||||
SUBMODULE="$(mktemp -d)"
|
||||
export SUBMODULE="$TMPDIR"/submodule
|
||||
mkdir $SUBMODULE
|
||||
cd $SUBMODULE
|
||||
git init
|
||||
echo "SUB" > README
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
|
||||
function setup {
|
||||
ORIGDIR="$(pwd)"
|
||||
TMPDIR="$(mktemp -d)"
|
||||
|
||||
# If no $FORGEBUILD is supplied in ENV, use the default
|
||||
# (otherwise you can't `bats ./tests/` manually)
|
||||
[ -z "$FORGEBUILD" ] && FORGEBUILD="forgebuild"
|
||||
|
||||
# Ensure output from previous test does not exist
|
||||
# (in case something crashed)
|
||||
clean
|
||||
|
||||
# Setup simple git repository
|
||||
REPO="$(mktemp -d)"
|
||||
REPO="$TMPDIR"/hg
|
||||
mkdir $REPO
|
||||
cd $REPO
|
||||
hg init
|
||||
echo "first commit" > README
|
||||
|
@ -24,7 +22,8 @@ function setup {
|
|||
hg commit -m "first commit"
|
||||
|
||||
# Setup forgebuild tasks
|
||||
FORGEBUILDDIR="$(mktemp -d)"
|
||||
FORGEBUILDDIR="$TMPDIR"/forgebuild
|
||||
mkdir $FORGEBUILDDIR
|
||||
echo "$REPO" > $FORGEBUILDDIR/time.source
|
||||
echo "mercurial" > $FORGEBUILDDIR/time.dvcs
|
||||
echo "date +%s%N > /tmp/forgebuild-time" > $FORGEBUILDDIR/time
|
||||
|
@ -51,8 +50,7 @@ function teardown {
|
|||
}
|
||||
|
||||
function clean {
|
||||
if [ -d $REPO ]; then rm -rf $GITREPO; fi
|
||||
if [ -d $FORGEBUILDDIR ]; then rm -rf $FORGEBUILDDIR; fi
|
||||
if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi
|
||||
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
|
||||
|
|
|
@ -6,17 +6,15 @@
|
|||
|
||||
function setup {
|
||||
ORIGDIR="$(pwd)"
|
||||
TMPDIR="$(mktemp -d)"
|
||||
|
||||
# If no $FORGEBUILD is supplied in ENV, use the default
|
||||
# (otherwise you can't `bats ./tests/` manually)
|
||||
[ -z "$FORGEBUILD" ] && FORGEBUILD="forgebuild"
|
||||
|
||||
# Ensure output from previous test does not exist
|
||||
# (in case something crashed)
|
||||
clean
|
||||
|
||||
# Setup forgebuild tasks
|
||||
FORGEBUILDDIR="$(mktemp -d)"
|
||||
FORGEBUILDDIR="$TMPDIR"/forgebuild
|
||||
mkdir $FORGEBUILDDIR
|
||||
echo "date +%s%N > /tmp/forgebuild-time" > $FORGEBUILDDIR/time
|
||||
chmod +x $FORGEBUILDDIR/time
|
||||
|
||||
|
@ -33,7 +31,7 @@ function teardown {
|
|||
}
|
||||
|
||||
function clean {
|
||||
if [ -d $FORGEBUILDDIR ]; then rm -rf $FORGEBUILDDIR; fi
|
||||
if [ -d $TMPDIR ]; then rm -rf $TMPDIR; fi
|
||||
if [ -f /tmp/forgebuild-time ]; then rm /tmp/forgebuild-time; fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue