From 3096524ef803f6236d22c665d6ae45f62fb89999 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 20 Mar 2012 13:13:11 +0000
Subject: [PATCH] Build test helpers that point to hpc-htools
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Instead of using just shell constructs to run hpc-htools correctly
(i.e. HTOOLS=role htools/hpc-htools …), let's add some shell fragments
that do this for us.

This will ease the running of tests directly.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenΓ© Nussbaumer <rn@google.com>
---
 Makefile.am | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e9b126a3e..6ed02a6c3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -156,6 +156,7 @@ CLEANFILES = \
 	stamp-srclinks \
 	$(nodist_pkgpython_PYTHON) \
 	$(HS_ALL_PROGS) $(HS_BUILT_SRCS) \
+	$(HS_BUILT_TEST_HELPERS) \
 	.hpc/*.mix htools/*.tix \
 	doc/hs-lint.html
 
@@ -358,6 +359,8 @@ HS_BIN_ROLES = hbal hscan hspace hinfo
 
 HS_ALL_PROGS = $(HS_PROGS) htools/test htools/hpc-htools
 HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
+HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/%) test/hail
+
 # we don't add -Werror by default
 HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
 # extra flags that can be overriden on the command line
@@ -840,7 +843,7 @@ check_SCRIPTS =
 if WANT_HTOOLSTESTS
 nodist_TESTS += $(haskell_tests)
 dist_TESTS += htools/offline-test.sh
-check_SCRIPTS += htools/hpc-htools
+check_SCRIPTS += htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
 endif
 
 TESTS = $(dist_TESTS) $(nodist_TESTS)
@@ -1150,6 +1153,7 @@ daemons/ganeti-%: MODULE = ganeti.server.$(patsubst ganeti-%,%,$(notdir $@))
 daemons/ganeti-watcher: MODULE = ganeti.watcher
 scripts/%: MODULE = ganeti.client.$(subst -,_,$(notdir $@))
 tools/ensure-dirs: MODULE = ganeti.tools.ensure_dirs
+$(HS_BUILT_TEST_HELPERS): TESTROLE = $(patsubst test/%,%,$@)
 
 $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
 	test -n "$(MODULE)" || { echo Missing module; exit 1; }
@@ -1178,6 +1182,17 @@ $(PYTHON_BOOTSTRAP): Makefile | $(all_dirfiles)
 	} > $@
 	chmod u+x $@
 
+$(HS_BUILT_TEST_HELPERS): Makefile
+	@test -n "$(TESTROLE)" || { echo Missing TESTROLE; exit 1; }
+	set -e; \
+	{ echo '#!/bin/sh'; \
+	  echo '# This file is automatically generated, do not edit!'; \
+	  echo "# Edit Makefile.am instead."; \
+	  echo; \
+	  echo "HTOOLS=$(TESTROLE) exec ./htools/hpc-htools \"\$$@\""; \
+	} > $@
+	chmod u+x $@
+
 # We need to create symlinks because "make distcheck" will not install Python
 # files when building.
 stamp-srclinks: Makefile | $(all_dirfiles)
@@ -1237,7 +1252,7 @@ check-local: check-dirs $(BUILT_SOURCES)
 	done
 
 .PHONY: hs-check
-hs-check: htools/test htools/hpc-htools
+hs-check: htools/test htools/hpc-htools $(HS_BUILT_TEST_HELPERS)
 	@rm -f test.tix
 	./htools/test
 	HBINARY="./htools/hpc-htools" ./htools/offline-test.sh
-- 
GitLab