2019-05-18 17:45:38 +00:00
|
|
|
# a generic test suite for all gems for all ruby versions.
|
|
|
|
# use via nix-build.
|
|
|
|
let
|
|
|
|
pkgs = import ../../../.. {};
|
|
|
|
lib = pkgs.lib;
|
|
|
|
stdenv = pkgs.stdenv;
|
|
|
|
|
|
|
|
rubyVersions = with pkgs; [
|
|
|
|
ruby_2_6
|
2020-01-01 00:25:35 +00:00
|
|
|
ruby_2_7
|
2019-05-18 17:45:38 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
gemTests =
|
|
|
|
(lib.mapAttrs
|
|
|
|
(name: gem: [ name ])
|
|
|
|
pkgs.ruby.gems) //
|
|
|
|
(import ./require_exceptions.nix);
|
|
|
|
|
|
|
|
tests = ruby:
|
|
|
|
lib.mapAttrs (name: gem:
|
|
|
|
let
|
|
|
|
test =
|
2019-09-08 23:38:31 +00:00
|
|
|
if builtins.isList gemTests.${name}
|
2019-05-18 17:45:38 +00:00
|
|
|
then pkgs.writeText "${name}.rb" ''
|
|
|
|
puts "${name} GEM_HOME: #{ENV['GEM_HOME']}"
|
2019-09-08 23:38:31 +00:00
|
|
|
${lib.concatStringsSep "\n" (map (n: "require '${n}'") gemTests.${name})}
|
2019-05-18 17:45:38 +00:00
|
|
|
''
|
2019-09-08 23:38:31 +00:00
|
|
|
else pkgs.writeText "${name}.rb" gemTests.${name};
|
2019-05-18 17:45:38 +00:00
|
|
|
|
2019-09-08 23:38:31 +00:00
|
|
|
deps = ruby.withPackages (g: [ g.${name} ]);
|
2019-05-18 17:45:38 +00:00
|
|
|
in stdenv.mkDerivation {
|
|
|
|
name = "test-gem-${ruby.name}-${name}";
|
|
|
|
buildInputs = [ deps ];
|
|
|
|
buildCommand = ''
|
|
|
|
INLINEDIR=$PWD ruby ${test}
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
) ruby.gems;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "test-all-ruby-gems";
|
|
|
|
buildInputs = builtins.foldl' (sum: ruby: sum ++ ( builtins.attrValues (tests ruby) )) [] rubyVersions;
|
|
|
|
buildCommand = ''
|
|
|
|
touch $out
|
|
|
|
'';
|
|
|
|
}
|