Skip to content

Instantly share code, notes, and snippets.

@Thibb1
Last active December 9, 2021 08:23
Show Gist options
  • Save Thibb1/e0c6f886e05e46b56aa32e80dfd782cb to your computer and use it in GitHub Desktop.
Save Thibb1/e0c6f886e05e46b56aa32e80dfd782cb to your computer and use it in GitHub Desktop.
mouli Antman (place in bonus file)
#!/usr/bin/env bash
clear
set -e
cd ..
# BASH COLORS
red() { printf "\033[38;5;196m${1}\033[0m\n"; }
green() { printf "\033[32m${1}\033[0m\n\n"; }
orange() { printf "\033[38;5;208m${1}\033[0m\n"; }
blue() { printf "\033[38;5;27m${1}\033[0m\n" ; }
purpl() { printf "\033[38;5;92m${1}\033[0m\n" ; }
yellow() { printf "\033[38;5;226m${1}\033[0m\n" ; }
banner() {
blue " _ _ _ _ "
blue " _ __ ___ ___ _ _| (_) / \ _ __ | |_ _ __ ___ __ _ _ __ "
blue " | '_ \` _ \ / _ \| | | | | | / _ \ | '_ \| __| '_ \` _ \ / _\` | '_ \ "
blue " | | | | | | (_) | |_| | | | / ___ \| | | | |_| | | | | | (_| | | | |"
blue " |_| |_| |_|\___/ \__,_|_|_| /_/ \_\_| |_|\__|_| |_| |_|\__,_|_| |_|"
blue " "
}
cmpant() {
file1="$test.ant"
file2="$test.giant"
SECONDS=0;
./antman/antman "$test" "$type" > "$file1"
yellow "It takes $SECONDS seconds to compress $test"
./giantman/giantman "$file1" "$type" > "$file2"
if cmp -s "$test" "$file2"; then
let "success += 1"
purpl "$test == $file2"
else
let "failed += 1"
red "$test != $file2"
fi
total=$((failed+success))
yellow "[$total/15] \033[38;5;196mF:$failed \033[32mS:$success"
perl - $test <<'__HERE__'
my $i = shift;
my $j = "$i.ant";
$i = -s $i;
$j = -s $j;
$i = (1-($j/$i))*100;
printf "\033[38;5;92mCompression ratio = %.2f%%\n\n\033[0m\n", $i;
__HERE__
sleep 0.5
}
banner
orange "Building binaries"
sleep 1
make -C antman re;
make -s -C antman clean;
make -C giantman re;
make -s -C giantman clean;
clear
banner
orange "Building binaries"
green "Done"
orange "Downloading testing files"
sleep 1
rm -rf antman_test_files;
git clone -q https://github.com/Thibb1/antman_test_files.git
green "Done"
orange "Testing binaries"
success=0
failed=0
sleep 1
type=1
test="antman_test_files/text1.lyr"
cmpant
test="antman_test_files/text2.lyr"
cmpant
test="antman_test_files/text3.lyr"
cmpant
test="antman_test_files/text4.lyr"
cmpant
test="antman_test_files/text5.lyr"
cmpant
test="antman_test_files/text6.lyr"
cmpant
type=2
test="antman_test_files/page1.html"
cmpant
test="antman_test_files/page2.html"
cmpant
test="antman_test_files/page3.html"
cmpant
test="antman_test_files/page4.html"
cmpant
test="antman_test_files/page5.html"
cmpant
type=3
test="antman_test_files/image1.ppm"
cmpant
test="antman_test_files/image2.ppm"
cmpant
test="antman_test_files/image3.ppm"
cmpant
test="antman_test_files/image4.ppm"
cmpant
green "Done"
orange "Removing binaries and test files"
read -p "Do you want to erase results files? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
orange "Removing results files"
rm -rf antman_test_files;
fi
make -s -C antman fclean;
make -s -C giantman fclean;
green "Done"
green "$success/15 test passed"
blue "Antman and Giantman have been tested"
blue "Provided by Thibault B - 2020 - Epitech Lille Promo 2025"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment