Skip to content
Snippets Groups Projects
Commit f0f3a6df authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 01606931
No related branches found
No related tags found
No related merge requests found
...@@ -110,11 +110,14 @@ ...@@ -110,11 +110,14 @@
/htools/htools /htools/htools
/htools/hconfd /htools/hconfd
/htools/hpc-htools /htest/hpc-htools
/htools/test /htest/test
/htools/*.prof* /htools/*.prof*
/htools/*.stat /htools/*.stat
/htools/*.tix /htools/*.tix
/htest/*.prof*
/htest/*.stat
/htest/*.tix
/.hpc/ /.hpc/
/*.tix /*.tix
......
...@@ -59,7 +59,8 @@ HTOOLS_DIRS = \ ...@@ -59,7 +59,8 @@ HTOOLS_DIRS = \
htools/Ganeti/Confd \ htools/Ganeti/Confd \
htools/Ganeti/HTools \ htools/Ganeti/HTools \
htools/Ganeti/HTools/Program \ htools/Ganeti/HTools/Program \
htools/Ganeti/Query htools/Ganeti/Query \
htest
DIRS = \ DIRS = \
autotools \ autotools \
...@@ -156,7 +157,7 @@ CLEANFILES = \ ...@@ -156,7 +157,7 @@ CLEANFILES = \
$(nodist_pkgpython_PYTHON) \ $(nodist_pkgpython_PYTHON) \
$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \ $(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
$(HS_BUILT_TEST_HELPERS) \ $(HS_BUILT_TEST_HELPERS) \
.hpc/*.mix htools/*.tix \ .hpc/*.mix htools/*.tix htest/*.tix \
doc/hs-lint.html doc/hs-lint.html
GENERATED_FILES = \ GENERATED_FILES = \
...@@ -358,14 +359,14 @@ docrst = \ ...@@ -358,14 +359,14 @@ docrst = \
HS_PROGS = htools/htools HS_PROGS = htools/htools
HS_BIN_ROLES = hbal hscan hspace hinfo hcheck 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_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools HFLAGS = -O -Wall -Werror -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.) # extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
HEXTRA = HEXTRA =
# internal extra flags (used for htools/test mainly) # internal extra flags (used for htest/test mainly)
HEXTRA_INT = HEXTRA_INT =
# exclude options for coverage reports # exclude options for coverage reports
HPCEXCL = --exclude Main \ HPCEXCL = --exclude Main \
...@@ -546,27 +547,26 @@ $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile ...@@ -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 ;\ echo "Error: htools compilation disabled at configure time" 1>&2 ;\
exit 1; \ exit 1; \
fi fi
@BINARY=$(@:htools/%=%); \ @if [ "$(notdir $@)" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
if [ "$BINARY" = "test" ] && [ -z "$(GHC_PKG_QUICKCHECK)" ]; then \
echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \ echo "Error: cannot run unittests without the QuickCheck library (see devnotes.rst)" 1>&2; \
exit 1; \ exit 1; \
fi fi
rm -f $(@:htools/%=%).tix @rm -f $(notdir $@).tix
BINARY=$(@:htools/%=%); $(GHC) --make \ $(GHC) --make \
$(HFLAGS) \ $(HFLAGS) \
$(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \ $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
-osuf $$BINARY.o -hisuf $$BINARY.hi \ -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
$(HEXTRA) $(HEXTRA_INT) $@ $(HEXTRA) $(HEXTRA_INT) $@
@touch "$@" @touch "$@"
# for the htools/test binary, we need to enable profiling/coverage # for the htest/test binary, we need to enable profiling/coverage
htools/test: HEXTRA_INT=-fhpc htest/test: HEXTRA_INT=-fhpc -ihtest
# we compile the hpc-htools binary with the program coverage # we compile the hpc-htools binary with the program coverage
htools/hpc-htools: HEXTRA_INT=-fhpc htest/hpc-htools: HEXTRA_INT=-fhpc
# test dependency # 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 # rules for building profiling-enabled versions of the haskell
# programs: hs-prof does the full two-step build, whereas # programs: hs-prof does the full two-step build, whereas
...@@ -679,8 +679,8 @@ EXTRA_DIST = \ ...@@ -679,8 +679,8 @@ EXTRA_DIST = \
$(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \ $(HS_LIB_SRCS) $(HS_BUILT_SRCS_IN) \
$(HS_PROG_SRCS) \ $(HS_PROG_SRCS) \
htools/lint-hints.hs \ htools/lint-hints.hs \
htools/cli-tests-defs.sh \ htest/cli-tests-defs.sh \
htools/offline-test.sh htest/offline-test.sh
man_MANS = \ man_MANS = \
man/ganeti.7 \ man/ganeti.7 \
...@@ -871,7 +871,7 @@ if HAS_FAKEROOT ...@@ -871,7 +871,7 @@ if HAS_FAKEROOT
python_tests += test/ganeti.utils.io_unittest-runasroot.py python_tests += test/ganeti.utils.io_unittest-runasroot.py
endif endif
haskell_tests = htools/test haskell_tests = htest/test
dist_TESTS = \ dist_TESTS = \
test/check-cert-expired_unittest.bash \ test/check-cert-expired_unittest.bash \
...@@ -886,8 +886,8 @@ check_SCRIPTS = ...@@ -886,8 +886,8 @@ check_SCRIPTS =
if WANT_HTOOLSTESTS if WANT_HTOOLSTESTS
nodist_TESTS += $(haskell_tests) nodist_TESTS += $(haskell_tests)
dist_TESTS += htools/offline-test.sh dist_TESTS += htest/offline-test.sh
check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS) check_SCRIPTS += htest/hpc-htools $(HS_BUILT_TEST_HELPERS)
endif endif
TESTS = $(dist_TESTS) $(nodist_TESTS) TESTS = $(dist_TESTS) $(nodist_TESTS)
...@@ -931,8 +931,8 @@ srclink_files = \ ...@@ -931,8 +931,8 @@ srclink_files = \
test/ganeti-cleaner_unittest.bash \ test/ganeti-cleaner_unittest.bash \
test/import-export_unittest.bash \ test/import-export_unittest.bash \
test/cli-test.bash \ test/cli-test.bash \
htools/offline-test.sh \ htest/offline-test.sh \
htools/cli-tests-defs.sh \ htest/cli-tests-defs.sh \
$(all_python_code) \ $(all_python_code) \
$(HS_LIB_SRCS) $(HS_PROG_SRCS) $(HS_LIB_SRCS) $(HS_PROG_SRCS)
...@@ -1248,7 +1248,7 @@ $(HS_BUILT_TEST_HELPERS): Makefile ...@@ -1248,7 +1248,7 @@ $(HS_BUILT_TEST_HELPERS): Makefile
echo '# This file is automatically generated, do not edit!'; \ echo '# This file is automatically generated, do not edit!'; \
echo "# Edit Makefile.am instead."; \ echo "# Edit Makefile.am instead."; \
echo; \ echo; \
echo "HTOOLS=$(TESTROLE) exec ./htools/hpc-htools \"\$$@\""; \ echo "HTOOLS=$(TESTROLE) exec ./htest/hpc-htools \"\$$@\""; \
} > $@ } > $@
chmod u+x $@ chmod u+x $@
...@@ -1316,10 +1316,10 @@ check-local: check-dirs $(GENERATED_FILES) ...@@ -1316,10 +1316,10 @@ check-local: check-dirs $(GENERATED_FILES)
done done
.PHONY: hs-check .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 @rm -f test.tix
./htools/test ./htest/test
HBINARY="./htools/hpc-htools" ./htools/offline-test.sh HBINARY="./htest/hpc-htools" ./htest/offline-test.sh
# E111: indentation is not a multiple of four # E111: indentation is not a multiple of four
# E121: continuation line 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) ...@@ -1522,7 +1522,7 @@ py-coverage: $(GENERATED_FILES) $(python_tests)
$(python_tests) $(python_tests)
.PHONY: hs-coverage .PHONY: hs-coverage
hs-coverage: $(haskell_tests) htools/hpc-htools hs-coverage: $(haskell_tests) htest/hpc-htools
rm -f *.tix rm -f *.tix
$(MAKE) $(AM_MAKEFLAGS) hs-check $(MAKE) $(AM_MAKEFLAGS) hs-check
@mkdir_p@ $(COVERAGE_HS_DIR) @mkdir_p@ $(COVERAGE_HS_DIR)
......
...@@ -15,10 +15,17 @@ cp -r doc/examples $tmpdir/doc ...@@ -15,10 +15,17 @@ cp -r doc/examples $tmpdir/doc
mv $tmpdir/lib $tmpdir/ganeti mv $tmpdir/lib $tmpdir/ganeti
ln -T -s $tmpdir/ganeti $tmpdir/lib 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 mkdir -p $tmpdir/htools $tmpdir/htest
if [ -e htools/$htest ]; then for hfile in htools; do
cp -p htools/$htest $tmpdir/htools/ 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 fi
done done
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
# This is an shell testing configuration fragment. # 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 export TESTDATA_DIR=${TOP_SRCDIR:-.}/test/data/htools
......
../htools/htools.hs
\ No newline at end of file
File moved
File moved
File moved
htools.hs
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment