Commit f0f3a6df authored by Iustin Pop's avatar Iustin Pop

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
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
../htools/htools.hs
\ No newline at end of file
htools.hs
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment