frawor / test / updateouts.zsh

#!/bin/zsh

autoload colors && colors

typeset -xr TMPDIR=$0:A:h:h:h/repository/tmp
typeset -gr PREFIX=${PREFIX:-.}

function copyout()
{
    othername=$TMPDIR/test/$1
    cp $othername.out $PREFIX/$1.ok
    [[ ${PREFIX[-4,-1]} == wine ]] && local -x TMPDIR='T:'
    perl -p -i -e 's/\Q$ENV{"TMPDIR"}\E/%TMPDIR%/g' $PREFIX/$1.ok
}

cd $0:a:h

test -d $PREFIX || mkdir $PREFIX

if test -e $TMPDIR/failed.lst ; then
    cat $TMPDIR/failed.lst | cut -d' ' -f 2 | \
        while read l ; do
            othername=$TMPDIR/test/$l
            echo
            diff -a -y $othername.ok $othername.out
            echo -n "\n\e[${color[yellow]}mUpdate $l?\e[0m "
            read -q update || continue
            copyout $l
        done
fi

for TEST in $TMPDIR/test/*.in ; do
    TEST=$TEST:t:r
    test -e $TEST.ok && continue
    othername=$TMPDIR/test/$TEST
    test -e $othername.out || continue
    echo
    cat $othername.out
    echo -n "\n\e[${color[yellow]}mCopy $TEST?\e[0m "
    read -q copy || continue
    copyout $TEST
done
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.