Skip to content

Instantly share code, notes, and snippets.

@erikarvstedt
Created April 7, 2020 20:49
Show Gist options
  • Save erikarvstedt/5b0b1a7787ebc1342fcc3f237da5afa7 to your computer and use it in GitHub Desktop.
Save erikarvstedt/5b0b1a7787ebc1342fcc3f237da5afa7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
instantiateTest() {
test/run-tests.sh vmTestNixExpr | nix-instantiate --indirect --add-root $1 - > /dev/null
}
TMPDIR=/tmp/diff-vm-drv
mkdir -p $TMPDIR
if [[ ! -e $TMPDIR/master ]]; then
echo "Creating test drv for master"
if ! git diff-index --quiet HEAD --; then
echo "There are uncommitted changes. Exiting."
exit 1
fi
currentBranch=$(git rev-parse --abbrev-ref HEAD)
git checkout master
instantiateTest $TMPDIR/master
git checkout $currentBranch
fi
diffTestDrv() {
instantiateTest $TMPDIR/current
if cmp $TMPDIR/master $TMPDIR/current; then
echo "No changes"
else
nix-diff $TMPDIR/master $TMPDIR/current
fi
}
diffTestDrv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment