Current round of tests pass, but filter function is failing to include when platform match in use.
This commit is contained in:
parent
0145ec999c
commit
07f781bd8d
|
@ -20,15 +20,13 @@
|
|||
, ...
|
||||
}@args:
|
||||
|
||||
with (
|
||||
builtins.trace "basic functions"
|
||||
import ./functions.nix { inherit lib ruby gemConfig groups; });
|
||||
with import ./functions.nix { inherit lib gemConfig; };
|
||||
|
||||
let
|
||||
|
||||
importedGemset = import gemset;
|
||||
|
||||
filteredGemset = filterGemset importedGemset;
|
||||
filteredGemset = filterGemset { inherit ruby groups; } importedGemset;
|
||||
|
||||
configuredGemset = lib.flip lib.mapAttrs filteredGemset (name: attrs:
|
||||
applyGemConfigs (attrs // { inherit ruby; gemName = name; })
|
||||
|
@ -66,13 +64,12 @@ let
|
|||
|
||||
buildGem = name: attrs: (
|
||||
let
|
||||
gemAttrs = composeGemAttrs gems name attrs;
|
||||
gemAttrs = composeGemAttrs ruby gems name attrs;
|
||||
in
|
||||
if gemAttrs.type == "path" then
|
||||
pathDerivation gemAttrs
|
||||
else
|
||||
builtins.trace (lib.showVal (gemAttrs.ruby or "def ruby"))
|
||||
buildRubyGem gemAttrs
|
||||
buildRubyGem gemAttrs
|
||||
);
|
||||
|
||||
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
{ lib, ruby, groups, gemConfig, ... }:
|
||||
builtins.trace (if ruby.stubbed or false then "functions has stubbed ruby" else "functions has live ruby")
|
||||
{ lib, gemConfig, ... }:
|
||||
rec {
|
||||
filterGemset = gemset: lib.filterAttrs (name: attrs: platformMatches attrs && groupMatches attrs) gemset;
|
||||
filterGemset = {ruby, groups,...}@env: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) gemset;
|
||||
|
||||
platformMatches = attrs: (
|
||||
platformMatches = {rubyEngine, version, ...}@ruby: attrs: (
|
||||
!(attrs ? "platforms") ||
|
||||
builtins.trace "ruby engine: ${rubyEngine}"
|
||||
builtins.trace "ruby version ${version.majMin}"
|
||||
builtins.any (platform:
|
||||
platform.engine == ruby.rubyEngine &&
|
||||
(!(platform ? "version") || platform.version == ruby.version.majMin)
|
||||
builtins.trace "checking: ${platform.engine}/${platform.version}"
|
||||
platform.engine == rubyEngine &&
|
||||
(!(platform ? "version") || platform.version == version.majMin)
|
||||
) attrs.platforms
|
||||
);
|
||||
|
||||
groupMatches = attrs: (
|
||||
groupMatches = groups: attrs: (
|
||||
!(attrs ? "groups") ||
|
||||
builtins.any (gemGroup: builtins.any (group: group == gemGroup) groups) attrs.groups
|
||||
);
|
||||
|
@ -45,7 +47,7 @@ rec {
|
|||
};
|
||||
in res;
|
||||
|
||||
composeGemAttrs = gems: name: attrs: ((removeAttrs attrs ["source" "platforms"]) // attrs.source // {
|
||||
composeGemAttrs = ruby: gems: name: attrs: ((removeAttrs attrs ["source" "platforms"]) // attrs.source // {
|
||||
inherit ruby;
|
||||
gemName = name;
|
||||
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
nix-build -E 'with import <nixpkgs> { }; callPackage ./test.nix {}' --show-trace && cat result
|
|
@ -18,11 +18,10 @@ let
|
|||
};
|
||||
|
||||
testConfigs = {
|
||||
groups = ["default"];
|
||||
inherit lib;
|
||||
gemConfig = defaultGemConfig;
|
||||
confFiles = "./testConfs";
|
||||
};
|
||||
functions = (import ./functions.nix ({ inherit lib; ruby = stubs.ruby; } // testConfigs));
|
||||
functions = (import ./functions.nix testConfigs);
|
||||
|
||||
justName = bundlerEnv {
|
||||
name = "test";
|
||||
|
@ -38,7 +37,16 @@ let
|
|||
};
|
||||
|
||||
results = builtins.concatLists [
|
||||
(test.run "Filter empty gemset" {} (set: functions.filterGemset set == {}))
|
||||
(test.run "Filter empty gemset" {} (set: functions.filterGemset {inherit ruby; groups = ["default"]; } set == {}))
|
||||
( let gemSet = { test = { groups = ["x" "y"]; }; };
|
||||
in
|
||||
test.run "Filter matches a group" gemSet (set: functions.filterGemset {inherit ruby; groups = ["y" "z"];} set == gemSet))
|
||||
( let gemSet = { test = { platforms = [{engine = ruby.rubyEngine; version = ruby.version;}]; }; };
|
||||
in
|
||||
test.run "Filter matches on platform" gemSet (set: functions.filterGemset {inherit ruby; groups = [];} set == gemSet))
|
||||
( let gemSet = { test = { groups = ["x" "y"]; }; };
|
||||
in
|
||||
test.run "Filter excludes based on groups" gemSet (set: functions.filterGemset {inherit ruby; groups = ["a" "b"];} set == {}))
|
||||
(test.run "bundlerEnv { name }" justName {
|
||||
name = should.equal "test";
|
||||
})
|
||||
|
|
|
@ -74,8 +74,6 @@ let
|
|||
|
||||
in
|
||||
|
||||
builtins.trace (gemName)
|
||||
builtins.trace (stdenv.stubbed or false)
|
||||
stdenv.mkDerivation (attrs // {
|
||||
inherit ruby;
|
||||
inherit doCheck;
|
||||
|
|
Loading…
Reference in New Issue