Rework translation tests

Rework test-languages so that we can test *all* languages as well
if needed and use the same script for both buildlang and testlang.
Add new tox job "publishlang" to publish all languages at once.

Change-Id: I7c7a5622df219f8ffa2dd1b824179de749ea2fed
This commit is contained in:
Andreas Jaeger 2014-06-30 20:47:51 +02:00
parent fdf714dfee
commit 1eaaf99b5c
2 changed files with 116 additions and 33 deletions

View File

@ -4,6 +4,7 @@ function setup_directory {
SET_LANG=$1 SET_LANG=$1
shift shift
for BOOK_DIR in "$@" ; do for BOOK_DIR in "$@" ; do
echo " $BOOK_DIR"
openstack-generate-docbook -l $SET_LANG -b $BOOK_DIR -r ./ openstack-generate-docbook -l $SET_LANG -b $BOOK_DIR -r ./
done done
} }
@ -18,34 +19,115 @@ function setup_lang {
cp pom.xml generated/$SET_LANG/pom.xml cp pom.xml generated/$SET_LANG/pom.xml
} }
function test_manuals { function test_api_quick_start {
SET_LANG=$1 SET_LANG=$1
shift shift
setup_lang $SET_LANG
for BOOK in "$@" ; do case "$PURPOSE" in
echo "Building $BOOK for language $SET_LANG..." test)
setup_directory $SET_LANG $BOOK setup_directory $SET_LANG 'api-quick-start'
openstack-doc-test --check-build -l $SET_LANG --only-book $BOOK openstack-doc-test -v --check-build -l $SET_LANG \
--only-book api-quick-start
RET=$? RET=$?
;;
publish)
setup_directory $SET_LANG 'api-quick-start'
openstack-doc-test -v --publish --check-build -l $SET_LANG \
--only-book api-quick-start
RET=$?
;;
esac
if [ "$RET" -eq "0" ] ; then if [ "$RET" -eq "0" ] ; then
echo "... succeeded" echo "... succeeded"
else else
echo "... failed" echo "... failed"
BUILD_FAIL=1 BUILD_FAIL=1
fi fi
done
} }
function test_all { function test_de {
test_manuals 'de' 'api-quick-start' setup_lang 'de'
test_manuals 'es' 'api-quick-start' test_api_quick_start 'de'
test_manuals 'fr' 'api-quick-start'
test_manuals 'ja' 'api-quick-start'
test_manuals 'ko_KR' 'api-quick-start'
} }
function test_es {
setup_lang 'es'
test_api_quick_start 'es'
}
function test_fr {
setup_lang 'fr'
test_api_quick_start 'fr'
}
function test_ko_KR {
setup_lang 'ko_KR'
test_api_quick_start 'ko_KR'
}
function test_ja {
setup_lang 'ja'
test_api_quick_start 'ja'
}
function test_language () {
case "$language" in
all)
test_de
test_es
test_fr
test_ja
test_ko_KR
;;
de)
test_de
;;
es)
test_es
;;
fr)
test_fr
;;
ja)
test_ja
;;
ko_KR)
test_ko_KR
;;
*)
BUILD_FAIL=1
echo "Language $language not handled"
;;
esac
}
function usage () {
echo "Call the script as: "
echo "$0 PURPOSE LANGUAGE1 LANGUAGE2..."
echo "PURPOSE is either 'test', 'publish' or 'publish-install'"
echo "LANGUAGE can also be 'all'."
}
if [ "$#" -lt 2 ] ; then
usage
exit 1
fi
if [ "$1" = "test" ] ; then
PURPOSE="test"
elif [ "$1" = "publish" ] ; then
PURPOSE="publish"
else
usage
exit 1
fi
shift
BUILD_FAIL=0 BUILD_FAIL=0
test_all for language in "$@" ; do
echo
echo "Building for language $language"
echo
test_language "$language"
done
exit $BUILD_FAIL exit $BUILD_FAIL

25
tox.ini
View File

@ -42,25 +42,26 @@ commands =
mv publish-docs/api-ref-guides publish-docs/api-ref/ mv publish-docs/api-ref-guides publish-docs/api-ref/
[testenv:checklang] [testenv:checklang]
# Generatedocbook needs xml2po which cannot be installed # openstack-generate-docbook needs xml2po which cannot be installed in
# in the venv. Since it's installed in the system, let's # the venv. Since it's installed in the system, let's use
# use sitepackages. # sitepackages.
sitepackages=True sitepackages=True
whitelist_externals = bash whitelist_externals = bash
commands = bash tools/test-languages.sh commands = bash tools/test-languages.sh test all
[testenv:buildlang] [testenv:buildlang]
# Run as "tox -e buildlang -- $LANG" # Run as "tox -e buildlang -- $LANG"
# openstack-generate-docbook needs xml2po which cannot be installed # openstack-generate-docbook needs xml2po which cannot be installed
# in the venv. Since it's installed in the system, let's # in the venv. Since it's installed in the system, let's
# use sitepackages. # use sitepackages.
# For now this only builds api-quick-start
sitepackages=True sitepackages=True
whitelist_externals = bash whitelist_externals = bash
commands = commands = bash tools/test-languages.sh publish {posargs}
openstack-generate-docbook -l {posargs} -b api-quick-start -r ./
# tox 1.7 does not parse the following line: [testenv:publishlang]
# cp doc/pom.xml generated/{posargs}/pom.xml # openstack-generate-docbook needs xml2po which cannot be installed
# Thus replaced by the next one: # in the venv. Since it's installed in the system, let's
bash ./tools/copy_pom {posargs} # use sitepackages.
openstack-doc-test --check-build --publish -l {posargs} --only-book api-quick-start sitepackages=True
whitelist_externals = bash
commands = bash tools/test-languages.sh publish all