<commit_before>import os
import sys
import subprocess

CALCULATE_HASH_CMD = bytearray([1])


def get_files(directory):
    ret = []

    for root, _, files in os.walk(directory):
        for file in files:
            if file.endswith(('gb', 'gbc')):
                ret.append(os.path.join(root, file))

    return ret


def main(directory, out_file_name):
    files = get_files(directory)

    with open(out_file_name, 'w') as f:
        for file in files:
            p = subprocess.Popen(['./emu', file], stdin=subprocess.PIPE, stdout=subprocess.PIPE)

            print("Is this correct result? [y, n, b]")
            ans = input()

            if ans in ('y', 'n'):
                p.stdin.write(CALCULATE_HASH_CMD)
                p.stdin.close()

                hash_res = p.stdout.read(64)
                f.write('{};{};{}\n'.format(os.path.basename(file), ans, hash_res.decode('ascii')))

            elif ans == 'b':
                f.write('{};{};{}\n'.format(os.path.basename(file), ans, ''))

            else:
                pass

            p.kill()


if __name__ == '__main__':
    if len(sys.argv) == 3:
        main(sys.argv[1], sys.argv[2])

    else:
        print("setup_tests.py <directory with tests> <output file name>")<commit_msg>test creator now takes program name as input param<commit_after>import os
import sys
import subprocess

CALCULATE_HASH_CMD = bytearray([1])


def get_files(directory):
    ret = []

    for root, _, files in os.walk(directory):
        for file in files:
            if file.endswith(('gb', 'gbc')):
                ret.append(os.path.join(root, file))

    return ret


def main(program_name, directory, out_file_name):
    files = get_files(directory)

    with open(out_file_name, 'w') as f:
        for file in files:
            p = subprocess.Popen([program_name, file], stdin=subprocess.PIPE, stdout=subprocess.PIPE)

            print("Is this correct result? [y, n, b]")
            ans = input()

            if ans in ('y', 'n'):
                p.stdin.write(CALCULATE_HASH_CMD)
                p.stdin.close()

                hash_res = p.stdout.read(64)
                f.write('{};{};{}\n'.format(os.path.basename(file), ans, hash_res.decode('ascii')))

            elif ans == 'b':
                f.write('{};{};{}\n'.format(os.path.basename(file), ans, ''))

            else:
                pass

            p.kill()


if __name__ == '__main__':
    if len(sys.argv) == 4:
        main(sys.argv[1], sys.argv[2], sys.argv[3])

    else:
        print("setup_tests.py <program path> <directory with tests> <output file name>")
{'fraction_non_alphanumeric': 0.15145705521472394, 'fraction_numerical': 0.004984662576687116, 'mean_word_length': 2.0694117647058823, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '7628285', 'n_tokens_mistral': 892, 'n_tokens_neox': 833, 'n_words': 193}