compare.sh 1.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/bash

# Example usage: ./compare.sh mezzo
# This script processes mezzo.mly using two versions of Menhir:
# 1- the last committed version;
# 2- the current (uncommitted) version.
# It then compares the output.

# The variable OPT can be used to pass extra options to Menhir.
# Use as follows:
# OPT=--lalr ./compare.sh ocaml

13
BENCH=../test/good
14
MENHIR=_stage1/menhir.native
15
BASE="-v -lg 1"
16 17 18 19 20 21 22

if [ $# -eq 0 ]
then
  echo "$0: at least one argument expected"
  exit 1
fi

23 24 25 26 27 28
# Try the current version.
echo "Compiling (current uncommitted version)..."
make &> compile.new || { cat compile.new && exit 1 ; }
sleep 1
for FILE in "$@"
do
29
  FLAGS=`if [ -f $BENCH/$FILE.flags ] ; then cat $BENCH/$FILE.flags ; fi`
30
  echo "Running ($FILE.mly)..."
31
  { time $MENHIR $BASE $OPT $FLAGS --list-errors -la 2 $BENCH/$FILE.mly ; } >$FILE.out.new 2>$FILE.err.new
32 33 34
done

# Try the last committed version.
35 36
git stash
echo "Compiling (last committed version)..."
37 38 39 40
make &> compile.old || { cat compile.old && exit 1 ; }
sleep 1
for FILE in "$@"
do
41 42 43
  FLAGS=`if [ -f $BENCH/$FILE.flags ] ; then cat $BENCH/$FILE.flags ; fi`
  echo "Running ($FILE.mly)..."
  { time $MENHIR $BASE $OPT $FLAGS --list-errors -la 2 $BENCH/$FILE.mly ; } >$FILE.out.old 2>$FILE.err.old
44
done
45 46 47 48 49
git stash pop

# Diff.
for FILE in "$@"
do
50 51 52 53
  echo "Diffing stderr ($FILE.mly)..."
  diff $FILE.err.old $FILE.err.new
  echo "Diffing stdout ($FILE.mly)..."
  diff $FILE.out.old $FILE.out.new
54
done