def detectClassName(file):
    content = getBytesFromFile(file["relativePath"]).decode("utf-8")
    match = re.search("class (\\w+)", content)
    if match is None:
        print("Could not detect class in file '" + file["name"] + "'")
        return -1

    return match.group(1).strip()
Beispiel #2
0
def runSingleTest(command, directory, inFile, answerFile):
    inp = getBytesFromFile(inFile)
    answer = getBytesFromFile(answerFile).decode("utf-8")
    result = (subprocess.run(command,
                             stdout=subprocess.PIPE,
                             input=inp,
                             cwd=directory).stdout.decode("utf-8").replace(
                                 "\r\n", "\n"))

    if answer == result:
        print("\U0001F49A", inFile, "succeeded")
        return True
    else:
        print("\U0000274C", inFile, "failed")
        print("expected:")
        print(answer)
        print("actual:")
        print(result)
        return False