On Wed, Jul 10, 2013 at 12:35 PM, Jose A. Lopes <[email protected]>wrote:

> From: "Jose A. Lopes" <[email protected]>
>
> Add Makefile.am target hs-test-% for single-execution of Haskell
> tests.
>
> Add Makefile.am target hs-shell-% for single-execution of Haskell
> shelltests.
>
> Update documentation on running individual tests.
>
> Signed-off-by: Jose A. Lopes <[email protected]>
> ---
>  Makefile.am             | 20 +++++++++++++++++++-
>  doc/devnotes.rst        | 30 ++++++++++++++++++++++++------
>  test/hs/offline-test.sh | 13 +++++++++----
>  3 files changed, 52 insertions(+), 11 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index dd9dbd2..49cd09e 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -20,6 +20,9 @@ strip_hsroot = $(patsubst src/%,%,$(patsubst
> test/hs/%,%,$(1)))
>  # Use bash in order to be able to use pipefail
>  SHELL=/bin/bash
>
> +# Enable colors in shelltest
> +SHELLTESTARGS = "-c"
> +
>  ACLOCAL_AMFLAGS = -I autotools
>  BUILD_BASH_COMPLETION = $(top_srcdir)/autotools/build-bash-completion
>  RUN_IN_TEMPDIR = $(top_srcdir)/autotools/run-in-tempdir
> @@ -1827,15 +1830,30 @@ check-local: check-dirs $(GENERATED_FILES)
>         done; \
>         test -z "$$error"
>
> +.PHONY: hs-test-%
> +hs-test-%: test/hs/htest | $(BUILT_PYTHON_SOURCES)
> +       @rm -f htest.tix
> +       test/hs/htest -t $*
> +
>  .PHONY: hs-tests
>  hs-tests: test/hs/htest | $(BUILT_PYTHON_SOURCES)
>         @rm -f htest.tix
>         ./test/hs/htest
>
> +.PHONY: hs-shell-%
> +hs-shell-%: test/hs/hpc-htools test/hs/hpc-mon-collector \
> +            $(HS_BUILT_TEST_HELPERS)
> +       @rm -f hpc-htools.tix hpc-mon-collector.tix
> +       HBINARY="./test/hs/hpc-htools" \
> +       SHELLTESTARGS=$(SHELLTESTARGS) \
> +       ./test/hs/offline-test.sh $*
> +
>  .PHONY: hs-shell
>  hs-shell: test/hs/hpc-htools test/hs/hpc-mon-collector
> $(HS_BUILT_TEST_HELPERS)
>         @rm -f hpc-htools.tix hpc-mon-collector.tix
> -       HBINARY="./test/hs/hpc-htools" ./test/hs/offline-test.sh
> +       HBINARY="./test/hs/hpc-htools" \
> +       SHELLTESTARGS=$(SHELLTESTARGS) \
> +       ./test/hs/offline-test.sh
>
>  .PHONY: hs-check
>  hs-check: hs-tests hs-shell
> diff --git a/doc/devnotes.rst b/doc/devnotes.rst
> index 82bad09..1a12ac9 100644
> --- a/doc/devnotes.rst
> +++ b/doc/devnotes.rst
> @@ -24,7 +24,7 @@ Most dependencies from :doc:`install-quick`, including
> ``qemu-img``
>  - `pep8 <https://github.com/jcrocholl/pep8/>`_
>  - `PyYAML <http://pyyaml.org/>`_
>
> -For older developement (Ganeti < 2.4) ``docbook`` was used instead
> +For older developement (Ganeti < 2.4) ``docbook`` was used instead of
>  ``pandoc``.
>
>  Note that for pylint, at the current moment the following versions
> @@ -175,8 +175,8 @@ Running individual tests
>  ~~~~~~~~~~~~~~~~~~~~~~~~
>
>  When developing code, running the entire test suite can be
> -slow. Running individual tests is possible easily for unit-tests, less
> -so for shell-tests (but these are faster, so it shouldn't be needed).
> +slow. Running individual tests is possible. There are different
> +Makefile targets for running individual Python and Haskell tests.
>
>  For Python tests::
>
> @@ -185,15 +185,33 @@ For Python tests::
>
>  For Haskell tests::
>
> -  $ make test/hs/htest && ./test/hs/htest -t %pattern%
> +  $ make hs-test-%pattern%
>
>  Where ``pattern`` can be a simple test pattern (e.g. ``comma``,
>  matching any test whose name contains ``comma``), a test pattern
>  denoting a group (ending with a slash, e.g. ``Utils/``), or more
> -complex glob pattern. For more details, see the documentation (on the
> -`test-framework homepage
> +complex glob pattern. For more details, search for glob patterns in
> +the documentation of `test-framework
>  <http://batterseapower.github.com/test-framework/>`_).
>
> +For individual Haskell shelltests::
> +
> +  $ make hs-shell-%name%
> +
> +which runs the test ``test/hs/shelltests/htools-%name%.test``. For
> +example, to run the test ``test/hs/shelltests/htools-balancing.test``,
> +use::
> +
> +  $ make hs-shell-balancing
> +
> +For combined Haskell shelltests::
> +
> +  $ make hs-shell-{%name1%,%name2%,...}
> +
> +for example::
> +
> +  $ make hs-shell-{balancing,basic}
> +
>  Packaging notes
>  ===============
>
> diff --git a/test/hs/offline-test.sh b/test/hs/offline-test.sh
> index 07f002e..b3b5427 100755
> --- a/test/hs/offline-test.sh
> +++ b/test/hs/offline-test.sh
> @@ -20,6 +20,14 @@
>  # This is an offline testing script for most/all of the htools
>  # programs, checking basic command line functionality.
>
> +# Optional argument that specifies the test files to run. If not
> +# specified, then all tests are run.
> +#
> +# For example, a value of 'balancing' runs the file
> +# 'shelltests/htools-balancing.test'.  Multiple files can be specified
> +# using shell notation, for example, '{balancing,basic}'.
> +TESTS=${1:-*}
> +
>  set -e
>  set -o pipefail
>
> @@ -97,7 +105,4 @@ echo OK
>  echo Running shelltest...
>
>  shelltest $SHELLTESTARGS \
> -  ${TOP_SRCDIR:-.}/test/hs/shelltests/htools-*.test \
> -  -- --hide-successes
> -
> -echo All OK
> +  ${TOP_SRCDIR:-.}/test/hs/shelltests/htools-$TESTS.test
> \ No newline at end of file
> --
> 1.8.3
>
>
LGTM, thanks.

Michele

Reply via email to