<commit_before>#!/bin/bash

# Run basic ERMrest REST API tests 

usage()
{
    cat <<EOF
usage: $0

Runs test against BASE_URL environment (${BASE_URL}), default (https://$(hostname)/ermrest/).

Uses cookie store named in COOKIES environment ($COOKIES), if
specified.

A successful run will exit with status 0 and an empty standard output.

A failure will exit with status 1 and a non-empty standard output.

Test case failures will not abort testing unless ABORT_ON_FAILURE is
set to "true". However, 500 Internal Server Error responses will
always abort testing.

Setting VERBOSE=true will include full per-test information on
standard output for successes as well as failures. VERBOSE=brief will
output a single line per successful test.

Diagnostics may be printed to standard error regardless of success or
failure.

EOF
}

error()
{
    cat <<EOF
$0: $*
EOF
    usage >&2
    exit 1
}

RUNKEY=smoketest-$RANDOM
RESPONSE_HEADERS=/tmp/${RUNKEY}-response-headers
RESPONSE_CONTENT=/tmp/${RUNKEY}-response-content
TEST_DATA=/tmp/${RUNKEY}-test-data

cleanup()
{
    rm -f ${RESPONSE_HEADERS} ${RESPONSE_CONTENT} ${TEST_DATA}
    rm -f /tmp/parts-${RUNKEY}*
}

trap cleanup 0

declare -a curl_options
curl_options=(
 -D ${RESPONSE_HEADERS}
 -o ${RESPONSE_CONTENT}
 -s -k
 -w "%{http_code}::%{content_type}::%{size_download}\n"
)

if [[ -n "$COOKIES" ]]
then
    curl_options+=( -b "$COOKIES" -c "$COOKIES" )
fi

mycurl()
{
    touch ${RESPONSE_HEADERS}
    touch ${RESPONSE_CONTENT}
    truncate -s 0 ${RESPONSE_HEADERS}
    truncate -s 0 ${RESPONSE_CONTENT}
    curl "${curl_options[@]}" "$@"
}
<commit_msg>only use `-b cookie` and not `-c cookie` so tests access cookie file read-only<commit_after>#!/bin/bash

# Run basic ERMrest REST API tests 

usage()
{
    cat <<EOF
usage: $0

Runs test against BASE_URL environment (${BASE_URL}), default (https://$(hostname)/ermrest/).

Uses cookie store named in COOKIES environment ($COOKIES), if
specified.

A successful run will exit with status 0 and an empty standard output.

A failure will exit with status 1 and a non-empty standard output.

Test case failures will not abort testing unless ABORT_ON_FAILURE is
set to "true". However, 500 Internal Server Error responses will
always abort testing.

Setting VERBOSE=true will include full per-test information on
standard output for successes as well as failures. VERBOSE=brief will
output a single line per successful test.

Diagnostics may be printed to standard error regardless of success or
failure.

EOF
}

error()
{
    cat <<EOF
$0: $*
EOF
    usage >&2
    exit 1
}

RUNKEY=smoketest-$RANDOM
RESPONSE_HEADERS=/tmp/${RUNKEY}-response-headers
RESPONSE_CONTENT=/tmp/${RUNKEY}-response-content
TEST_DATA=/tmp/${RUNKEY}-test-data

cleanup()
{
    rm -f ${RESPONSE_HEADERS} ${RESPONSE_CONTENT} ${TEST_DATA}
    rm -f /tmp/parts-${RUNKEY}*
}

trap cleanup 0

declare -a curl_options
curl_options=(
 -D ${RESPONSE_HEADERS}
 -o ${RESPONSE_CONTENT}
 -s -k
 -w "%{http_code}::%{content_type}::%{size_download}\n"
)

if [[ -n "$COOKIES" ]]
then
    curl_options+=( -b "$COOKIES" )
fi

mycurl()
{
    touch ${RESPONSE_HEADERS}
    touch ${RESPONSE_CONTENT}
    truncate -s 0 ${RESPONSE_HEADERS}
    truncate -s 0 ${RESPONSE_CONTENT}
    curl "${curl_options[@]}" "$@"
}

{'fraction_non_alphanumeric': 0.11968166513621059, 'fraction_numerical': 0.0073461891643709825, 'mean_word_length': 4.1545741324921135, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2533120', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1134, 'n_words': 367}