mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-28 00:24:18 +00:00
c4b5c2574b
Test with: nix-build -A lua.tests pass Tests are very limited for now, goal is mostly to put the infra into place and enrich the tests when dealing with lua issues. add luaPath/luaCpath as passthrough makes it easier to generate LUA_PATH/LUA_CPATH
51 lines
978 B
Nix
51 lines
978 B
Nix
{ 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
|
|
'');
|
|
|
|
})
|
|
|