I am writing a testing script. It executes program with *.in files passed as input and compares its output with *.out files using diff command.
However, I don't want to print diff output, but to check if there is any and if so, then add *.in file name to the list of failed tests.
The problem is I have no idea how to check if command produces output without printing it.
My script now:
failed_tests=""
for filename in $directory/*.in; do
command=< ${filename} ./${program} | diff - ${filename%.in}.out
# Check if command produces output.
if command; then
# Add filename to failed tests list.
failed_tests="${failed_tests} ${filename}"
fi
done
echo $failed_tests
Thank you in advance for all the answers.