<commit_before>from SCons.Script.SConscript import SConsEnvironment

import os

#
# Function taken from scons Wiki
#
def builder_unit_test(target, source, env):
	app = str(source[0].abspath)
	if os.spawnl(os.P_WAIT, app, app) == 0:
		open(str(target[0]), 'w').write("PASSED\n")
	else:
		return 1


def UnitTest(env, source, **kwargs):
    if 'target' in kwargs:
        kwargs['target'] = 'unittest-'+kwargs['target']
    test = env.Program(source=source, **kwargs)
    unittest = env.Test( test[0].abspath+'.unittest_passed', test )
    if 'target' in kwargs:
        env.Alias(kwargs['target'], unittest)
    env.Alias('unittest', unittest)
    return test



def generate(env):
    """
    Add builders and construction variables for unittest.
    """
    import SCons.Builder
    unitTestBuilder = SCons.Builder.Builder(action = builder_unit_test)
    env.Append(BUILDERS = {'Test' : unitTestBuilder })
    
    SConsEnvironment.UnitTest = UnitTest


def exists(env):
    return True


<commit_msg>unittest: env propagation<commit_after>from SCons.Script.SConscript import SConsEnvironment

import os
import sys
import subprocess

windows = os.name.lower() == "nt" and sys.platform.lower().startswith("win")

ld_library_path = 'LD_LIBRARY_PATH' if not windows else 'PATH'
mpsep = ':' if not windows else ';'


#
# Function taken from scons Wiki
#
def builder_unit_test(target, source, env):
	app = str(source[0].abspath)
	procenv = env['ENV']
	procenv[ld_library_path] = mpsep.join(env['LIBPATH'])
	if subprocess.call(app, env=procenv) == 0:
		open(str(target[0]), 'w').write("PASSED\n")
	else:
		return 1


def UnitTest(env, source, **kwargs):
	if 'target' in kwargs:
		kwargs['target'] = 'unittest-'+kwargs['target']
	test = env.Program(source=source, **kwargs)
	unittest = env.Test( test[0].abspath+'.unittest_passed', test )
	if 'target' in kwargs:
		env.Alias(kwargs['target'], unittest)
	env.Alias('unittest', unittest)
	return test


def generate(env):
	"""
	Add builders and construction variables for unittest.
	"""
	import SCons.Builder
	unitTestBuilder = SCons.Builder.Builder(action = builder_unit_test)
	env.Append(BUILDERS = {'Test' : unitTestBuilder })

	SConsEnvironment.UnitTest = UnitTest


def exists(env):
	return True



{'fraction_non_alphanumeric': 0.1403118040089087, 'fraction_numerical': 0.004454342984409799, 'mean_word_length': 4.5594059405940595, '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': '3663426', 'n_tokens_mistral': 786, 'n_tokens_neox': 756, 'n_words': 180}