#!/usr/bin/env bash

mkdir -p bin

call_python() {
	python3 $@
}

run() {
	call_python $@
	code=$?
	if [ ${code} -ne 0 ]
	then
		echo -e "\033[91m\033[7mError in test '${1}'. Exiting...\033[0m"
		exit ${code}
	fi
}

run_tests() {
	# Test prep (generate log files)
	echo -e "\033[93mUndergoing test preparations\033[0m"
	run ./tests/write.py ./bin/w1.lnm
	run ./tests/write_many.py ./bin/w2.lnm 100
	echo

	# Unit tests
	echo -e "\033[93mBeginning unit tests\033[0m"
	run ./tests/unit_parserargs.py
	echo

	echo -e "\033[92mFinished! Exitting with code 0...\033[0m"
}

run_tests