Skip to content

Commit

Permalink
Optimize our tests to run faster.
Browse files Browse the repository at this point in the history
Changes include:

 * default tests locale is Polish instead of Spanish

   Rationale: see commit 049f59a.

              tl;dr¹: 1 vs 20 locales to generate, that’s all.

 * flake8 is running on its own build jobs.

   Rationale: we are now able to tell what passed and what didn’t at a
              glance.  We do not have to search through stuff to find out
              what (nosetests or flake8) failed.

 * Use the Travis apt cache, which will save us a few seconds here or
   there.

¹ This commit message is actually longer than the one in 049f59a.

Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Oct 30, 2013
1 parent 8b1f7fb commit d854906
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
18 changes: 9 additions & 9 deletions .travis.yml
@@ -1,6 +1,6 @@
before_install:
- "[[ $NMODE == 'nikola' ]] && sudo apt-get update -qq || true"
- "[[ $NMODE == 'nikola' ]] && sudo apt-get --reinstall install -qq language-pack-en language-pack-pl"
- "if [[ $NMODE == 'nikola' ]]; then sudo apt-get update -qq || true; fi"
- "if [[ $NMODE == 'nikola' ]]; then sudo apt-get --reinstall install -qq language-pack-en language-pack-pl; fi"
language: python
cache: apt
python:
Expand All @@ -11,16 +11,16 @@ env:
- NMODE=nikola
- NMODE=flake8
install:
- "[[ $NMODE == 'nikola' ]] && pip install -r requirements-tests.txt --use-mirrors || true"
- "[[ $NMODE == 'nikola' ]] && pip install . --use-mirrors || true"
- "[[ $NMODE == 'flake8' ]] && pip install flake8 --use-mirrors || true"
- "if [[ $NMODE == 'nikola' ]]; then pip install -r requirements-tests.txt --use-mirrors; fi"
- "if [[ $NMODE == 'nikola' ]]; then pip install . --use-mirrors; fi"
- "if [[ $NMODE == 'flake8' ]]; then pip install flake8 --use-mirrors; fi"
# We run tests, nikola (to see if the command is executable) and flake8.
script:
- "[[ $NMODE == 'nikola' ]] && nosetests --with-coverage --cover-package=nikola --with-doctest --doctest-options=+NORMALIZE_WHITESPACE --logging-filter=-yapsy || true"
- "[[ $NMODE == 'nikola' ]] && nikola help || true"
- "[[ $NMODE == 'flake8' ]] && flake8 --ignore=E501 . || true"
- "if [[ $NMODE == 'nikola' ]]; then nosetests --with-coverage --cover-package=nikola --with-doctest --doctest-options=+NORMALIZE_WHITESPACE --logging-filter=-yapsy; fi"
- "if [[ $NMODE == 'nikola' ]]; then nikola help; fi"
- "if [[ $NMODE == 'flake8' ]]; then flake8 --ignore=E501 .; fi"
after_success:
- "[[ $NMODE == 'nikola' ]] && coveralls || true"
- "if [[ $NMODE == 'nikola' ]]; then coveralls; fi"
notifications:
irc:
channels:
Expand Down
1 change: 0 additions & 1 deletion requirements-tests.txt
@@ -1,6 +1,5 @@
-r requirements-full.txt
coverage
nose
flake8
freezegun
python-coveralls
24 changes: 12 additions & 12 deletions tests/README.rst
Expand Up @@ -38,33 +38,33 @@ You need:
How to set the locale for Nikola tests?
---------------------------------------

For testing nikola needs to specify two languages, each one with a supported locale. By default, the test suite uses ``en`` and ``es`` as languages, and their respective default locale for them.
For testing nikola needs to specify two languages, each one with a supported locale. By default, the test suite uses ``en`` and ``pl`` as languages, and their respective default locale for them.

You can set the language - locale pairs by exporting two shell variables, like in::
The choice of Polish is due to having one locale to generate instead of 20 (Spanish) and you can happily ignore it — just set the languagelocale pairs by exporting two shell variables, for example::

export NIKOLA_LOCALE_DEFAULT=en,en_US.utf8
export NIKOLA_LOCALE_OTHER=es,es_ES.utf8
export NIKOLA_LOCALE_OTHER=pl,pl_PL.utf8

In Windows that would be::

set NIKOLA_LOCALE_DEFAULT=en,English
set NIKOLA_LOCALE_OTHER=es,Spanish
set NIKOLA_LOCALE_DEFAULT=en,English
set NIKOLA_LOCALE_OTHER=pl,Polish

Replace the part before the comma with a Nikola translation selector (see ``nikola/conf.py.in`` for details), and the part after the comma with an *installed* glibc locale.

To check if the desired locale is supported in your host you can, in a python console::

import locale
locale.setlocale(locale.LC_ALL, 'locale_name')
# by example, 'en_US.utf8' (posix) 'English' (windows)
# if it does not traceback, then python can use that locale
import locale
locale.setlocale(locale.LC_ALL, 'locale_name')
# for example, 'en_US.utf8' (posix) 'English' (windows)
# if it does not traceback, then python can use that locale

Alternatively, if you have some disk space to spare, you can install
the two default locales. Here is how to do that in Ubuntu::

sudo apt-get install language-pack-en language-pack-es
sudo apt-get install language-pack-en language-pack-pl


How to execute the tests
------------------------

Expand Down
8 changes: 4 additions & 4 deletions tests/base.py
Expand Up @@ -106,18 +106,18 @@ def initialize(cls):
if hasattr(cls, 'langlocales'):
return
defaults = {
'linux': {
'posix': {
# non-windows defaults, must be two locales suported by .travis.yml
'default': ("en", str("en_US.utf8")),
'other': ("es", str("es_ES.utf8")),
'other': ("pl", str("pl_PL.utf8")),
},
'windows': {
# windows defaults
'default': ("en", str("English")),
'other': ("es", str("Spanish")),
'other': ("pl", str("Polish")),
},
}
os_id = 'windows' if sys.platform == 'win32' else 'linux'
os_id = 'windows' if sys.platform == 'win32' else 'posix'
langlocales = {}
for suffix in ['other', 'default']:
try:
Expand Down

0 comments on commit d854906

Please sign in to comment.