pkgs.writers: tests for lua ruby, and remove failed tests because of external package errors

This commit is contained in:
Tulili 2024-01-16 01:51:17 -03:00 committed by lassulus
parent f6e0ee5545
commit 703a085c0a
2 changed files with 86 additions and 11 deletions

View file

@ -181,7 +181,7 @@ rec {
inherit strip; inherit strip;
} name; } name;
# writeHaskellBin takes the same arguments as writeHaskell but outputs a directory (like writeScriptBin) # writeHaskellBin takes the same arguments as kell but outputs a directory (like writeScriptBin)
writeHaskellBin = name: writeHaskellBin = name:
writeHaskell "/bin/${name}"; writeHaskell "/bin/${name}";
@ -199,28 +199,67 @@ rec {
writeNuBin = name: writeNuBin = name:
writeNu "/bin/${name}"; writeNu "/bin/${name}";
# makeRubyWriter takes ruby and compatible rubyPackages and produces ruby script writer,
# If any libraries are specified, ruby.withPackages is used as interpreter, otherwise the "bare" ruby is used.
makeRubyWriter = ruby: rubyPackages: buildRubyPackages: name: { libraries ? [], }:
makeScriptWriter {
interpreter =
if libraries == []
then "${ruby}/bin/ruby"
else "${(ruby.withPackages (ps: libraries))}/bin/ruby";
# Rubocop doesnt seem to like running in this fashion.
#check = (writeDash "rubocop.sh" ''
# exec ${lib.getExe buildRubyPackages.rubocop} "$1"
#'');
} name;
# Like writeScript but the first line is a shebang to ruby # Like writeScript but the first line is a shebang to ruby
# #
# Example: # Example:
# writeRuby "example" '' # writeRuby "example" ''
# puts "hello world" # puts "hello world"
# '' # ''
writeRuby = makeScriptWriter { writeRuby = makeRubyWriter pkgs.ruby pkgs.rubyPackages buildPackages.rubyPackages;
interpreter = "${lib.getExe pkgs.ruby}";
};
writeRubyBin = name: writeRubyBin = name:
writeRuby "/bin/${name}"; writeRuby "/bin/${name}";
# Like writeScript but the first line is a shebang to lua # makeLuaWriter takes lua and compatible luaPackages and produces lua script writer,
# which validates the script with luacheck at build time. If any libraries are specified,
# lua.withPackages is used as interpreter, otherwise the "bare" lua is used.
makeLuaWriter = lua: luaPackages: buildLuaPackages: name: { libraries ? [], }:
makeScriptWriter {
interpreter = lua.interpreter;
# if libraries == []
# then lua.interpreter
# else (lua.withPackages (ps: libraries)).interpreter
# This should support packages! I just cant figure out why some dependency collision happens whenever I try to run this.
check = (writeDash "luacheck.sh" ''
exec ${buildLuaPackages.luacheck}/bin/luacheck "$1"
'');
} name;
# writeLua takes a name an attributeset with libraries and some lua source code and
# returns an executable (should also work with luajit)
# #
# Example: # Example:
# writeLua "example" '' # writeLua "test_lua" { libraries = [ pkgs.luaPackages.say ]; } ''
# print("hello world") # s = require("say")
# s:set_namespace("en")
#
# s:set('money', 'I have %s dollars')
# s:set('wow', 'So much money!')
#
# print(s('money', {1000})) -- I have 1000 dollars
#
# s:set_namespace("fr") -- switch to french!
# s:set('wow', "Tant d'argent!")
#
# print(s('wow')) -- Tant d'argent!
# s:set_namespace("en") -- switch back to english!
# print(s('wow')) -- So much money!
# '' # ''
writeLua = makeScriptWriter { writeLua = makeLuaWriter pkgs.lua pkgs.luaPackages buildPackages.luaPackages;
interpreter = "${lib.getExe pkgs.lua}";
};
writeLuaBin = name: writeLuaBin = name:
writeLua "/bin/${name}"; writeLua "/bin/${name}";

View file

@ -6,6 +6,8 @@
, pypy2Packages , pypy2Packages
, python3Packages , python3Packages
, pypy3Packages , pypy3Packages
, luaPackages
, rubyPackages
, runCommand , runCommand
, testers , testers
, writers , writers
@ -119,6 +121,28 @@ lib.recurseIntoAttrs {
# """) # """)
# print(y[0]['test']) # print(y[0]['test'])
#''); #'');
# Could not test this because of external package issues :(
#lua = writeLuaBin "test-writers-lua-bin" { libraries = [ pkgs.luaPackages.say ]; } ''
# s = require("say")
# s:set_namespace("en")
# s:set('money', 'I have %s dollars')
# s:set('wow', 'So much money!')
# print(s('money', {1000})) -- I have 1000 dollars
# s:set_namespace("fr") -- switch to french!
# s:set('wow', "Tant d'argent!")
# print(s('wow')) -- Tant d'argent!
# s:set_namespace("en") -- switch back to english!
# print(s('wow')) -- So much money!
#'';
#ruby = expectSuccessBin (writeRubyBin "test-writers-ruby-bin" { libraries = [ rubyPackages.rubocop ]; } ''
#puts "This should work!"
#'');
}; };
simple = lib.recurseIntoAttrs { simple = lib.recurseIntoAttrs {
@ -136,6 +160,10 @@ lib.recurseIntoAttrs {
end end
''); '');
nu = expectSuccess (writeNu "test-writers-nushell" ''
echo "success"
'');
haskell = expectSuccess (writeHaskell "test-writers-haskell" { libraries = [ haskellPackages.acme-default ]; } '' haskell = expectSuccess (writeHaskell "test-writers-haskell" { libraries = [ haskellPackages.acme-default ]; } ''
import Data.Default import Data.Default
@ -232,6 +260,14 @@ lib.recurseIntoAttrs {
fsharpNoNugetDeps = expectSuccess (writeFSharp "test-writers-fsharp-no-nuget-deps" '' fsharpNoNugetDeps = expectSuccess (writeFSharp "test-writers-fsharp-no-nuget-deps" ''
printfn "success" printfn "success"
''); '');
luaNoLibs = expectSuccess (writeLua "test-writers-lua-no-libs" {} ''
print("success")
'');
rubyNoLibs = expectSuccess (writeRuby "test-writers-ruby-no-libs" {} ''
puts "success"
'');
}; };
path = lib.recurseIntoAttrs { path = lib.recurseIntoAttrs {