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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#!/bin/sh
set -eu
if test "$#" -lt 3; then
cat >>/dev/stderr <<EOF
Usage:
$0 <repodir> <testsdir(output)> <rundir> ...
Using <repodir> (to map the abbreviated hash in the result directory
name onto a full hash?) merge the test results under <rundir> into
results for each individual test writing them into <testdir>.
The test output is left unchanged.
EOF
exit 1
fi
webdir=$(cd $(dirname $0) && pwd)
repodir=$(cd $1 && pwd) ; shift
testsdir=$(cd $1 && pwd) ; shift
for rundir in "$@"; do
run=$(basename ${rundir})
hash=$(${webdir}/gime-git-rev.sh ${rundir})
hash=$(cd ${repodir} && git show --no-patch --format=%H ${hash})
if test "${hash}" = "" ; then
hash=null
fi
echo ${run} ${hash} 1>&2
{
cd ${rundir}
find . \
-maxdepth 4 \
-type f \
-name result.json \
-print
} | {
# ./${testdir}/OUTPUT/result.json
cut -d/ -f2
} | while read testdir ; do
# echo ${testsdir}/${testdir}/${run}.json 1>&2
mkdir -p ${testsdir}/${testdir}
# let any existing hash override above
jq --arg hash "${hash}" --arg run "${run}" \
'.hash = if .hash? then .hash else $hash end | .run = $run' \
${rundir}/${testdir}/OUTPUT/result.json \
> ${testsdir}/${testdir}/${run}.json
done
done
echo joining 1>&2
cd ${testsdir}
{
find . \
-maxdepth 1 \
-type d \
-print
} | {
cut -d/ -f2
} | while read testdir ; do
find ${testdir} -name '*.json' -print \
| xargs cat \
| jq --slurp . - > ${testdir}.json
done
exit 0
|