43 lines
995 B
Bash
Executable File
43 lines
995 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Exit immediately if any command below fails.
|
|
set -e
|
|
|
|
make
|
|
|
|
|
|
echo "Generating a test_files directory.."
|
|
mkdir -p test_files
|
|
rm -f test_files/*
|
|
|
|
|
|
echo "Generating test files.."
|
|
printf "Hello, World!\n" > test_files/ascii.input
|
|
printf "Hello, World!" > test_files/ascii2.input
|
|
printf "Hello,\x00World!\n" > test_files/data.input
|
|
printf "Hællo,\x00World!\n" > test_files/iso1.input
|
|
printf "Hello,\x00Wørld!\n" > test_files/iso2.input
|
|
printf "Hello,\x00World!\n" > test_files/utf81.input
|
|
printf "Hello,\x00World!\n" > test_files/utf82.input
|
|
printf "" > test_files/empty.input
|
|
### TODO: Generate more test files ###
|
|
|
|
|
|
echo "Running the tests.."
|
|
exitcode=0
|
|
for f in test_files/*.input
|
|
do
|
|
echo ">>> Testing ${f}.."
|
|
file "${f}" | sed 's/ASCII text.*/ASCII text/' > "${f}.expected"
|
|
./file "${f}" > "${f}.actual"
|
|
|
|
if ! diff -u "${f}.expected" "${f}.actual"
|
|
then
|
|
echo ">>> Failed :-("
|
|
exitcode=1
|
|
else
|
|
echo ">>> Success :-)"
|
|
fi
|
|
done
|
|
exit $exitcodeASCII
|