<commit_before>#!/bin/sh -ex

pt () {
    python setup.py test --addopts "$*"
}

if [ "$BACKEND_TEST" ] ; then
    if [ "$SQLITE_TEST" ] ; then
        pt --verbose -m sqlite_source
    fi

    if [ "$POSTGRES_TEST" ] ; then
        psql -c 'DROP DATABASE IF EXISTS test;' -U postgres
        psql -c 'create database test;' -U postgres
        export POSTGRES_URI='postgresql+psycopg2://postgres@localhost/test'
        pt --verbose -m postgres_source
        export POSTGRES_URI='postgresql+pg8000://postgres@localhost/test'
        pt --verbose -m postgres_source
    fi

    if [ "$MYSQL_TEST" ] ; then
        mysql -u root -e 'DROP DATABASE IF EXISTS test;'
        mysql -u root -e 'CREATE DATABASE test DEFAULT CHARACTER SET utf8;'
        mysql -u root -e "CREATE USER IF NOT EXISTS 'test' IDENTIFIED BY 'password';"
        mysql -u root -e "GRANT ALL ON test.* TO 'test';"
        export MYSQL_URI='mysql+mysqlconnector://test:password@localhost/test?charset=utf8&auth_plugin=mysql_native_password'
        pt --verbose -m mysql_source
        export MYSQL_URI='mysql+mysqldb://test:password@localhost/test?charset=utf8'
        pt --verbose -m mysql_source
    fi
else
    pt --verbose -m "'not inttest and not owm_cli_test'" --cov=owmeta
    mv .coverage .coverage-unit
    pt --verbose -m inttest --cov=owmeta
    mv .coverage .coverage-integration
    if [ $WORKERS ] ; then
        pt --workers $WORKERS -m owm_cli_test --cov=owmeta
    else
        pt --verbose -m owm_cli_test --cov=owmeta
    fi
    coverage combine .coverage-integration .coverage-unit .coverage
fi
<commit_msg>Combining SQL backend tests into main jobs and adding code coverage for them<commit_after>#!/bin/sh -ex

pt () {
    python setup.py test --addopts "$* --cov=owmeta"
}


COVERAGES=""

add_coverage () {
    tempname="$(mktemp ow-meta-test-coverage.XXXXXXXXXX)"
    cat .coverage > $tempname
    COVERAGES="$COVERAGES $tempname"
}

list_coverage () {
    echo $COVERAGES
}

cleanup_coverage () {
    if [ "$COVERAGES" ] ; then
        rm $COVERAGES
    fi
}

trap cleanup_coverage EXIT

if [ "$SQLITE_TEST" ] ; then
    pt --verbose -m sqlite_source
    add_coverage
fi

if [ "$POSTGRES_TEST" ] ; then
    psql -c 'DROP DATABASE IF EXISTS test;' -U postgres
    psql -c 'create database test;' -U postgres
    export POSTGRES_URI='postgresql+psycopg2://postgres@localhost/test'
    pt --verbose -m postgres_source
    add_coverage
    export POSTGRES_URI='postgresql+pg8000://postgres@localhost/test'
    pt --verbose -m postgres_source
    add_coverage
fi

if [ "$MYSQL_TEST" ] ; then
    mysql -u root -e 'DROP DATABASE IF EXISTS test;'
    mysql -u root -e 'CREATE DATABASE test DEFAULT CHARACTER SET utf8;'
    mysql -u root -e "CREATE USER IF NOT EXISTS 'test' IDENTIFIED BY 'password';"
    mysql -u root -e "GRANT ALL ON test.* TO 'test';"
    export MYSQL_URI='mysql+mysqlconnector://test:password@localhost/test?charset=utf8&auth_plugin=mysql_native_password'
    pt --verbose -m mysql_source
    add_coverage
    export MYSQL_URI='mysql+mysqldb://test:password@localhost/test?charset=utf8'
    pt --verbose -m mysql_source
    add_coverage
fi
pt --verbose -m "'not inttest and not owm_cli_test'"
add_coverage
pt --verbose -m inttest
add_coverage
if [ $WORKERS ] ; then
    pt --workers $WORKERS -m owm_cli_test
else
    pt --verbose -m owm_cli_test
fi
add_coverage
coverage combine $(list_coverage)

{'fraction_non_alphanumeric': 0.11336270190895742, 'fraction_numerical': 0.004698972099853157, 'mean_word_length': 2.983625730994152, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, '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': '1811111', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1169, 'n_words': 330}