import re
import os
import sys

if len(sys.argv) <= 1:
    raise NameError("ABORTED: Please provide a folder in which the testSuite.cpp will be generated.")
else:
    currentDir = sys.argv[1] + '/'
    allMethodNames = []
    for fileName in os.listdir(currentDir):
        if fileName.endswith("Test.cpp"):
            with open(currentDir + fileName, "r") as file:
                text = file.read()
                regex = r"(?<=\nvoid\s)(.+)(?=\(\))"
                matches = re.findall(regex, text)

                for match in matches:
                    allMethodNames.append(match)

    with open(currentDir + "testSuite.cpp", "w") as file:
        file.write('// THIS FILE WAS AUTOGENERATED BY FILE generateTestSuite.py\n')
        file.write('#include "testSuite.h" \n#include "test.h"\n\n')

        for methodName in allMethodNames:
            file.write('void ' + methodName + '();\n')

        file.write('\nvoid RunTests() \n{\n')

        for methodName in allMethodNames:
            file.write('\tRUN_TEST(' + methodName + ');\n')
        
        file.write('}\n')
    

import re
import os
import sys

if len(sys.argv) <= 1:
    raise NameError("ABORTED: Please provide a folder in which the testSuite.cpp will be generated.")
else:
    currentDir = sys.argv[1] + '/'
    allMethodNames = []
    for fileName in os.listdir(currentDir):
        if fileName.endswith("Test.cpp"):
            with open(currentDir + fileName, "r") as file:
                text = file.read()
                regex = r"(?<=\nvoid\s)(.+)(?=\(\))"
                matches = re.findall(regex, text)

                for match in matches:
                    allMethodNames.append(match)

    with open(currentDir + "testSuite.cpp", "w") as file:
        file.write('// THIS FILE WAS AUTOGENERATED BY FILE generateTestSuite.py\n')
        file.write('#include "testSuite.h" \n#include "test.h"\n\n')

        for methodName in allMethodNames:
            file.write('void ' + methodName + '();\n')

        file.write('\nvoid RunTests() \n{\n')

        for methodName in allMethodNames:
            file.write('\tRUN_TEST(' + methodName + ');\n')
        
        file.write('}\n')
    

#include "test.h"\n\n')