about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/lua-5/tests/default.nix
blob: 38479af5f2070fdb284bc3fcbdd8e6c6efcea3a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ lua
, hello
, wrapLua
, lib, fetchFromGitHub
, fetchFromGitLab
, pkgs
}:
let

  runTest = lua: { name, command }:
    pkgs.runCommandLocal "test-${lua.name}" ({
      nativeBuildInputs = [lua];
      meta.platforms = lua.meta.platforms;
    }) (''
      source ${./assert.sh}
    ''
    + command
    + "touch $out"
    );

    wrappedHello = hello.overrideAttrs(oa: {
      propagatedBuildInputs = [
        wrapLua
        lua.pkgs.cjson
      ];
      postFixup = ''
        wrapLuaPrograms
      '';
    });
in
  pkgs.recurseIntoAttrs ({

  checkAliases = runTest lua {
    name = "check-aliases";
    command = ''
      generated=$(lua -e 'print(package.path)')
      golden_LUA_PATH='./share/lua/${lua.luaversion}/?.lua;./?.lua;./?/init.lua'

      assertStringEqual "$generated" "$golden_LUA_PATH"
      '';
  };

  checkWrapping = pkgs.runCommandLocal "test-${lua.name}" ({
    }) (''
      grep -- 'LUA_PATH=' ${wrappedHello}/bin/hello
      touch $out
    '');

})