2016-11-01 19:10:51 +01:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
|
|
|
function mtime() {
|
|
|
|
stat -c %Y $1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Go to top of blueprint tree
|
2017-06-29 00:10:11 +02:00
|
|
|
cd $(dirname ${BASH_SOURCE[0]})/..
|
|
|
|
TOP=${PWD}
|
2016-11-01 19:10:51 +01:00
|
|
|
|
2017-06-29 00:10:11 +02:00
|
|
|
export TEMPDIR=$(mktemp -d -t blueprint.test.XXX)
|
2016-11-01 19:10:51 +01:00
|
|
|
|
2017-06-29 00:10:11 +02:00
|
|
|
function cleanup() {
|
|
|
|
cd "${TOP}"
|
2017-10-30 22:53:03 +01:00
|
|
|
echo "cleaning up ${TEMPDIR}"
|
2017-06-29 00:10:11 +02:00
|
|
|
rm -rf "${TEMPDIR}"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
export OUTDIR="${TEMPDIR}/out"
|
|
|
|
mkdir "${OUTDIR}"
|
|
|
|
|
|
|
|
export SRCDIR="${TEMPDIR}/src"
|
|
|
|
cp -r tests/test_tree "${SRCDIR}"
|
2017-09-13 02:57:18 +02:00
|
|
|
cp -r "${TOP}" "${SRCDIR}/blueprint"
|
2016-11-01 19:10:51 +01:00
|
|
|
|
2017-06-29 00:10:11 +02:00
|
|
|
cd "${OUTDIR}"
|
2017-07-19 04:37:37 +02:00
|
|
|
export BLUEPRINTDIR=${SRCDIR}/blueprint
|
2017-10-30 22:53:03 +01:00
|
|
|
#setup
|
2017-07-19 09:59:57 +02:00
|
|
|
${SRCDIR}/blueprint/bootstrap.bash $@
|
2017-10-30 22:53:03 +01:00
|
|
|
|
|
|
|
#confirm no build.ninja file is rebuilt when no change happens
|
2016-11-01 19:10:51 +01:00
|
|
|
./blueprint.bash
|
|
|
|
|
2017-07-19 08:57:34 +02:00
|
|
|
OLDTIME_BOOTSTRAP=$(mtime .bootstrap/build.ninja)
|
2016-11-01 19:10:51 +01:00
|
|
|
OLDTIME=$(mtime build.ninja)
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
./blueprint.bash
|
|
|
|
|
|
|
|
if [ ${OLDTIME} != $(mtime build.ninja) ]; then
|
|
|
|
echo "unnecessary build.ninja regeneration for null build" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-07-19 08:57:34 +02:00
|
|
|
if [ ${OLDTIME_BOOTSTRAP} != $(mtime .bootstrap/build.ninja) ]; then
|
|
|
|
echo "unnecessary .bootstrap/build.ninja regeneration for null build" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-30 22:53:03 +01:00
|
|
|
#confirm no build.ninja file is rebuilt when a new directory is created
|
2016-11-01 19:10:51 +01:00
|
|
|
mkdir ${SRCDIR}/newglob
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
./blueprint.bash
|
|
|
|
|
|
|
|
if [ ${OLDTIME} != $(mtime build.ninja) ]; then
|
2017-10-30 22:53:03 +01:00
|
|
|
echo "unnecessary build.ninja regeneration for new empty directory" >&2
|
2016-11-01 19:10:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-07-19 08:57:34 +02:00
|
|
|
if [ ${OLDTIME_BOOTSTRAP} != $(mtime .bootstrap/build.ninja) ]; then
|
2017-10-30 22:53:03 +01:00
|
|
|
echo "unnecessary .bootstrap/build.ninja regeneration for new empty directory" >&2
|
2017-07-19 08:57:34 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-11-01 19:10:51 +01:00
|
|
|
|
2017-10-30 22:53:03 +01:00
|
|
|
#confirm that build.ninja is rebuilt when a new Blueprints file is added
|
2016-11-01 19:10:51 +01:00
|
|
|
touch ${SRCDIR}/newglob/Blueprints
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
./blueprint.bash
|
|
|
|
|
|
|
|
if [ ${OLDTIME} = $(mtime build.ninja) ]; then
|
2017-07-19 08:57:34 +02:00
|
|
|
echo "Failed to rebuild build.ninja for glob addition" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ${OLDTIME_BOOTSTRAP} = $(mtime .bootstrap/build.ninja) ]; then
|
|
|
|
echo "Failed to rebuild .bootstrap/build.ninja for glob addition" >&2
|
2016-11-01 19:10:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-30 22:53:03 +01:00
|
|
|
#confirm that build.ninja is rebuilt when a glob match is removed
|
2016-11-01 19:10:51 +01:00
|
|
|
OLDTIME=$(mtime build.ninja)
|
2017-07-19 08:57:34 +02:00
|
|
|
OLDTIME_BOOTSTRAP=$(mtime .bootstrap/build.ninja)
|
2016-11-01 19:10:51 +01:00
|
|
|
rm ${SRCDIR}/newglob/Blueprints
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
./blueprint.bash
|
|
|
|
|
|
|
|
if [ ${OLDTIME} = $(mtime build.ninja) ]; then
|
2017-07-19 08:57:34 +02:00
|
|
|
echo "Failed to rebuild build.ninja for glob removal" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ${OLDTIME_BOOTSTRAP} = $(mtime .bootstrap/build.ninja) ]; then
|
|
|
|
echo "Failed to rebuild .bootstrap/build.ninja for glob removal" >&2
|
2016-11-01 19:10:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-30 22:53:03 +01:00
|
|
|
#confirm that build.ninja is not rebuilt when a glob match is removed
|
2016-11-01 19:10:51 +01:00
|
|
|
OLDTIME=$(mtime build.ninja)
|
2017-07-19 08:57:34 +02:00
|
|
|
OLDTIME_BOOTSTRAP=$(mtime .bootstrap/build.ninja)
|
2016-11-01 19:10:51 +01:00
|
|
|
rmdir ${SRCDIR}/newglob
|
|
|
|
|
|
|
|
sleep 2
|
|
|
|
./blueprint.bash
|
|
|
|
|
|
|
|
if [ ${OLDTIME} != $(mtime build.ninja) ]; then
|
2017-10-30 22:53:03 +01:00
|
|
|
echo "unnecessary build.ninja regeneration for removal of empty directory" >&2
|
2016-11-01 19:10:51 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-30 22:53:03 +01:00
|
|
|
|
2017-07-19 08:57:34 +02:00
|
|
|
if [ ${OLDTIME_BOOTSTRAP} != $(mtime .bootstrap/build.ninja) ]; then
|
2017-10-30 22:53:03 +01:00
|
|
|
echo "unnecessary .bootstrap/build.ninja regeneration for removal of empty directory" >&2
|
2017-07-19 08:57:34 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2017-10-30 22:53:03 +01:00
|
|
|
|
|
|
|
echo tests passed
|