Skip to content

Instantly share code, notes, and snippets.

@mqudsi
Created December 17, 2021 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mqudsi/0edbd38507ce97ac695a72dcb7a7661c to your computer and use it in GitHub Desktop.
Save mqudsi/0edbd38507ce97ac695a72dcb7a7661c to your computer and use it in GitHub Desktop.
A script to bisect vim portably
#!/bin/sh
# set -x
# vim is really hard to run portably; I can't seem to get `set rtp=./runtime/`
# to actually work, so we build it with a prefix pointing to $PWD and then
# symlink `share/vim/` so it points to the files we need.
if mkdir share 2>&1 >/dev/null; then
ln -s $(pwd) share/vim
fi
make clean
rm -f ./src/vim
# git reserves exit code 125 for build failure, which will skip the commit when
# bisecting.
echo Building vim $(git rev-parse HEAD)
test -f ./configure && {
./configure --prefix=$(pwd) > /dev/null || exit 125
}
make -j16 > /dev/null || echo "Error compiling project!";
rm -f src/auto/config.cache
test -x ./src/vim || exit 125
rm -f output.html
# See above regarding portability. We are now using the currently checked out
# git source as the runtimepath, so we don't need to use `-u NORC`
./src/vim -c 'source bisect.vim'
test -f output.html || {
echo "error running test!"
sleep 10
exit 125
}
# If the output matches bad.html, then the bisect test has failed.
if diff output.html bad.html >/dev/null; then
echo -n $'\e[31m'
echo -n $(git rev-parse HEAD) bisects BAD
echo $'\e[m'
echo ""
exit 1
fi
echo -n '\e[32m'
echo -n $(git rev-parse HEAD) bisects GOOD
echo '\e[m'
echo ""
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment