<commit_before>from SCons.Script import *


def run_tests(env):
    import shlex
    import subprocess
    import sys

    cmd = shlex.split(env.get('TEST_COMMAND'))
    print('Executing:', cmd)
    sys.exit(subprocess.call(cmd))


def generate(env):
    import os
    import distutils.spawn

    python = distutils.spawn.find_executable('python3')
    if not python: python = distutils.spawn.find_executable('python')
    if not python: python = distutils.spawn.find_executable('python2')
    if not python: python = 'python'
    if env['PLATFORM'] == 'win32': python = python.replace('\\', '\\\\')

    cmd = python + ' tests/testHarness -C tests --diff-failed --view-failed ' \
        '--view-unfiltered --save-failed --build'

    if 'DOCKBOT_MASTER_PORT' in os.environ: cmd += ' --no-color'

    env.CBAddVariables(('TEST_COMMAND', '`test` target command line', cmd))

    if 'test' in COMMAND_LINE_TARGETS: env.CBAddConfigureCB(run_tests)


def exists(): return 1<commit_msg>Use common testHarness in derived projects<commit_after>from SCons.Script import *
import inspect


def run_tests(env):
    import shlex
    import subprocess
    import sys

    cmd = shlex.split(env.get('TEST_COMMAND'))
    print('Executing:', cmd)
    sys.exit(subprocess.call(cmd))


def generate(env):
    import os
    import distutils.spawn

    python = distutils.spawn.find_executable('python3')
    if not python: python = distutils.spawn.find_executable('python')
    if not python: python = distutils.spawn.find_executable('python2')
    if not python: python = 'python'
    if env['PLATFORM'] == 'win32': python = python.replace('\\', '\\\\')

    path = inspect.getfile(inspect.currentframe())
    home = os.path.dirname(os.path.abspath(path)) + '/../..'

    cmd = python + ' ' + home + '/tests/testHarness -C tests --diff-failed ' \
        '--view-failed --view-unfiltered --save-failed --build'

    if 'DOCKBOT_MASTER_PORT' in os.environ: cmd += ' --no-color'

    env.CBAddVariables(('TEST_COMMAND', '`test` target command line', cmd))

    if 'test' in COMMAND_LINE_TARGETS: env.CBAddConfigureCB(run_tests)


def exists(): return 1
{'fraction_non_alphanumeric': 0.14526710402999063, 'fraction_numerical': 0.004686035613870665, 'mean_word_length': 3.429460580912863, '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': '4476157', 'n_tokens_mistral': 721, 'n_tokens_neox': 695, 'n_words': 161}