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:
|
}@args:
|
||||||
|
|
||||||
with (
|
with import ./functions.nix { inherit lib gemConfig; };
|
||||||
builtins.trace "basic functions"
|
|
||||||
import ./functions.nix { inherit lib ruby gemConfig groups; });
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
importedGemset = import gemset;
|
importedGemset = import gemset;
|
||||||
|
|
||||||
filteredGemset = filterGemset importedGemset;
|
filteredGemset = filterGemset { inherit ruby groups; } importedGemset;
|
||||||
|
|
||||||
configuredGemset = lib.flip lib.mapAttrs filteredGemset (name: attrs:
|
configuredGemset = lib.flip lib.mapAttrs filteredGemset (name: attrs:
|
||||||
applyGemConfigs (attrs // { inherit ruby; gemName = name; })
|
applyGemConfigs (attrs // { inherit ruby; gemName = name; })
|
||||||
@ -66,13 +64,12 @@ let
|
|||||||
|
|
||||||
buildGem = name: attrs: (
|
buildGem = name: attrs: (
|
||||||
let
|
let
|
||||||
gemAttrs = composeGemAttrs gems name attrs;
|
gemAttrs = composeGemAttrs ruby gems name attrs;
|
||||||
in
|
in
|
||||||
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
|
|
||||||
);
|
);
|
||||||
|
|
||||||
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
envPaths = lib.attrValues gems ++ lib.optional (!hasBundler) bundler;
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
{ lib, ruby, groups, gemConfig, ... }:
|
{ lib, 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 = {ruby, groups,...}@env: gemset: lib.filterAttrs (name: attrs: platformMatches ruby attrs && groupMatches groups attrs) gemset;
|
||||||
|
|
||||||
platformMatches = attrs: (
|
platformMatches = {rubyEngine, version, ...}@ruby: attrs: (
|
||||||
!(attrs ? "platforms") ||
|
!(attrs ? "platforms") ||
|
||||||
|
builtins.trace "ruby engine: ${rubyEngine}"
|
||||||
|
builtins.trace "ruby version ${version.majMin}"
|
||||||
builtins.any (platform:
|
builtins.any (platform:
|
||||||
platform.engine == ruby.rubyEngine &&
|
builtins.trace "checking: ${platform.engine}/${platform.version}"
|
||||||
(!(platform ? "version") || platform.version == ruby.version.majMin)
|
platform.engine == rubyEngine &&
|
||||||
|
(!(platform ? "version") || platform.version == version.majMin)
|
||||||
) attrs.platforms
|
) attrs.platforms
|
||||||
);
|
);
|
||||||
|
|
||||||
groupMatches = attrs: (
|
groupMatches = groups: attrs: (
|
||||||
!(attrs ? "groups") ||
|
!(attrs ? "groups") ||
|
||||||
builtins.any (gemGroup: builtins.any (group: group == gemGroup) groups) attrs.groups
|
builtins.any (gemGroup: builtins.any (group: group == gemGroup) groups) attrs.groups
|
||||||
);
|
);
|
||||||
@ -45,7 +47,7 @@ rec {
|
|||||||
};
|
};
|
||||||
in res;
|
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;
|
inherit ruby;
|
||||||
gemName = name;
|
gemName = name;
|
||||||
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
|
gemPath = map (gemName: gems."${gemName}") (attrs.dependencies or []);
|
||||||
|
2
pkgs/development/ruby-modules/bundler-env/runtests.sh
Executable file
2
pkgs/development/ruby-modules/bundler-env/runtests.sh
Executable file
@ -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 = {
|
testConfigs = {
|
||||||
groups = ["default"];
|
inherit lib;
|
||||||
gemConfig = defaultGemConfig;
|
gemConfig = defaultGemConfig;
|
||||||
confFiles = "./testConfs";
|
|
||||||
};
|
};
|
||||||
functions = (import ./functions.nix ({ inherit lib; ruby = stubs.ruby; } // testConfigs));
|
functions = (import ./functions.nix testConfigs);
|
||||||
|
|
||||||
justName = bundlerEnv {
|
justName = bundlerEnv {
|
||||||
name = "test";
|
name = "test";
|
||||||
@ -38,7 +37,16 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
results = builtins.concatLists [
|
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 {
|
(test.run "bundlerEnv { name }" justName {
|
||||||
name = should.equal "test";
|
name = should.equal "test";
|
||||||
})
|
})
|
||||||
|
@ -74,8 +74,6 @@ 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;
|
||||||
|
Loading…
Reference in New Issue
Block a user