<commit_before>import env
import os
import sys
import unittest
import shutil
from robot import run as robot_run


def acceptance_test(options):
    if not options:
        return _acceptance_all()
    else:
        if '-s' in options or '--suite' in options:
            return _acceptance_include(options[1:])
        else:
            print 'Only "-s" or "--suite" supported'
            _exit(255)


def _acceptance_all():
    return robot_run(
        env.ACCEPTANCE_TEST_DIR,
        outputdir=env.RESULTS_DIR,
        loglevel='trace'
    )


def _acceptance_include(options):
    return robot_run(
        env.ACCEPTANCE_TEST_DIR,
        outputdir=env.RESULTS_DIR,
        suite=options,
        loglevel='trace'
    )


def clean_results():
    print 'Clean: {0}'.format(env.RESULTS_DIR)
    if os.path.exists(env.RESULTS_DIR):
        shutil.rmtree(env.RESULTS_DIR)
    else:
        os.mkdir(env.RESULTS_DIR)


def unit_test():
    print 'Running unit test'
    sys.path.insert(0, env.SRC_DIR)
    sys.path.append(env.UNIT_TEST_DIR)
    # suite = unittest.TestLoader().loadTestsFromName(
    #     'test_runners.TestRunnerForScanner.test_scan_all')
    suite = unittest.TestLoader().discover(
        start_dir=env.UNIT_TEST_DIR,
        pattern='test*.py')
    return unittest.TextTestRunner(verbosity=2).run(suite)


def _help():
    print 'Usage: python run_test.py [-s suite_name]'
    return 255


def _exit(rc):
    sys.exit(rc)

if __name__ == '__main__':
    if '--help' in sys.argv or '-h' in sys.argv:
        _exit(_help())
    clean_results()
    u_result = unit_test()
    a_result = acceptance_test(sys.argv[1:])
    if u_result.errors:
        print 'Unit tests failed'
        print 'errors: ', u_result.errors
        print 'failures: ', u_result.failures
        _exit(u_result.errors)
    elif a_result != 0:
        print 'Acceptance tests failed'
        _exit(a_result)
    else:
        print 'All passed'
        _exit(0)
<commit_msg>Failed unit test did not make the test status fail<commit_after>import env
import os
import sys
import unittest
import shutil
from robot import run as robot_run


def acceptance_test(options):
    if not options:
        return _acceptance_all()
    else:
        if '-s' in options or '--suite' in options:
            return _acceptance_include(options[1:])
        else:
            print 'Only "-s" or "--suite" supported'
            _exit(255)


def _acceptance_all():
    return robot_run(
        env.ACCEPTANCE_TEST_DIR,
        outputdir=env.RESULTS_DIR,
        loglevel='trace'
    )


def _acceptance_include(options):
    return robot_run(
        env.ACCEPTANCE_TEST_DIR,
        outputdir=env.RESULTS_DIR,
        suite=options,
        loglevel='trace'
    )


def clean_results():
    print 'Clean: {0}'.format(env.RESULTS_DIR)
    if os.path.exists(env.RESULTS_DIR):
        shutil.rmtree(env.RESULTS_DIR)
    else:
        os.mkdir(env.RESULTS_DIR)


def unit_test():
    print 'Running unit test'
    sys.path.insert(0, env.SRC_DIR)
    sys.path.append(env.UNIT_TEST_DIR)
    # suite = unittest.TestLoader().loadTestsFromName(
    #     'test_runners.TestRunnerForScanner.test_scan_all')
    suite = unittest.TestLoader().discover(
        start_dir=env.UNIT_TEST_DIR,
        pattern='test*.py')
    return unittest.TextTestRunner(verbosity=2).run(suite)


def _help():
    print 'Usage: python run_test.py [-s suite_name]'
    return 255


def _exit(rc):
    sys.exit(rc)

if __name__ == '__main__':
    if '--help' in sys.argv or '-h' in sys.argv:
        _exit(_help())
    clean_results()
    u_result = unit_test()
    a_result = acceptance_test(sys.argv[1:])
    if u_result.errors or u_result.failures:
        print 'Unit tests failed'
        print 'errors: ', u_result.errors
        print 'failures: ', u_result.failures
        _exit(u_result.errors)
    elif a_result != 0:
        print 'Acceptance tests failed'
        _exit(a_result)
    else:
        print 'All passed'
        _exit(0)

{'fraction_non_alphanumeric': 0.10461760461760462, 'fraction_numerical': 0.006253006253006253, 'mean_word_length': 2.292953285827395, 'pattern_counts': {'":': 0, '<': 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': '4393085', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1321, 'n_words': 293}