lua.tests.checkSetupHook: test lua setup hook for http package

the 'http' package is an interesting one to test because all its lua
files are in a 'http' subfolder, ie., there is no share/lua/5.1/*.lua,
only share/lua/5.1/http/*.lua files unlike most packages. This tests we
can match those subfolders.
This commit is contained in:
Matthieu Coudron 2024-04-02 10:44:34 +02:00
parent cb1f3bcd8b
commit b8be016426
2 changed files with 16 additions and 0 deletions

View File

@ -25,6 +25,7 @@ addToLuaSearchPathWithCustomDelimiter() {
# export only if the folder contains lua files
shopt -s globstar
for _file in ${absPattern/\?/\*\*}; do
export "${varName}=${!varName:+${!varName};}${absPattern}"
shopt -u globstar

View File

@ -66,6 +66,21 @@ in
touch $out
'');
# checks that lua's setup-hook adds dependencies to LUA_PATH
# Prevents the following regressions
# $ env NIX_PATH=nixpkgs=. nix-shell --pure -Q -p luajitPackages.lua luajitPackages.http
# nix-shell$ luajit
# > require('http.request')
# stdin:1: module 'http.request' not found:
checkSetupHook = pkgs.runCommandLocal "test-${lua.name}-setup-hook" ({
nativeBuildInputs = [lua];
buildInputs = [ lua.pkgs.http ];
meta.platforms = lua.meta.platforms;
}) (''
${lua}/bin/lua -e "require'http.request'"
touch $out
'');
checkRelativeImports = pkgs.runCommandLocal "test-${lua.name}-relative-imports" ({
}) (''
source ${./assert.sh}