Created
April 1, 2020 08:43
-
-
Save kprav33n/f4c5132f63e79248e5f3cc5891aad02f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo "Usage: $0 CONFIG" | |
exit 1 | |
} | |
if [ $# -ne 1 ]; then | |
usage | |
fi | |
input_files=$(grep input_files $1 | cut -d '=' -f 2 | sed 's/,/ /g') | |
output_dir=$(grep output_dir $1 | cut -d '=' -f 2) | |
num_output=$(grep n_output_files $1 | cut -d '=' -f 2) | |
echo "Testing with input files $input_files against output in $output_dir" | |
echo -n "Checking number of output files..." | |
[ $num_output -eq $(ls $output_dir | wc -l) ] && echo "PASS" || echo "FAIL" | |
echo "Checking if output in sorted order..." | |
for out in $(ls $output_dir); do | |
echo -n " $output_dir/$out " | |
diff -u <(LC_COLLATE=c sort $output_dir/$out) $output_dir/$out && echo "PASS" || echo "FAIL" | |
done | |
echo -n "Checking final output..." | |
diff -u <(awk '{print}' $input_files | sed 's/\.//g' | tr ' ' '\n' | sed '/^$/d' | LC_COLLATE=c sort | uniq -c | awk '{print $2 " " $1}') <(awk '{print}' $output_dir/* | LC_COLLATE=c sort) && echo "PASS" || echo "FAIL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment