#!/bin/sh# do two runs of a script, one optimistic and one pessimistic, expect identical outputs# if not, display and error message and a diffwhich opendiff >/dev/nullRES=$?if [ $RES = 0 ]; then DIFFTOOL=opendiffelse DIFFTOOL=difffiOPTIMISTIC=out_optimisticPESSIMISTIC=out_pessimistic$JAVA_HOME/bin/java -ea -jar ../dist/nashorn.jar ${@} >$PESSIMISTIC$JAVA_HOME/bin/java -ea -Dnashorn.optimistic -jar ../dist/nashorn.jar ${@} >$OPTIMISTICif ! diff -q $PESSIMISTIC $OPTIMISTIC >/dev/null ; then echo "Failure! Results are different" echo "" $DIFFTOOL $PESSIMISTIC $OPTIMISTICelse echo "OK - Results are identical"fi