<commit_before>#!/bin/sh

TOTAL_NUM=0
FAILED_NUM=0

fail()
{
	FAILED_NUM=$(($FAILED_NUM + 1))

	while [ $# -gt 0 ]; do
		echo "$1"
		shift
	done
}

errmsg()
{
	while [ $# -gt 0 ]; do
		echo "$1" > /dev/stderr
		shift
	done

	exit 1
}

DIR=`dirname $0`
SYMBIOTIC=`readlink -f $DIR/../install/bin/symbiotic`

if [ ! -f $SYMBIOTIC ]; then
	errmsg "Couldn't find compiled symbiotic"
fi

if [ $# -ne 1 ]; then
	errmsg "Usage: $0 tests.txt"
fi

TESTS=`readlink -f $1`
cat $TESTS | while read DESIRED ARGS; do
	TOTAL_NUM=$(($TOTAL_NUM + 1))
	OUTPUT=`$SYMBIOTIC $ARGS 2>&1`
	echo -n "$ARGS ... "

	if [ "$DESIRED" = "FALSE" ]; then
		echo "$OUTPUT" | grep -q "RESULT: false" || fail "FAILED"
		echo "OK"
	elif [ "$DESIRED" = "TRUE" ]; then
		echo "$OUTPUT" | grep -q "RESULT: true" || fail "FAILED"
		echo "OK"
	else
		errmsg  "Wrong syntax in tests.txt"
	fi
done

if [ $FAILED_NUM -ne 0 ]; then
	echo " ------------------------------------ "
	echo "$FAILED_NUM of $TOTAL_NUM tests failed"
	echo " ------------------------------------ "
	exit 1
fi
<commit_msg>run-tests: fix parsing result<commit_after>#!/bin/sh

TOTAL_NUM=0
FAILED_NUM=0

fail()
{
	FAILED_NUM=$(($FAILED_NUM + 1))

	while [ $# -gt 0 ]; do
		echo "$1"
		shift
	done
}

errmsg()
{
	while [ $# -gt 0 ]; do
		echo "$1" > /dev/stderr
		shift
	done

	exit 1
}

DIR=`dirname $0`
SYMBIOTIC=`readlink -f $DIR/../install/bin/symbiotic`

if [ ! -f $SYMBIOTIC ]; then
	errmsg "Couldn't find compiled symbiotic"
fi

if [ $# -ne 1 ]; then
	errmsg "Usage: $0 tests.txt"
fi

TESTS=`readlink -f $1`
cat $TESTS | while read DESIRED ARGS; do
	TOTAL_NUM=$(($TOTAL_NUM + 1))
	OUTPUT=`$SYMBIOTIC $ARGS 2>&1`
	echo -n "$ARGS ... "

	if [ "$DESIRED" = "FALSE" ]; then
		if echo "$OUTPUT" | grep -q "RESULT: false"; then
			echo "OK"
		else
			fail "FAILED"
		fi
	elif [ "$DESIRED" = "TRUE" ]; then
		if echo "$OUTPUT" | grep -q "RESULT: true"; then
			echo "OK"
		else
			fail "FAILED"
		fi
	else
		errmsg  "Wrong syntax in tests.txt"
	fi
done

if [ $FAILED_NUM -ne 0 ]; then
	echo " ------------------------------------ "
	echo "$FAILED_NUM of $TOTAL_NUM tests failed"
	echo " ------------------------------------ "
	exit 1
fi

{'fraction_non_alphanumeric': 0.22643253234750463, 'fraction_numerical': 0.015711645101663587, 'mean_word_length': 2.38810641627543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2085600', 'n_tokens_mistral': 940, 'n_tokens_neox': 868, 'n_words': 251}