<commit_before>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 ';'


def execute_ScriptTest(target, source, env):
	'''
	Execute source param executable and create a file into target param.
	'''
	app = str(source[0].abspath)
	outputFilename = str(target[0])
	procenv = env['ENV']
	
	# Format LIBPATH to convert expressions into plain filepath
	ldPaths = []
	for p in env['LIBPATH']:
		pp = p.replace('#', env['TOPDIR']+'/')
		pEval = env.subst(pp)
		if pEval:
			ldPaths.append(pEval)
	procenv[ld_library_path] = mpsep.join(ldPaths)

	writingFilename = outputFilename + "-writing"
	failedFilename = outputFilename + "-failed"

	# clean before the new build
	if os.path.exists(outputFilename):
		os.remove(outputFilename)
	if os.path.exists(writingFilename):
		os.remove(writingFilename)
	if os.path.exists(failedFilename):
		os.remove(failedFilename)

	# Execute the test.
	errcode = 0
	with open(writingFilename, 'w') as writingFile:
		errcode = subprocess.call([env['SCRIPTTESTXX'], app, env['SCRIPTTESTFLAGS']], env=procenv, stdout=writingFile, stderr=subprocess.STDOUT)

	for line in open(writingFilename, 'r').readlines():
		sys.stdout.write( "    " + line )

	# We use a fake file to keep a timestamp for file dependencies.
	# We keep the log inside this file.
	if errcode == 0:
		# The test is passed with success.
		# We rename the log file to the output dependence filename,
		# so the test will seen has done by scons, and
		# will not be executed again.
		os.rename(writingFilename, outputFilename)
	else:
		# the failed file is not the output dependence
		os.rename(writingFilename, failedFilename)
	return errcode


def ScriptTest(env, source, **kwargs):
	'''
	Function added to the SCons Environment.
	Build an application from source files and run this executable as a Test.
	'''
	target = ['scripttest']
	if 'target' not in kwargs:<commit_msg>fix SCRIPTTESTFLAGS to allow multiple values<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 ';'


def execute_ScriptTest(target, source, env):
	'''
	Execute source param executable and create a file into target param.
	'''
	app = str(source[0].abspath)
	outputFilename = str(target[0])
	procenv = env['ENV']
	
	# Format LIBPATH to convert expressions into plain filepath
	ldPaths = []
	for p in env['LIBPATH']:
		pp = p.replace('#', env['TOPDIR']+'/')
		pEval = env.subst(pp)
		if pEval:
			ldPaths.append(pEval)
	procenv[ld_library_path] = mpsep.join(ldPaths)

	writingFilename = outputFilename + "-writing"
	failedFilename = outputFilename + "-failed"

	# clean before the new build
	if os.path.exists(outputFilename):
		os.remove(outputFilename)
	if os.path.exists(writingFilename):
		os.remove(writingFilename)
	if os.path.exists(failedFilename):
		os.remove(failedFilename)

	# Execute the test.
	errcode = 0
	with open(writingFilename, 'w') as writingFile:
		errcode = subprocess.call([env['SCRIPTTESTXX'], app] + env['SCRIPTTESTFLAGS'].split(' '), env=procenv, stdout=writingFile, stderr=subprocess.STDOUT)

	for line in open(writingFilename, 'r').readlines():
		sys.stdout.write( "    " + line )

	# We use a fake file to keep a timestamp for file dependencies.
	# We keep the log inside this file.
	if errcode == 0:
		# The test is passed with success.
		# We rename the log file to the output dependence filename,
		# so the test will seen has done by scons, and
		# will not be executed again.
		os.rename(writingFilename, outputFilename)
	else:
		# the failed file is not the output dependence
		os.rename(writingFilename, failedFilename)
	return errcode


def ScriptTest(env, source, **kwargs):
	'''
	Function added to the SCons Environment.
	Build an application from source files and run this executable as a Test.
	'''
	target = ['scripttest']
	if 'target' not in kwargs:
{'fraction_non_alphanumeric': 0.11222301644031452, 'fraction_numerical': 0.0019061234214915416, 'mean_word_length': 4.575033200531209, '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': '2599640', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1322, 'n_words': 430}