Merge pull request #300905 from teto/teto/fix-lua-setup-hook

lua.tests.checkSetupHook: test lua setup hook for http package
This commit is contained in:
Florian Klink 2024-04-02 12:11:36 +02:00 committed by GitHub
commit f7ae598e45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

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

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}