<commit_before>#!/bin/bash

set -e

function error {
    echo error: "$@"
    exit 1
}

function itime {
    /usr/bin/time "$@"
}

BUILD_GO=y
INTEGRATION=y
FAST=n
SHOW_HELP=n

TEMP=`getopt -o h --long help,no-go,no-integration,fast -n test.bash -- "$@"`
eval set -- "$TEMP"
while true; do
    case "$1" in
        -h|--help)      SHOW_HELP=y         ; shift   ;;
        --no-go)        BUILD_GO=n          ; shift   ;;
        --no-integration) INTEGRATION=n     ; shift   ;;
        --fast)         FAST=y              ; shift   ;;
        --)             shift               ; break   ;;
    esac
done

if [ "$SHOW_HELP" = y ]; then
    echo "usage: test.bash -h|--help"
    echo "       test.bash [--no-go] [--no-integration] [--fast]"
    exit 0
fi

function do_cmd {
    echo "[+] $@"
    eval "$@"
}

# Build Go
if [ "$BUILD_GO" = y ]; then
    export GOROOT_BOOTSTRAP
    [ -z "$GOROOT_BOOTSTRAP" ] && error "GOROOT_BOOTSTRAP not set"
    [ "$FAST" = y ] && fast_opt=--fast || fast_opt=
    do_cmd itime -p ./build.bash go $fast_opt
fi

# Run integration tests
if [ "$INTEGRATION" = y ]; then
    unigornel_root="$PWD"
    pushd integration_tests
    [ "$FAST" = y ] && fast_opt=--fast || fast_opt=
    UNIGORNEL_ROOT="$unigornel_root" do_cmd itime -p python3 test.py --junit "integration_tests.xml" $fast_opt
    popd
fi<commit_msg>Compile Go in test.bash directly<commit_after>#!/bin/bash

set -e

function error {
    echo error: "$@"
    exit 1
}

function itime {
    /usr/bin/time "$@"
}

BUILD_GO=y
INTEGRATION=y
FAST=n
SHOW_HELP=n

TEMP=`getopt -o h --long help,no-go,no-integration,fast -n test.bash -- "$@"`
eval set -- "$TEMP"
while true; do
    case "$1" in
        -h|--help)      SHOW_HELP=y         ; shift   ;;
        --no-go)        BUILD_GO=n          ; shift   ;;
        --no-integration) INTEGRATION=n     ; shift   ;;
        --fast)         FAST=y              ; shift   ;;
        --)             shift               ; break   ;;
    esac
done

if [ "$SHOW_HELP" = y ]; then
    echo "usage: test.bash -h|--help"
    echo "       test.bash [--no-go] [--no-integration] [--fast]"
    exit 0
fi

function do_cmd {
    echo "[+] $@"
    eval "$@"
}

# Build Go
if [ "$BUILD_GO" = y ]; then
    pushd go/src
    export GOROOT_BOOTSTRAP
    [ -z "$GOROOT_BOOTSTRAP" ] && error "GOROOT_BOOTSTRAP not set"
    [ "$FAST" = y ] && fast_opt=--no-clean || fast_opt=
    do_cmd GOOS=unigornel GOARCH=amd64 ./make.bash $fast_opt
    popd
fi

# Run integration tests
if [ "$INTEGRATION" = y ]; then
    unigornel_root="$PWD"
    pushd integration_tests
    [ "$FAST" = y ] && fast_opt=--fast || fast_opt=
    UNIGORNEL_ROOT="$unigornel_root" do_cmd itime -p python3 test.py --junit "integration_tests.xml" $fast_opt
    popd
fi
{'fraction_non_alphanumeric': 0.157319737800437, 'fraction_numerical': 0.003641660597232338, 'mean_word_length': 2.028665931642778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '4454199', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1054, 'n_words': 241}