| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Script to accept the current output for some output comparing test as the golden output |
| 4 | # |
| 5 | # Usage: accept <test> |
| 6 | # |
| 7 | # Will copy build/tests/<test>.output to tests/<test>.expected |
| 8 | |
| 9 | if [ "$#" -ne 1 ] |
| 10 | then |
| 11 | echo "Usage: accept <test>" |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
| 15 | scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 16 | rootdir=$(dirname $scriptdir) |
| 17 | |
| 18 | if [[ ! -f $rootdir/build/tests/$1.output ]] |
| 19 | then |
| 20 | echo "Output file does not exist." |
| 21 | exit |
| 22 | fi |
| 23 | echo "About to 'cp build/tests/$1.output tests/$1.expected'" |
| 24 | |
| 25 | read -r -p "Are you sure? [y/N] " response |
| 26 | if [[ ! $response =~ ^([yY][eE][sS]|[yY])$ ]] |
| 27 | then |
| 28 | exit |
| 29 | fi |
| 30 | |
| 31 | cp $rootdir/build/tests/$1.output $rootdir/tests/$1.expected |
| 32 | echo "Accepted!" |