#Developed with Python 2.7.15+
#Might not run with other versions.

#What this program does:
#Recursively traverse the game's folders
#If a folder contains a folder called 'tests', runs them with busted

#requires busted to be installed

import subprocess
import os


def find_and_run_tests(path):
	files = os.listdir(path)
	for f in files:
		childpath = os.path.join(path, f)
		if f == "tests":
			subprocess.call(["cd " + path + " && busted " + "."], shell = True)
		elif os.path.isdir(childpath):
				find_and_run_tests(childpath)
			

dirname, filename = os.path.split(os.path.abspath(__file__))
find_and_run_tests(dirname)
