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
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:
|
}@args:
|
||||||
|
|
||||||
with (import ./functions.nix { inherit lib ruby gemConfig groups; });
|
with (
|
||||||
|
builtins.trace "basic functions"
|
||||||
|
import ./functions.nix { inherit lib ruby gemConfig groups; });
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
@ -69,6 +71,7 @@ let
|
|||||||
if gemAttrs.type == "path" then
|
if gemAttrs.type == "path" then
|
||||||
pathDerivation gemAttrs
|
pathDerivation gemAttrs
|
||||||
else
|
else
|
||||||
|
builtins.trace (lib.showVal (gemAttrs.ruby or "def ruby"))
|
||||||
buildRubyGem gemAttrs
|
buildRubyGem gemAttrs
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{ lib, ruby, groups, gemConfig, ... }:
|
{ lib, ruby, groups, gemConfig, ... }:
|
||||||
|
builtins.trace (if ruby.stubbed or false then "functions has stubbed ruby" else "functions has live ruby")
|
||||||
rec {
|
rec {
|
||||||
filterGemset = gemset: lib.filterAttrs (name: attrs: platformMatches attrs && groupMatches attrs) gemset;
|
filterGemset = gemset: lib.filterAttrs (name: attrs: platformMatches attrs && groupMatches attrs) gemset;
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ rec {
|
|||||||
};
|
};
|
||||||
in res;
|
in res;
|
||||||
|
|
||||||
composeGemAttrs = gems: name: attrs: ((removeAttrs attrs ["source"]) // attrs.source // {
|
composeGemAttrs = gems: name: attrs: ((removeAttrs attrs ["source" "platforms"]) // attrs.source // {
|
||||||
inherit ruby;
|
inherit ruby;
|
||||||
gemName = name;
|
gemName = name;
|
||||||
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
|
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:
|
Confusingly, the ideal result ends with something like:
|
||||||
error: build of ‘/nix/store/3245f3dcl2wxjs4rci7n069zjlz8qg85-test-results.tap.drv’ failed
|
error: build of ‘/nix/store/3245f3dcl2wxjs4rci7n069zjlz8qg85-test-results.tap.drv’ failed
|
||||||
*/
|
*/
|
||||||
{ writeText, lib, ruby, defaultGemConfig, callPackage }:
|
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage }@defs:
|
||||||
let
|
let
|
||||||
test = import ./testing.nix;
|
test = import ./testing.nix;
|
||||||
tap = import ./tap-support.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 stubs;
|
||||||
basicEnv = callPackage ./basic.nix {};
|
bundlerEnv = callPackage ./default.nix stubs // {
|
||||||
|
inherit basicEnv;
|
||||||
|
};
|
||||||
|
|
||||||
testConfigs = {
|
testConfigs = {
|
||||||
groups = ["default"];
|
groups = ["default"];
|
||||||
gemConfig = defaultGemConfig;
|
gemConfig = defaultGemConfig;
|
||||||
confFiles = "./testConfs";
|
confFiles = "./testConfs";
|
||||||
};
|
};
|
||||||
functions = (import ./functions.nix ({ inherit lib ruby; } // testConfigs));
|
functions = (import ./functions.nix ({ inherit lib; ruby = stubs.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}'");
|
|
||||||
};
|
|
||||||
|
|
||||||
justName = bundlerEnv {
|
justName = bundlerEnv {
|
||||||
name = "test";
|
name = "test";
|
||||||
@ -66,9 +46,9 @@ let
|
|||||||
[
|
[
|
||||||
(should.haveKeys [ "name" "env" "postBuild" ])
|
(should.haveKeys [ "name" "env" "postBuild" ])
|
||||||
{
|
{
|
||||||
name = should.equal "test-0.1.2";
|
name = should.equal "test";
|
||||||
env = should.beASet;
|
env = should.beASet;
|
||||||
postBuild = should.havePrefix "nananana";
|
postBuild = should.havePrefix "/nix/store";
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
];
|
];
|
||||||
|
@ -74,6 +74,8 @@ let
|
|||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
|
builtins.trace (gemName)
|
||||||
|
builtins.trace (stdenv.stubbed or false)
|
||||||
stdenv.mkDerivation (attrs // {
|
stdenv.mkDerivation (attrs // {
|
||||||
inherit ruby;
|
inherit ruby;
|
||||||
inherit doCheck;
|
inherit doCheck;
|
||||||
@ -87,6 +89,7 @@ stdenv.mkDerivation (attrs // {
|
|||||||
++ lib.optional stdenv.isDarwin darwin.libobjc
|
++ lib.optional stdenv.isDarwin darwin.libobjc
|
||||||
++ buildInputs;
|
++ buildInputs;
|
||||||
|
|
||||||
|
#name = builtins.trace (attrs.name or "no attr.name" ) "${namePrefix}${gemName}-${version}";
|
||||||
name = attrs.name or "${namePrefix}${gemName}-${version}";
|
name = attrs.name or "${namePrefix}${gemName}-${version}";
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user