<commit_before>"""
Finds all test cases under tests/integration and generates runTestCase calls
in IntegrationTestFixture.Generated.boo
"""
import System.IO

def testCaseName(fname as string):
	return Path.GetFileNameWithoutExtension(fname).Replace("-", "_")
	
def writeTestCases(writer as TextWriter, baseDir as string):
	count = 0
	for fname in Directory.GetFiles(baseDir):
		continue unless fname.EndsWith(".boo")
		++count		
		writer.Write("""
	[Test]
	def ${testCaseName(fname)}():
		runTestCase("../boojay/${fname.Replace('\\', '/')}")
		""")
	print("${count} test cases found in ${baseDir}.")
	
using writer = StreamWriter("src/Boojay.Compilation.Tests/IntegrationTestFixture.Generated.boo"):
	writer.Write("""
namespace Boojay.Compilation.Tests
<commit_msg>support for tests in subfolders<commit_after>"""
Finds all test cases under tests/integration and generates runTestCase calls
in IntegrationTestFixture.Generated.boo
"""
import System.IO

def testCaseName(fname as string):
	return Path.GetFileNameWithoutExtension(fname).Replace("-", "_")
	
def writeTestCases(writer as TextWriter, baseDir as string):
	count = 0
	for fname in Directory.GetFiles(baseDir):
		continue unless fname.EndsWith(".boo")
		++count		
		writeTestCase(writer, fname)
	for subDir in Directory.GetDirectories(baseDir):
		writeTestCases(writer, subDir)
	print("${count} test cases found in ${baseDir}.")
	
def writeTestCase(writer as TextWriter, fname as string):
	writer.Write("""
	[Test]
	def ${testCaseName(fname)}():
		runTestCase("../boojay/${fname.Replace('\\', '/')}")
		""")
		
using writer = StreamWriter("src/Boojay.Compilation.Tests/IntegrationTestFixture.Generated.boo"):
	writer.Write("""
namespace Boojay.Compilation.Tests

{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.0011614401858304297, 'mean_word_length': 5.73046875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6578213', 'n_tokens_mistral': 568, 'n_tokens_neox': 547, 'n_words': 129}