about summary refs log tree commit diff
path: root/pkgs/development/interpreters/lua-5
diff options
context:
space:
mode:
authorMatthieu Coudron <886074+teto@users.noreply.github.com>2024-04-02 10:44:34 +0200
committerMatthieu Coudron <886074+teto@users.noreply.github.com>2024-04-02 11:20:36 +0200
commitb8be0164260e61c1859d12b5d973c0f3f67d379c (patch)
tree56ed1e5753f773aec7f83c1699b948933091babb /pkgs/development/interpreters/lua-5
parentcb1f3bcd8b88bc71906f66ba4edec11d81c9567b (diff)
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.
Diffstat (limited to 'pkgs/development/interpreters/lua-5')
-rw-r--r--pkgs/development/interpreters/lua-5/hooks/setup-hook.sh1
-rw-r--r--pkgs/development/interpreters/lua-5/tests/default.nix15
2 files changed, 16 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh b/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
index 3041b7f1c3f71..cbc7b7b53e9b1 100644
--- a/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
+++ b/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
@@ -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
diff --git a/pkgs/development/interpreters/lua-5/tests/default.nix b/pkgs/development/interpreters/lua-5/tests/default.nix
index 6ca6b153c0b62..c95d11aefc967 100644
--- a/pkgs/development/interpreters/lua-5/tests/default.nix
+++ b/pkgs/development/interpreters/lua-5/tests/default.nix
@@ -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}