From ff28d3101470160b3273994f550c87bbd9d14f40 Mon Sep 17 00:00:00 2001
From: Ulrik Haugen <qha@lysator.liu.se>
Date: Mon, 13 Apr 2015 13:50:15 +0200
Subject: [PATCH] Makefile: support more complex module paths and document
 further possible values for fakeroot.

modulepath: new variable.

modules: expand in each component of modulepath.

remove old commented definition of rwildcard.

fakeroot: expand comments.

puppet-paths: use new modulepath variable.
---
 modules/Makefile | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/modules/Makefile b/modules/Makefile
index 1f10aac..6325a46 100755
--- a/modules/Makefile
+++ b/modules/Makefile
@@ -91,16 +91,18 @@
 # `make yourmodule/tests/yourclass.pp` and a test manifest with broken
 # dependencies will be produced for you to repair.
 
+# modulepath with colon separated module directories:
+modulepath := .
+
 # Recursive call to make all tests in a module will override this
 # variable:
-modules := $(patsubst %.,%,$(wildcard */.))
+modules := $(foreach moduledir,$(subst :, ,$(modulepath)),$(patsubst %.,%,$(wildcard $(moduledir)/*/.)))
 # Make modules available to the second/third pass make that builds
 # test-sub-stage-2:
 export modules
 
 # Recursive wildcard match (must be recursively expanded), syntax:
 # $(call rwildcard,_directory_,_wildcard_ [...])
-#rwildcard = $(foreach elem,$(wildcard $1/*),$(call rwildcard,$(elem),$2) $(filter $(subst *,%,$2),$(elem)))
 rwildcard = $(foreach elem,$(wildcard $1/*),$(call rwildcard,$(elem),$2)) $(wildcard $(addprefix $1/,$2))
 
 # Testfiles and dependent variables are recursively expanded so we
@@ -164,7 +166,11 @@ $(modules): clean
 osfamily := $(shell facter osfamily|tr A-Z a-z)
 
 # Possible values for fakeroot are: fakeroot, fakeroot-ng
-# (nonfunctional) and empty (noop).
+# (nonfunctional), empty (noop) and sudo.
+# Sudo will require a line like
+#  %puppet-devs ALL = (root) NOPASSWD: /usr/bin/puppet apply --noop *
+# in your sudoers configuration. Beware though that this will let all
+# members of puppet-devs trivially escalate their priviliges.
 # Set it to empty on Centos/Redhat and fakeroot elsewhere.
 fakeroot := $(if $(filter redhat,$(osfamily)),,fakeroot)
 
@@ -175,7 +181,7 @@ puppet-paths := --confdir smoke-testing-state/etc \
 	--vardir smoke-testing-state/var \
 	--ssldir smoke-testing-state/var/lib/puppet/ssl \
 	--rundir smoke-testing-state/var/run/puppet \
-	--modulepath .
+	--modulepath $(modulepath)
 
 
 # Expand testenvdefs with filters:
-- 
GitLab