<commit_before>#!/bin/sh

export BASE_DIR="$(cd $(dirname $0); pwd)"
top_dir="$BASE_DIR/.."

if test "$NO_MAKE" != "yes"; then
    make -C ${top_dir} > /dev/null || exit 1
fi

if test -z "$MYSQL_SOURCE"; then
    MYSQL_SOURCE="$(make -s -C $top_dir echo-mysql-source)"
fi
export MYSQL_SOURCE

if test -z "$MYSQL_BUILD"; then
    MYSQL_BUILD="$(make -s -C $top_dir echo-mysql-build)"
fi
export MYSQL_BUILD

if test -z "$MYSQL_VERSION"; then
    MYSQL_VERSION="$(make -s -C $top_dir echo-mysql-version)"
fi
export MYSQL_VERSION

test_suite_names="mroonga_storage,mroonga_wrapper"
source_mysql_test_dir="${MYSQL_SOURCE}/mysql-test"
build_mysql_test_dir="${MYSQL_BUILD}/mysql-test"
source_test_suites_dir="${source_mysql_test_dir}/suite"
build_test_suites_dir="${build_mysql_test_dir}/suite"
build_test_include_dir="${build_mysql_test_dir}/include"
case "${MYSQL_VERSION}" in
    5.1.*)
	plugins_dir="${MYSQL_BUILD}/lib/mysql/plugin"
	if ! test -d "${build_test_suites_dir}"; then
	    mkdir -p "${build_test_suites_dir}"
	fi
	;;
    *-MariaDB*)
	if ! test -d "${build_test_suites_dir}"; then
	    ln -s "${source_test_suites_dir}" "${build_test_suites_dir}"
	fi
	if ! test -d "${MYSQL_BUILD}/plugin/mroonga"; then
	    ln -s "${top_dir}" "${MYSQL_BUILD}/plugin/mroonga"
	fi
	;;
    *)
	if ! test -d "${build_test_suites_dir}"; then
	    ln -s "${source_test_suites_dir}" "${build_test_suites_dir}"
	fi
	plugins_dir="${MYSQL_SOURCE}/lib/plugin"
	;;
esac

same_link_p()
{
    src=$1
    dest=$2
    if test -L "$dest" -a "$(readlink "$dest")" = "$src"; then
	return 0
    else
	return 1
    fi
}

local_mroonga_mysql_test_include_dir="${BASE_DIR}/sql/include"
for test_include_name in $(ls $local_mroonga_mysql_test_include_dir | grep '\.inc$'); do
    local_mroonga_mysql_test_include="${local_mroonga_mysql_test_include_dir}/${test_include_name}"
    mroonga_mysql_test_include="${build_test_include_dir}/${test_include_name}"
    if ! same_link_p "${local_mroonga_mysql_test_include}" \
			"${mroonga_mysql_test_include}"; then
	rm -f "${mroonga_mysql_test_include}"
        ln -s "${local_mroonga_mysql_test_include}" \
	    "${mroonga_mysql_test_include}"
    fi
done

for test_suite_name in $(echo $test_suite_names | sed -e 's/,/ /g'); do
    local_mroonga_mysql_test_suite_dir="${BASE_DIR}/sql/suite/${test_suite_name}"
    mroonga_mysql_test_suite_dir="${build_test_suites_dir}/${test_suite_name}"
    if ! same_link_p "${local_mroonga_mysql_test_suite_dir}" \
			"${mroonga_mysql_test_suite_dir}"; then
	rm -f "${mroonga_mysql_test_suite_dir}"
	ln -s "${local_mroonga_mysql_test_suite_dir}" \
	    "${mroonga_mysql_test_suite_dir}"
    fi
done

innodb_test_suite_dir="${build_test_suites_dir}/innodb"
mroonga_wrapper_innodb_test_suite_dir="${build_test_suites_dir}/mroonga_wrapper_innodb"
if test "$0" -nt "$(dirname "${mroonga_wrapper_innodb_test_suite_dir}")"; then
    rm -rf "${mroonga_wrapper_innodb_test_suite_dir}"
fi
if ! test -d "${mroonga_wrapper_innodb_test_suite_dir}"; then
    cp -rp "${innodb_test_suite_dir}" "${mroonga_wrapper_innodb_test_suite_dir}"
    ruby -i'' \
	-pe "\$_.gsub!(/\bengine\s*=\s*innodb\b([^;\\n]*)/i,
                      \"ENGINE=mroonga\\\1 COMMENT='ENGINE \\\"InnoDB\\\"'\")
             \$_.gsub!(/\b(storage_engine\s*=\s*)innodb\b([^;\\n]*)/i,
                      \"\\\1mroonga\")
            " \
	${mroonga_wrapper_innodb_test_suite_dir}/r/*.result \
	${mroonga_wrapper_innodb_test_suite_dir}/t/*.test \
	${mroonga_wrapper_innodb_test_suite_dir}/include/*.inc \
	${build_test_include_dir}/innodb_*.inc # over our work. :<
    sed -i'' \
	-e '1 i --source include/have_mroonga.inc' \
	${mroonga_wrapper_innodb_test_suite_dir}/t/*.test
fi<commit_msg>wrapper innodb test: add missing escapes<commit_after>#!/bin/sh

export BASE_DIR="$(cd $(dirname $0); pwd)"
top_dir="$BASE_DIR/.."

if test "$NO_MAKE" != "yes"; then
    make -C ${top_dir} > /dev/null || exit 1
fi

if test -z "$MYSQL_SOURCE"; then
    MYSQL_SOURCE="$(make -s -C $top_dir echo-mysql-source)"
fi
export MYSQL_SOURCE

if test -z "$MYSQL_BUILD"; then
    MYSQL_BUILD="$(make -s -C $top_dir echo-mysql-build)"
fi
export MYSQL_BUILD

if test -z "$MYSQL_VERSION"; then
    MYSQL_VERSION="$(make -s -C $top_dir echo-mysql-version)"
fi
export MYSQL_VERSION

test_suite_names="mroonga_storage,mroonga_wrapper"
source_mysql_test_dir="${MYSQL_SOURCE}/mysql-test"
build_mysql_test_dir="${MYSQL_BUILD}/mysql-test"
source_test_suites_dir="${source_mysql_test_dir}/suite"
build_test_suites_dir="${build_mysql_test_dir}/suite"
build_test_include_dir="${build_mysql_test_dir}/include"
case "${MYSQL_VERSION}" in
    5.1.*)
	plugins_dir="${MYSQL_BUILD}/lib/mysql/plugin"
	if ! test -d "${build_test_suites_dir}"; then
	    mkdir -p "${build_test_suites_dir}"
	fi
	;;
    *-MariaDB*)
	if ! test -d "${build_test_suites_dir}"; then
	    ln -s "${source_test_suites_dir}" "${build_test_suites_dir}"
	fi
	if ! test -d "${MYSQL_BUILD}/plugin/mroonga"; then
	    ln -s "${top_dir}" "${MYSQL_BUILD}/plugin/mroonga"
	fi
	;;
    *)
	if ! test -d "${build_test_suites_dir}"; then
	    ln -s "${source_test_suites_dir}" "${build_test_suites_dir}"
	fi
	plugins_dir="${MYSQL_SOURCE}/lib/plugin"
	;;
esac

same_link_p()
{
    src=$1
    dest=$2
    if test -L "$dest" -a "$(readlink "$dest")" = "$src"; then
	return 0
    else
	return 1
    fi
}

local_mroonga_mysql_test_include_dir="${BASE_DIR}/sql/include"
for test_include_name in $(ls $local_mroonga_mysql_test_include_dir | grep '\.inc$'); do
    local_mroonga_mysql_test_include="${local_mroonga_mysql_test_include_dir}/${test_include_name}"
    mroonga_mysql_test_include="${build_test_include_dir}/${test_include_name}"
    if ! same_link_p "${local_mroonga_mysql_test_include}" \
			"${mroonga_mysql_test_include}"; then
	rm -f "${mroonga_mysql_test_include}"
        ln -s "${local_mroonga_mysql_test_include}" \
	    "${mroonga_mysql_test_include}"
    fi
done

for test_suite_name in $(echo $test_suite_names | sed -e 's/,/ /g'); do
    local_mroonga_mysql_test_suite_dir="${BASE_DIR}/sql/suite/${test_suite_name}"
    mroonga_mysql_test_suite_dir="${build_test_suites_dir}/${test_suite_name}"
    if ! same_link_p "${local_mroonga_mysql_test_suite_dir}" \
			"${mroonga_mysql_test_suite_dir}"; then
	rm -f "${mroonga_mysql_test_suite_dir}"
	ln -s "${local_mroonga_mysql_test_suite_dir}" \
	    "${mroonga_mysql_test_suite_dir}"
    fi
done

innodb_test_suite_dir="${build_test_suites_dir}/innodb"
mroonga_wrapper_innodb_test_suite_dir="${build_test_suites_dir}/mroonga_wrapper_innodb"
if test "$0" -nt "$(dirname "${mroonga_wrapper_innodb_test_suite_dir}")"; then
    rm -rf "${mroonga_wrapper_innodb_test_suite_dir}"
fi
if ! test -d "${mroonga_wrapper_innodb_test_suite_dir}"; then
    cp -rp "${innodb_test_suite_dir}" "${mroonga_wrapper_innodb_test_suite_dir}"
    ruby -i'' \
	-pe "\$_.gsub!(/\\bengine\\s*=\\s*innodb\\b([^;\\n]*)/i,
                      \"ENGINE=mroonga\\\1 COMMENT='ENGINE \\\"InnoDB\\\"'\")
             \$_.gsub!(/\\b(storage_engine\\s*=\\s*)innodb\\b([^;\\n]*)/i,
                      \"\\\1mroonga\")
            " \
	${mroonga_wrapper_innodb_test_suite_dir}/r/*.result \
	${mroonga_wrapper_innodb_test_suite_dir}/t/*.test \
	${mroonga_wrapper_innodb_test_suite_dir}/include/*.inc \
	${build_test_include_dir}/innodb_*.inc # over our work. :<
    sed -i'' \
	-e '1 i --source include/have_mroonga.inc' \
	${mroonga_wrapper_innodb_test_suite_dir}/t/*.test
fi
{'fraction_non_alphanumeric': 0.16238396340643077, 'fraction_numerical': 0.003228844342795641, 'mean_word_length': 4.666158536585366, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2717913', 'n_tokens_mistral': 3074, 'n_tokens_neox': 2997, 'n_words': 458}