<commit_before>
# pre-commit-hook.py
# This runs all tests. Tests are dividing into those that should succeed
# (test/pass/*) and tests that check for errors (test/fail/*)

# A successful test should not print anything.

# Tests that expect a specific error message should put that message at the
# top, in a comment block. This allows the tester to check that a given error
# message is correct.

import os, subprocess, sys, signal

pass_count = 0
error_count = 0
crash_count = 0
test_count = 0
# No point in doing 'real' argument parsing when this is the only option.
verbose = (sys.argv[-1] == '--verbose')

def get_expected_str(filename):
    f = open(filename, "r")
    output = ''
    collecting = 0
    for line in f:
        if line.startswith('#[') and line.rstrip('\r\n') == '#[':
            collecting = True
        elif line.startswith(']#') and line.rstrip('\r\n') == "]#":
            collecting = False
        elif collecting:
            # This assumes that line is always \n terminated.
            output += line
    return output

def run_test(options, dirpath, filepath):
    global pass_count, error_count, crash_count, test_count, verbose

    test_count += 1

    fullpath = dirpath + filepath<commit_msg>pre-commit: Only count #[ ... if #[ is the first line.<commit_after>
# pre-commit-hook.py
# This runs all tests. Tests are dividing into those that should succeed
# (test/pass/*) and tests that check for errors (test/fail/*)

# A successful test should not print anything.

# Tests that expect a specific error message should put that message at the
# top, in a comment block. This allows the tester to check that a given error
# message is correct.

import os, subprocess, sys, signal

pass_count = 0
error_count = 0
crash_count = 0
test_count = 0
# No point in doing 'real' argument parsing when this is the only option.
verbose = (sys.argv[-1] == '--verbose')

def get_expected_str(filename):
    f = open(filename, "r")
    output = ''

    if f.readline().rstrip('\r\n') == '#[':
        for line in f:
            if line.startswith(']#') and line.rstrip('\r\n') == "]#":
                break
            else:
                # This assumes that line is always \n terminated.
                output += line

    return output

def run_test(options, dirpath, filepath):
    global pass_count, error_count, crash_count, test_count, verbose

    test_count += 1

    fullpath = dirpath + filepath
{'fraction_non_alphanumeric': 0.10731907894736842, 'fraction_numerical': 0.005345394736842105, 'mean_word_length': 2.8803827751196174, 'pattern_counts': {'":': 2, '<': 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': '4695272', 'n_tokens_mistral': 733, 'n_tokens_neox': 711, 'n_words': 282}