Index: incubator/apertium-bel-rus/t/.gitignore =================================================================== --- incubator/apertium-bel-rus/t/.gitignore (nonexistent) +++ incubator/apertium-bel-rus/t/.gitignore (revision 71863) @@ -0,0 +1,3 @@ +*.html +config.sh +*.results Index: incubator/apertium-bel-rus/t/README.org =================================================================== --- incubator/apertium-bel-rus/t/README.org (nonexistent) +++ incubator/apertium-bel-rus/t/README.org (revision 71863) @@ -0,0 +1,47 @@ +#+STARTUP: showall + + +* Setting up tests for a new language pair +To add these test scripts to your language pair, go into your language +pair directory and do: + +#+BEGIN_SRC sh +git clone https://github.com/unhammer/apertium-wiki-tests t +# edit t/config.sh.in and save as t/config.sh +svn add --depth=files t +#+END_SRC + +You should have your tests in a page named after your language pair, e.g. +http://wiki.apertium.org/wiki/apertium-sme-smj/Regression_tests +and +http://wiki.apertium.org/wiki/apertium-sme-smj/Pending_tests + + +* Running the tests + +To run the tests from your language pair, assuming it's been set up as +shown above, do + +#+BEGIN_SRC sh + t/update-latest +#+END_SRC + +This will overwrite the files named t/latest-pending.results and +t/latest-regression.results. You can view the differences with + +#+BEGIN_SRC sh + svn diff +#+END_SRC + +Test results are kept in SVN since that means we don't have to keep +moving things back and forth between "Pending" and "Regression" in the +wiki whenever we pass a new test (or fail an old one), and we get a +nice log of our progression. + +To run just regression or just pending tests, use t/pending-tests or +t/regression-tests. Pass the -f argument to those scripts to only see +failed regression tests or passed pending tests, e.g. + +#+BEGIN_SRC sh +t/regression-tests -f +#+END_SRC Index: incubator/apertium-bel-rus/t/config.sh =================================================================== --- incubator/apertium-bel-rus/t/config.sh (nonexistent) +++ incubator/apertium-bel-rus/t/config.sh (revision 71863) @@ -0,0 +1 @@ +PAIRS=( bel-rus rus-bel ) Index: incubator/apertium-bel-rus/t/pending-tests =================================================================== --- incubator/apertium-bel-rus/t/pending-tests (nonexistent) +++ incubator/apertium-bel-rus/t/pending-tests (revision 71863) @@ -0,0 +1,11 @@ +#!/bin/bash + +# Run with -p to show only passing tests + +set -e -u + +source "$(dirname $0)"/config.sh + +for pair in "${PAIRS[@]}"; do + bash "$(dirname $0)"/wiki-tests -u "$@" Pending "${pair}" +done Property changes on: incubator/apertium-bel-rus/t/pending-tests ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: incubator/apertium-bel-rus/t/regression-tests =================================================================== --- incubator/apertium-bel-rus/t/regression-tests (nonexistent) +++ incubator/apertium-bel-rus/t/regression-tests (revision 71863) @@ -0,0 +1,11 @@ +#!/bin/bash + +# Run with -f to show only failing tests + +set -e -u + +source "$(dirname $0)"/config.sh + +for pair in "${PAIRS[@]}"; do + bash "$(dirname $0)"/wiki-tests -u "$@" Regression "${pair}" +done Property changes on: incubator/apertium-bel-rus/t/regression-tests ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: incubator/apertium-bel-rus/t/update-latest =================================================================== --- incubator/apertium-bel-rus/t/update-latest (nonexistent) +++ incubator/apertium-bel-rus/t/update-latest (revision 71863) @@ -0,0 +1,6 @@ +#!/bin/bash + +cd "$(dirname $0)"/../ +t/regression-tests > t/latest-regression.results & +t/pending-tests > t/latest-pending.results & +wait Property changes on: incubator/apertium-bel-rus/t/update-latest ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: incubator/apertium-bel-rus/t/wiki-tests =================================================================== --- incubator/apertium-bel-rus/t/wiki-tests (nonexistent) +++ incubator/apertium-bel-rus/t/wiki-tests (revision 71863) @@ -0,0 +1,171 @@ +#!/bin/bash + +set -e -u + +######## Globals: + +# You shouldn't have to change this unless the wiki gets a new host: +if [[ ! -f "$(dirname $0)/../config.log" ]]; then + echo "Can't find $(dirname $0)/../config.log, did you forget to run autogen.sh?" >&2 + exit 1 +fi +declare -r PACKAGE=$(grep ^PACKAGE= "$(dirname $0)/../config.log" |grep -o "apertium-[^']*") # e.g. apertium-sme-nob +declare -r BASEURL="http://wiki.apertium.org/wiki/${PACKAGE}" + +# Workarounds for Mac's: +SED=sed +if [[ "$(uname -s)" = Darwin ]]; then + SED=gsed +fi +declare -r SED + + +######## Functions: + +fetchtests () { + local -r update=$1 + local -r testtype=$2 + local -r html=$3 + + if ${update}; then + tmp=$(mktemp -t wiki-tests.html.XXXXXXXXXX) + if wget -O "${tmp}" -q "${BASEURL}/${testtype}" && [[ -s "${tmp}" ]]; then + mv "${tmp}" "${html}" + else + rm "${tmp}" + echo "Couldn't fetch ${BASEURL}/${testtype}" >&2 + fi + fi + + if [[ ! -s "${html}" ]]; then + echo "${html} does not exist or is empty (use '-u' option)" >&2 + exit 1 + fi +} + +decodehtml() { + # Decodes the three HTML standard entities if they are part of the test, + # because even if they are not written as HTML entities in MediaWiki, they + # are rendered as such because we use the HTML rendering of the MediaWiki + # page as source. + sed -e "s/<//g" -e "s/&/\&/g" +} + +cleantst () { + # Would use these, but printf on Mac doesn't support unicode + # names, so the below sed's use *literal* byte-order-marks and + # zero-width-spaces: + local bom=$(env printf "\uFEFF") + local zws=$(env printf "\u200B") + $SED 's/^ *//; s/ *$//; s/\([^,.?!:;]\)$/\1./g; s/ */ /g' \ + | $SED -e "s///g" \ + | $SED -e "s///g" +} +cleansrc () { + local -r srclang=$1 trglang=$2 + local -r tdir="\\((${srclang})\\|(${srclang}-${trglang})\\)" + grep -o "