<commit_before><commit_msg>Add Asheesh's script that runs tests in a cloned repository.<commit_after>#!/bin/bash

CLONE_AND_TEST_LOCK="/tmp/clone-and-test-$USER"
mkdir $CLONE_AND_TEST_LOCK || die "Could not lock clone-and-test."

notify_send() {
    notify-send -u critical -t 10000 "$1"
}

find_or_die() {
    which $1 2>&1 > /dev/null || die Could not find $1
}

die() {
    echo $1 >&2
    exit 1
}

REPO="$1"

## Check for dependencies
find_or_die notify-send
find_or_die git

## Create a clone of the git repository
MYTEMP="$(mktemp -d /tmp/$(date -I)-testing-git-clone.XXXX)"
cd "$MYTEMP"
nohup git clone "$REPO"

# Find test.sh
cd "$(dirname */*/test.sh)"
nohup ./test.sh

result=$?

if [ $result -eq 0 ]; then
    notify_send "Tests aced! Deleting temporary clone."
    sleep 5
    rm -rf "$MYTEMP"
else
    notify_send "Tests failboated. Temporary clone in $MYTEMP"
    # Do not delete the directory
fi

rmdir "$CLONE_AND_TEST_LOCK"
{'fraction_non_alphanumeric': 0.1381509032943677, 'fraction_numerical': 0.01700318809776833, 'mean_word_length': 3.6176470588235294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5983242', 'n_tokens_mistral': 361, 'n_tokens_neox': 347, 'n_words': 106}