diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-07-01 11:16:53 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-07-01 11:16:53 +0100 |
commit | 1f9144c6b95cb8c949a98842dc8d9df64ba94863 (patch) | |
tree | 0b426e321867dde68787ef5c06cbcf45982deeac | |
parent | 1b31bd6c23e4335fff859e1a82acbf97c2b0929f (diff) | |
download | gall-1f9144c6b95cb8c949a98842dc8d9df64ba94863.tar.gz |
Blacklist system git2 modules while running tests
In order to run the tests safely, particularly if
the git2 C module isn't built due to a missing dep
we need to blacklist any system git2 module. This
change also requires lua5.2 for the test suite.
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | blacklist-system-git2 | 21 | ||||
-rw-r--r-- | find-git2 | 17 |
3 files changed, 40 insertions, 2 deletions
@@ -2,7 +2,7 @@ all: test MODULES := gall gall.util gall.ll \ gall.repository gall.object gall.commit gall.tag gall.tree -LUA_VER := 5.1 +LUA_VER := 5.2 PREFIX ?= /usr/local @@ -35,7 +35,7 @@ install: cmodule fi -LUA := LUA_CPATH="$(shell pwd)/lib/?.so;;" LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" lua$(LUA_VER) +LUA := LUA_CPATH="$(shell pwd)/lib/?.so;;" LUA_PATH="$(shell pwd)/lib/?.lua;$(shell pwd)/extras/luacov/src/?.lua;;" __GALL_LL_GIT2_BLACKLIST="$(shell lua$(LUA_VER) find-git2)" lua$(LUA_VER) -e "dofile('blacklist-system-git2')" cmodule: try-cmodule diff --git a/blacklist-system-git2 b/blacklist-system-git2 new file mode 100644 index 0000000..92d266c --- /dev/null +++ b/blacklist-system-git2 @@ -0,0 +1,21 @@ +-- -*- Lua -*- + +-- Our purpose is to blacklist the git2 module(s) found on the package +-- search path. We do that by loading an environment variable and then +-- wrappering the third searcher as necessary. + +function __gall_ll_git2_blacklister(f, ignoreme) + local type = type + local function replacement(modname) + local fret, fname = f(modname) + if type(fret) == "function" and fname == ignoreme then + return nil, "Blacklisted " .. fname .. "\n" + end + return fret, fname + end + return replacement +end + +for fname in (os.getenv("__GALL_LL_GIT2_BLACKLIST") or ""):gmatch("([^:]+)") do + package.searchers[3] = __gall_ll_git2_blacklister(package.searchers[3], fname) +end diff --git a/find-git2 b/find-git2 new file mode 100644 index 0000000..6bdca05 --- /dev/null +++ b/find-git2 @@ -0,0 +1,17 @@ +-- -*- Lua -*- + +-- Our goal is to find git2.so so we can blacklist it for the duration of +-- tests. This is done by essentially rummaging in the package loaders... + +dofile("blacklist-system-git2") + +local ffunc, loc = package.searchers[3]('gall.ll.git2') + +local locs = {} +while ffunc ~= nil do + locs[#locs+1] = loc + package.searchers[3] = __gall_ll_git2_blacklister(package.searchers[3], loc) + ffunc, loc = package.searchers[3]('gall.ll.git2') +end + +print(table.concat(locs, ":")) |