<commit_before>#!/usr/bin/env python

import argparse
import os
import shutil
import subprocess
import sys

tests_directory = os.path.dirname(os.path.realpath(__file__))
needy_path = os.path.join(tests_directory, '..', 'needy.py')

def test(directory, args):
    print 'Running test in %s: %s' % (directory, ' '.join(args))
    os.chdir(directory)
    if os.path.exists('needs'):
        shutil.rmtree('needs')
    subprocess.check_call([needy_path] + args)

def main(args):
    parser = argparse.ArgumentParser(description='Tests Needy.')
    parameters = parser.parse_args(args[1:])
    
    for entry in os.listdir(tests_directory):
        test_directory = os.path.join(tests_directory, entry)
        if os.path.isfile(os.path.join(test_directory, 'needs.json')):
            test(test_directory, [])
            test(test_directory, ['--target=ios:armv7'])
            test(test_directory, ['--target=android:armv7'])

if __name__ == "__main__":
    try:
        sys.exit(main(sys.argv))
    except Exception as e:
        print '[ERROR]', e
        raise<commit_msg>add run-dirty debugging flag to tests<commit_after>#!/usr/bin/env python

import argparse
import os
import shutil
import subprocess
import sys

tests_directory = os.path.dirname(os.path.realpath(__file__))
needy_path = os.path.join(tests_directory, '..', 'needy.py')

def test(directory, needy_args, run_dirty=False):
    print 'Running test in %s: %s' % (directory, ' '.join(needy_args))
    os.chdir(directory)
    if not run_dirty and os.path.exists('needs'):
        shutil.rmtree('needs')
    subprocess.check_call([needy_path] + needy_args)

def main(args):
    parser = argparse.ArgumentParser(description='Tests Needy.')
    parser.add_argument('--run-dirty', default=False, action='store_true', help='run without cleaning first (useful for saving time while debugging)')
    parameters = parser.parse_args(args[1:])
    
    for entry in os.listdir(tests_directory):
        test_directory = os.path.join(tests_directory, entry)
        if os.path.isfile(os.path.join(test_directory, 'needs.json')):
            test(test_directory, [], parameters.run_dirty)
            test(test_directory, ['--target=ios:armv7'], parameters.run_dirty)
            test(test_directory, ['--target=android:armv7'], parameters.run_dirty)

if __name__ == "__main__":
    try:
        sys.exit(main(sys.argv))
    except Exception as e:
        print '[ERROR]', e
        raise
{'fraction_non_alphanumeric': 0.13975409836065575, 'fraction_numerical': 0.002459016393442623, 'mean_word_length': 3.640684410646388, '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': '2528645', 'n_tokens_mistral': 796, 'n_tokens_neox': 787, 'n_words': 162}