summaryrefslogtreecommitdiff
path: root/utils/notes-util/check.sh
blob: acac923471a0e281e9ec9c09426729801fed12be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

set -e

CABAL_INSTALL="${CABAL_INSTALL:-cabal}"
GHC="${GHC:-ghc}"

cd "$(dirname $0)"
"$CABAL_INSTALL" build -w "$GHC"
bin="$("$CABAL_INSTALL" list-bin -w "$GHC" ghc-notes)"
cd "$(git rev-parse --show-toplevel)"
"$bin" broken-refs \
    | grep -v "utils/notes-util/expected-broken-note-refs:" \
    | sed 's/:[0-9]\+:[0-9]\+:/:/' \
    > broken-note-refs

if diff -q utils/notes-util/expected-broken-note-refs broken-note-refs; then
    printf "No unexpected broken note references"
else
    printf "Found unexpected broken note references:\n\n"
    diff -u utils/notes-util/expected-broken-note-refs broken-note-refs || true
    if [[ "$1" == "-a" ]]; then
        cp broken-note-refs utils/notes-util/expected-broken-note-refs
        printf "\n"
        printf "Accepted new broken note references."
    else
        exit 1
    fi
fi