#!/bin/bash

command=$1

case $command in
	test)
		{
			echo -n "Started at "
			date
			# All unit tests
			echo === Unit Tests ===
			for test in t/unit/*.rakutest		; do echo '=> ' $test ; raku -Ilib -It/lib "$test"; done

			# All integration tests
			echo === Integration Tests ===
			for test in t/integration/*.rakutest	; do echo '=> ' $test ; raku -Ilib -It/lib "$test"; done

			# All example tests
			echo === Example Tests ===
			for test in t/examples/*.rakutest	; do echo '=> ' $test ; raku -Ilib -It/lib "$test"; done
		} 2>&1 | ts "%H:%M:%.S" | tee test-output.txt
		;;
	check)
#		echo "=== Run tests ==="
#		./project test
		echo "=== Check for broken rakudoc ==="
		grep -FRl '#|' lib/ t/
		echo "=== Check for TODOs ==="
		ack TODO lib/ t/
		;;
	*)
		echo "Error: Unknown command '$command'" >&2
		exit 1
esac
