From f0f3a6df871c8cea9b8244ba596657ceb9234d62 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 29 Aug 2012 13:53:48 +0200 Subject: [PATCH] Move haskell test code to htest/ This is the first commit of a series that will attempt to cleanup the test code organisation, which evolved somewhat organically from the initial pure htools functionality. The proposed organisation of the tree will be as follows: - htools (or maybe renamed to haskell or hs): only production code - htest: top-level test directory, containing test.hs, static helper scripts, etc. - htest/Ganeti/*.hs: modules implementing the actual test properties and test cases for the correspondingly-named production code modules - htest/data: containing test data files for the test cases This particular patch moves all the test code (test.hs, hpc-htools.hs symlink) and helper scripts (offline-test.sh, etc.) from htools/ to htest/, while updating the files themselves (if they had paths mentioning htools/), .gitignore and the Makefile. The only special mention is that in Makefile, we used to have a BINARY shell variable in binary build rule; that was computed via stripping `htools/' prefix; I've cleaned that and replaced with $(notdir $@); even though it's duplicated a few times, it leads to more readable make output (and easier to copy-paste). Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Agata Murawska <agatamurawska@google.com> --- .gitignore | 7 ++-- Makefile.am | 50 ++++++++++++++--------------- autotools/run-in-tempdir | 15 ++++++--- {htools => htest}/cli-tests-defs.sh | 2 +- htest/hpc-htools.hs | 1 + {htools => htest}/live-test.sh | 0 {htools => htest}/offline-test.sh | 0 {htools => htest}/test.hs | 0 htools/hpc-htools.hs | 1 - 9 files changed, 43 insertions(+), 33 deletions(-) rename {htools => htest}/cli-tests-defs.sh (96%) create mode 120000 htest/hpc-htools.hs rename {htools => htest}/live-test.sh (100%) rename {htools => htest}/offline-test.sh (100%) rename {htools => htest}/test.hs (100%) delete mode 120000 htools/hpc-htools.hs diff --git a/.gitignore b/.gitignore index 70b94621a..e43fd5fa6 100644 --- a/.gitignore +++ b/.gitignore @@ -110,11 +110,14 @@ /htools/htools /htools/hconfd -/htools/hpc-htools -/htools/test +/htest/hpc-htools +/htest/test /htools/*.prof* /htools/*.stat /htools/*.tix +/htest/*.prof* +/htest/*.stat +/htest/*.tix /.hpc/ /*.tix diff --git a/Makefile.am b/Makefile.am index 61f2786d1..1cb17739a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -59,7 +59,8 @@ HTOOLS_DIRS = \ htools/Ganeti/Confd \ htools/Ganeti/HTools \ htools/Ganeti/HTools/Program \ - htools/Ganeti/Query + htools/Ganeti/Query \ + htest DIRS = \ autotools \ @@ -156,7 +157,7 @@ CLEANFILES = \ $(nodist_pkgpython_PYTHON) \ $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \ $(HS_BUILT_TEST_HELPERS) \ - .hpc/*.mix htools/*.tix \ + .hpc/*.mix htools/*.tix htest/*.tix \ doc/hs-lint.html GENERATED_FILES = \ @@ -358,14 +359,14 @@ docrst = \ HS_PROGS = htools/htools HS_BIN_ROLES = hbal hscan hspace hinfo hcheck -HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools htools/hconfd +HS_ALL_PROGS = $(HS_PROGS) htest/test htest/hpc-htools htools/hconfd HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools # extra flags that can be overriden on the command line (e.g. -Wwarn, etc.) HEXTRA = -# internal extra flags (used for htools/test mainly) +# internal extra flags (used for htest/test mainly) HEXTRA_INT = # exclude options for coverage reports HPCEXCL = --exclude Main \ @@ -546,27 +547,26 @@ $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile echo "Error: htools compilation disabled at configure time" 1>&2 ;\ exit 1; \ fi - @BINARY=$(@:htools/%=%); \ - if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \ + @if [ "$(notdir $@)" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \ echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \ exit 1; \ fi - rm -f $(@:htools/%=%).tix - BINARY=$(@:htools/%=%); $(GHC) --make \ + @rm -f $(notdir $@).tix + $(GHC) --make \ $(HFLAGS) \ $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \ - -osuf $$BINARY.o -hisuf $$BINARY.hi \ + -osuf $(notdir $@).o -hisuf $(notdir $@).hi \ $(HEXTRA) $(HEXTRA_INT) $@ @touch "$@" -# for the htools/test binary, we need to enable profiling/coverage -htools/test: HEXTRA_INT=-fhpc +# for the htest/test binary, we need to enable profiling/coverage +htest/test: HEXTRA_INT=-fhpc -ihtest # we compile the hpc-htools binary with the program coverage -htools/hpc-htools: HEXTRA_INT=-fhpc +htest/hpc-htools: HEXTRA_INT=-fhpc # test dependency -htools/offline-tests.sh: htools/hpc-htools +htest/offline-tests.sh: htest/hpc-htools # rules for building profiling-enabled versions of the haskell # programs: hs-prof does the full two-step build, whereas @@ -679,8 +679,8 @@ EXTRA_DIST = \ $(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \ $(HS_PROG_SRCS) \ htools/lint-hints.hs \ - htools/cli-tests-defs.sh \ - htools/offline-test.sh + htest/cli-tests-defs.sh \ + htest/offline-test.sh man_MANS = \ man/ganeti.7 \ @@ -871,7 +871,7 @@ if HAS_FAKEROOT python_tests += test/ganeti.utils.io_unittest-runasroot.py endif -haskell_tests = htools/test +haskell_tests = htest/test dist_TESTS = \ test/check-cert-expired_unittest.bash \ @@ -886,8 +886,8 @@ check_SCRIPTS = if WANT_HTOOLSTESTS nodist_TESTS += $(haskell_tests) -dist_TESTS += htools/offline-test.sh -check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS) +dist_TESTS += htest/offline-test.sh +check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS) endif TESTS = $(dist_TESTS) $(nodist_TESTS) @@ -931,8 +931,8 @@ srclink_files = \ test/ganeti-cleaner_unittest.bash \ test/import-export_unittest.bash \ test/cli-test.bash \ - htools/offline-test.sh \ - htools/cli-tests-defs.sh \ + htest/offline-test.sh \ + htest/cli-tests-defs.sh \ $(all_python_code) \ $(HS_LIB_SRCS) $(HS_PROG_SRCS) @@ -1248,7 +1248,7 @@ $(HS_BUILT_TEST_HELPERS): Makefile echo '# This file is automatically generated, do not edit!'; \ echo "# Edit Makefile.am instead."; \ echo; \ - echo "HTOOLS=$(TESTROLE) exec ./htools/hpc-htools \"\$$@\""; \ + echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \ } > $@ chmod u+x $@ @@ -1316,10 +1316,10 @@ check-local: check-dirs $(GENERATED_FILES) done .PHONY: hs-check -hs-check: htools/test htools/hpc-htools $(HS_BUILT_TEST_HELPERS) +hs-check: htest/test htest/hpc-htools $(HS_BUILT_TEST_HELPERS) @rm -f test.tix - ./htools/test - HBINARY="./htools/hpc-htools" ./htools/offline-test.sh + ./htest/test + HBINARY="./htest/hpc-htools" ./htest/offline-test.sh # E111: indentation is not a multiple of four # E121: continuation line indentation is not a multiple of four @@ -1522,7 +1522,7 @@ py-coverage: $(GENERATED_FILES) $(python_tests) $(python_tests) .PHONY: hs-coverage -hs-coverage: $(haskell_tests) htools/hpc-htools +hs-coverage: $(haskell_tests) htest/hpc-htools rm -f *.tix $(MAKE) $(AM_MAKEFLAGS) hs-check @mkdir_p@ $(COVERAGE_HS_DIR) diff --git a/autotools/run-in-tempdir b/autotools/run-in-tempdir index 316b54775..a1b2088a0 100755 --- a/autotools/run-in-tempdir +++ b/autotools/run-in-tempdir @@ -15,10 +15,17 @@ cp -r doc/examples $tmpdir/doc mv $tmpdir/lib $tmpdir/ganeti ln -T -s $tmpdir/ganeti $tmpdir/lib -mkdir -p $tmpdir/htools -for htest in htools hpc-htools test offline-test.sh cli-tests-defs.sh; do - if [ -e htools/$htest ]; then - cp -p htools/$htest $tmpdir/htools/ + +mkdir -p $tmpdir/htools $tmpdir/htest +for hfile in htools; do + if [ -e htools/$hfile ]; then + cp -p htools/$hfile $tmpdir/htools/ + fi +done + +for hfile in hpc-htools test offline-test.sh cli-tests-defs.sh; do + if [ -e htest/$hfile ]; then + cp -p htest/$hfile $tmpdir/htest/ fi done diff --git a/htools/cli-tests-defs.sh b/htest/cli-tests-defs.sh similarity index 96% rename from htools/cli-tests-defs.sh rename to htest/cli-tests-defs.sh index 59d78ce9b..7d305a1ad 100644 --- a/htools/cli-tests-defs.sh +++ b/htest/cli-tests-defs.sh @@ -19,7 +19,7 @@ # This is an shell testing configuration fragment. -HBINARY=${HBINARY:-./htools/hpc-htools} +HBINARY=${HBINARY:-./htest/hpc-htools} export TESTDATA_DIR=${TOP_SRCDIR:-.}/test/data/htools diff --git a/htest/hpc-htools.hs b/htest/hpc-htools.hs new file mode 120000 index 000000000..2d49067c1 --- /dev/null +++ b/htest/hpc-htools.hs @@ -0,0 +1 @@ +../htools/htools.hs \ No newline at end of file diff --git a/htools/live-test.sh b/htest/live-test.sh similarity index 100% rename from htools/live-test.sh rename to htest/live-test.sh diff --git a/htools/offline-test.sh b/htest/offline-test.sh similarity index 100% rename from htools/offline-test.sh rename to htest/offline-test.sh diff --git a/htools/test.hs b/htest/test.hs similarity index 100% rename from htools/test.hs rename to htest/test.hs diff --git a/htools/hpc-htools.hs b/htools/hpc-htools.hs deleted file mode 120000 index 487efdc27..000000000 --- a/htools/hpc-htools.hs +++ /dev/null @@ -1 +0,0 @@ -htools.hs \ No newline at end of file -- GitLab