#!/usr/bin/env bash

set -eo pipefail

none() {
	echo 'Running CLJS test in Node with optimizations :none'
	TEST_SCI=true clojure -M:test:cljs-test-runner:sci:test-sci -c '{:optimizations :none}' "$@"
}

advanced() {
	echo 'Running CLJS test in Node with optimizations :advanced'
	TEST_SCI=true clojure -M:test:cljs-test-runner:sci:test-sci -c '{:optimizations :advanced}' -e :simple "$@"
}

cherry-none() {
	echo 'Running CLJS test in Node with cherry + optimizations :none'
	clojure -M:test:cljs-test-runner:cherry:test-cherry -c '{:optimizations :none}' "$@"
}

cherry-advanced() {
	echo 'Running CLJS test in Node with cherry + optimizations :advanced'
	# :optimize-constants is set to false until https://clojure.atlassian.net/browse/CLJS-3401 is fixed
 	clojure -M:test:cljs-test-runner:cherry:test-cherry -c '{:optimizations :advanced :optimize-constants false}' -e :simple "$@"
}

case $1 in
	none) none ;;
	advanced) advanced ;;
	cherry-none) cherry-none ;;
	cherry-advanced) cherry-advanced ;;
	*) none; advanced; cherry; cherry-advanced ;;
esac
