<commit_before>#!/bin/sh

CRASHLOGFILE="/tmp/crash.log"
LOGFILE="/tmp/crash-last.log"
MAX_ERROR=20
ERRORCOUNT=0

log()
{
	DATE=`date "+%F %T"`
	echo "$DATE: $*" >> $CRASHLOGFILE
}

safe_exit()
{
        if [ "$CRASHTEST_ATEXIT" != "" ]; then
                $CRASHTEST_ATEXIT
        fi
        exit $1
}

infinite_loop()
{
	while (:); do
		log "Starting '$*'"
        	$* > $LOGFILE
                EXITSTATUS=$?
                if [ "$EXITSTATUS" = "6" ]; then
                        log "Assert fail"
                        ERRORCOUNT=`expr $ERRORCOUNT + 1`
                        if [ "$ERRORCOUNT" -gt $MAX_ERROR ]; then
                        	safe_exit 1
                        fi
                fi
                if [ "$EXITSTATUS" = "1" ]; then
                	log "Test failed, exiting"
                	safe_exit 1
                fi
                log "Program exited with status $EXITSTATUS"
	done
}

infinite_loop $* & 
<commit_msg>Fixed crashtest ERRORCOUNT.<commit_after>#!/bin/sh

CRASHLOGFILE="/tmp/crash.log"
LOGFILE="/tmp/crash-last.log"
MAX_ERROR=20
ERRORCOUNT=1

log()
{
	DATE=`date "+%F %T"`
	echo "$DATE: ($ERRORCOUNT) $*" >> $CRASHLOGFILE
}

safe_exit()
{
        if [ "$CRASHTEST_ATEXIT" != "" ]; then
                $CRASHTEST_ATEXIT
        fi
        exit $1
}

infinite_loop()
{
	while (:); do
		log "Starting '$*'"
        	$* > $LOGFILE
                EXITSTATUS=$?
                if [ "$EXITSTATUS" = "6" ]; then
                        log "Assert fail"
                        ERRORCOUNT=`expr $ERRORCOUNT + 1`
                        if [ $ERRORCOUNT -gt $MAX_ERROR ]; then
                        	safe_exit 1
                        fi
                fi
                if [ "$EXITSTATUS" = "1" ]; then
                	log "Test failed, exiting"
                	safe_exit 1
                fi
                log "Program exited with status $EXITSTATUS"
	done
}

infinite_loop $* & 

{'fraction_non_alphanumeric': 0.12706611570247933, 'fraction_numerical': 0.009297520661157025, 'mean_word_length': 1.325330132052821, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5786328', 'n_tokens_mistral': 638, 'n_tokens_neox': 610, 'n_words': 133}