mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 07:13:23 +01:00
Current round of tests pass, but filter function is failing to include when groups match in use.
This commit is contained in:
parent
66fed6d28f
commit
0145ec999c
6 changed files with 77 additions and 33 deletions
24
pkgs/development/ruby-modules/bundler-env/assertions.nix
Normal file
24
pkgs/development/ruby-modules/bundler-env/assertions.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ test, lib, ...}:
|
||||
{
|
||||
equal = expected: actual:
|
||||
if actual == expected then
|
||||
(test.passed "= ${toString expected}") else
|
||||
(test.failed "'${toString actual}'(${builtins.typeOf actual}) != '${toString expected}'(${builtins.typeOf expected})");
|
||||
|
||||
beASet = actual:
|
||||
if builtins.isAttrs actual then
|
||||
(test.passed "is a set") else
|
||||
(test.failed "is not a set, was ${builtins.typeOf actual}: ${toString actual}");
|
||||
|
||||
haveKeys = expected: actual:
|
||||
if builtins.all
|
||||
(ex: builtins.any (ac: ex == ac) (builtins.attrNames actual))
|
||||
expected then
|
||||
(test.passed "has expected keys") else
|
||||
(test.failed "keys differ: expected [${lib.concatStringsSep ";" expected}] have [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
|
||||
|
||||
havePrefix = expected: actual:
|
||||
if lib.hasPrefix expected actual then
|
||||
(test.passed "has prefix '${expected}'") else
|
||||
(test.failed "prefix '${expected}' not found in '${actual}'");
|
||||
}
|
|
@ -20,7 +20,9 @@
|
|||
, ...
|
||||
}@args:
|
||||
|
||||
with (import ./functions.nix { inherit lib ruby gemConfig groups; });
|
||||
with (
|
||||
builtins.trace "basic functions"
|
||||
import ./functions.nix { inherit lib ruby gemConfig groups; });
|
||||
|
||||
let
|
||||
|
||||
|
@ -69,7 +71,8 @@ let
|
|||
if gemAttrs.type == "path" then
|
||||
pathDerivation gemAttrs
|
||||
else
|
||||
buildRubyGem gemAttrs
|
||||
builtins.trace (lib.showVal (gemAttrs.ruby or "def ruby"))
|
||||
buildRubyGem gemAttrs
|
||||
);
|
||||
|
||||
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ lib, ruby, groups, gemConfig, ... }:
|
||||
builtins.trace (if ruby.stubbed or false then "functions has stubbed ruby" else "functions has live ruby")
|
||||
rec {
|
||||
filterGemset = gemset: lib.filterAttrs (name: attrs: platformMatches attrs && groupMatches attrs) gemset;
|
||||
|
||||
|
@ -44,7 +45,7 @@ rec {
|
|||
};
|
||||
in res;
|
||||
|
||||
composeGemAttrs = gems: name: attrs: ((removeAttrs attrs ["source"]) // attrs.source // {
|
||||
composeGemAttrs = gems: name: attrs: ((removeAttrs attrs ["source" "platforms"]) // attrs.source // {
|
||||
inherit ruby;
|
||||
gemName = name;
|
||||
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
|
||||
|
|
33
pkgs/development/ruby-modules/bundler-env/stubs.nix
Normal file
33
pkgs/development/ruby-modules/bundler-env/stubs.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{ stdenv, lib, ruby, callPackage, ... }:
|
||||
let
|
||||
real = {
|
||||
inherit (stdenv) mkDerivation;
|
||||
};
|
||||
mkDerivation = {name, ...}@argSet:
|
||||
derivation {
|
||||
inherit name;
|
||||
text = (builtins.toJSON (lib.filterAttrs ( n: v: builtins.any (x: x == n) ["name" "system"]) argSet));
|
||||
builder = stdenv.shell;
|
||||
args = [ "-c" "echo $(<$textPath) > $out"];
|
||||
system = stdenv.system;
|
||||
passAsFile = ["text"];
|
||||
};
|
||||
fetchurl = {url?"", urls ? [],...}: "fetchurl:${if urls == [] then url else builtins.head urls}";
|
||||
|
||||
stdenv' = stdenv // {
|
||||
inherit mkDerivation;
|
||||
stubbed = true;
|
||||
};
|
||||
ruby' = ruby // {
|
||||
stdenv = stdenv';
|
||||
stubbed = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
ruby = ruby';
|
||||
buildRubyGem = callPackage ../gem {
|
||||
inherit fetchurl;
|
||||
ruby = ruby';
|
||||
};
|
||||
stdenv = stdenv';
|
||||
}
|
|
@ -5,44 +5,24 @@ nix-build -E 'with import <nixpkgs> { }; callPackage ./test.nix {}' --show-trace
|
|||
Confusingly, the ideal result ends with something like:
|
||||
error: build of ‘/nix/store/3245f3dcl2wxjs4rci7n069zjlz8qg85-test-results.tap.drv’ failed
|
||||
*/
|
||||
{ writeText, lib, ruby, defaultGemConfig, callPackage }:
|
||||
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage }@defs:
|
||||
let
|
||||
test = import ./testing.nix;
|
||||
tap = import ./tap-support.nix;
|
||||
stubs = import ./stubs.nix defs;
|
||||
should = import ./assertions.nix { inherit test lib; };
|
||||
|
||||
bundlerEnv = callPackage ./default.nix {};
|
||||
basicEnv = callPackage ./basic.nix {};
|
||||
basicEnv = callPackage ./basic.nix stubs;
|
||||
bundlerEnv = callPackage ./default.nix stubs // {
|
||||
inherit basicEnv;
|
||||
};
|
||||
|
||||
testConfigs = {
|
||||
groups = ["default"];
|
||||
gemConfig = defaultGemConfig;
|
||||
confFiles = "./testConfs";
|
||||
};
|
||||
functions = (import ./functions.nix ({ inherit lib ruby; } // testConfigs));
|
||||
|
||||
should = {
|
||||
equal = expected: actual:
|
||||
if actual == expected then
|
||||
(test.passed "= ${toString expected}") else
|
||||
(test.failed "'${toString actual}'(${builtins.typeOf actual}) != '${toString expected}'(${builtins.typeOf expected})");
|
||||
|
||||
beASet = actual:
|
||||
if builtins.isAttrs actual then
|
||||
(test.passed "is a set") else
|
||||
(test.failed "is not a set, was ${builtins.typeOf actual}: ${toString actual}");
|
||||
|
||||
haveKeys = expected: actual:
|
||||
if builtins.all
|
||||
(ex: builtins.any (ac: ex == ac) (builtins.attrNames actual))
|
||||
expected then
|
||||
(test.passed "has expected keys") else
|
||||
(test.failed "keys differ: expected [${lib.concatStringsSep ";" expected}] have [${lib.concatStringsSep ";" (builtins.attrNames actual)}]");
|
||||
|
||||
havePrefix = expected: actual:
|
||||
if lib.hasPrefix expected actual then
|
||||
(test.passed "has prefix '${expected}'") else
|
||||
(test.failed "prefix '${expected}' not found in '${actual}'");
|
||||
};
|
||||
functions = (import ./functions.nix ({ inherit lib; ruby = stubs.ruby; } // testConfigs));
|
||||
|
||||
justName = bundlerEnv {
|
||||
name = "test";
|
||||
|
@ -66,9 +46,9 @@ let
|
|||
[
|
||||
(should.haveKeys [ "name" "env" "postBuild" ])
|
||||
{
|
||||
name = should.equal "test-0.1.2";
|
||||
name = should.equal "test";
|
||||
env = should.beASet;
|
||||
postBuild = should.havePrefix "nananana";
|
||||
postBuild = should.havePrefix "/nix/store";
|
||||
}
|
||||
])
|
||||
];
|
||||
|
|
|
@ -74,6 +74,8 @@ let
|
|||
|
||||
in
|
||||
|
||||
builtins.trace (gemName)
|
||||
builtins.trace (stdenv.stubbed or false)
|
||||
stdenv.mkDerivation (attrs // {
|
||||
inherit ruby;
|
||||
inherit doCheck;
|
||||
|
@ -87,6 +89,7 @@ stdenv.mkDerivation (attrs // {
|
|||
++ lib.optional stdenv.isDarwin darwin.libobjc
|
||||
++ buildInputs;
|
||||
|
||||
#name = builtins.trace (attrs.name or "no attr.name" ) "${namePrefix}${gemName}-${version}";
|
||||
name = attrs.name or "${namePrefix}${gemName}-${version}";
|
||||
|
||||
inherit src;
|
||||
|
|
Loading…
Reference in a new issue