-
Notifications
You must be signed in to change notification settings - Fork 147
Expand file tree
/
Copy pathruntest.sh
More file actions
executable file
·37 lines (32 loc) · 792 Bytes
/
runtest.sh
File metadata and controls
executable file
·37 lines (32 loc) · 792 Bytes
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
#!/bin/bash
set -e
out=$1
tmp=${out}.tmp
name=$(basename ${out} | sed 's/\..*//')
shift
cmd="$@"
ext=$(echo ${cmd} | sed 's/.*\.//')
ins=$(/bin/ls */${name}*.in 2> /dev/null || true)
if [ -z "${ins}" ]; then
if [ ${ext} = "sed" ]; then
echo | ${cmd} > ${tmp}
perl -i -p0 -e 's/\n\Z//' ${tmp}
else
${cmd} < /dev/null > ${tmp}
fi
else
rm -f ${tmp}
for i in ${ins}; do
echo "=== ${i} ===" >> ${tmp}
if [ ${ext} = "ws" ]; then
(cat ${i} && echo -en "\0") | ${cmd} >> ${tmp}
elif [ ${ext} = "sed" ]; then
(cat ${i} && echo) | ${cmd} >> ${tmp}
perl -i -p0 -e 's/\n\Z//' ${tmp}
else
${cmd} < ${i} >> ${tmp}
fi
echo >> ${tmp}
done
fi
mv ${tmp} ${out}