2017-05-04 04:27:42 +01:00
|
|
|
|
/*
|
|
|
|
|
Run with:
|
|
|
|
|
nix-build -E 'with import <nixpkgs> { }; callPackage ./test.nix {}' --show-trace; and cat result
|
|
|
|
|
|
|
|
|
|
Confusingly, the ideal result ends with something like:
|
|
|
|
|
error: build of ‘/nix/store/3245f3dcl2wxjs4rci7n069zjlz8qg85-test-results.tap.drv’ failed
|
|
|
|
|
*/
|
2017-05-09 17:39:20 +01:00
|
|
|
|
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage }@defs:
|
2017-05-01 17:07:42 +01:00
|
|
|
|
let
|
|
|
|
|
test = import ./testing.nix;
|
|
|
|
|
tap = import ./tap-support.nix;
|
2017-05-09 17:39:20 +01:00
|
|
|
|
stubs = import ./stubs.nix defs;
|
|
|
|
|
should = import ./assertions.nix { inherit test lib; };
|
2017-05-01 17:07:42 +01:00
|
|
|
|
|
2017-05-09 17:39:20 +01:00
|
|
|
|
basicEnv = callPackage ./basic.nix stubs;
|
|
|
|
|
bundlerEnv = callPackage ./default.nix stubs // {
|
|
|
|
|
inherit basicEnv;
|
|
|
|
|
};
|
2017-05-01 17:07:42 +01:00
|
|
|
|
|
|
|
|
|
testConfigs = {
|
2017-05-10 18:00:21 +01:00
|
|
|
|
inherit lib;
|
2017-05-01 17:07:42 +01:00
|
|
|
|
gemConfig = defaultGemConfig;
|
|
|
|
|
};
|
2017-05-10 18:00:21 +01:00
|
|
|
|
functions = (import ./functions.nix testConfigs);
|
2017-05-01 17:07:42 +01:00
|
|
|
|
|
|
|
|
|
justName = bundlerEnv {
|
2017-05-15 17:36:30 +01:00
|
|
|
|
name = "test-0.1.2";
|
2017-05-01 17:07:42 +01:00
|
|
|
|
gemset = ./test/gemset.nix;
|
|
|
|
|
};
|
|
|
|
|
|
2017-05-15 17:36:30 +01:00
|
|
|
|
pnamed = bundlerEnv {
|
2017-05-01 17:07:42 +01:00
|
|
|
|
pname = "test";
|
2017-05-04 04:27:42 +01:00
|
|
|
|
gemdir = ./test;
|
2017-05-01 17:07:42 +01:00
|
|
|
|
gemset = ./test/gemset.nix;
|
2017-05-04 04:27:42 +01:00
|
|
|
|
gemfile = ./test/Gemfile;
|
|
|
|
|
lockfile = ./test/Gemfile.lock;
|
2017-05-01 17:07:42 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
results = builtins.concatLists [
|
2017-05-10 18:00:21 +01:00
|
|
|
|
(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))
|
2017-05-12 17:44:39 +01:00
|
|
|
|
( let gemSet = { test = { platforms = []; }; };
|
|
|
|
|
in
|
|
|
|
|
test.run "Filter matches empty platforms list" gemSet (set: functions.filterGemset {inherit ruby; groups = [];} set == gemSet))
|
2017-05-12 17:47:00 +01:00
|
|
|
|
( let gemSet = { test = { platforms = [{engine = ruby.rubyEngine; version = ruby.version.majMin;}]; }; };
|
2017-05-10 18:00:21 +01:00
|
|
|
|
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 == {}))
|
2017-05-01 17:07:42 +01:00
|
|
|
|
(test.run "bundlerEnv { name }" justName {
|
2017-05-15 17:36:30 +01:00
|
|
|
|
name = should.equal "test-0.1.2";
|
2017-05-01 17:07:42 +01:00
|
|
|
|
})
|
|
|
|
|
(test.run "bundlerEnv { pname }" pnamed
|
2017-05-04 04:27:42 +01:00
|
|
|
|
[
|
|
|
|
|
(should.haveKeys [ "name" "env" "postBuild" ])
|
|
|
|
|
{
|
2017-05-15 17:36:30 +01:00
|
|
|
|
name = should.equal "test-0.1.2";
|
2017-05-04 04:27:42 +01:00
|
|
|
|
env = should.beASet;
|
2017-05-09 17:39:20 +01:00
|
|
|
|
postBuild = should.havePrefix "/nix/store";
|
2017-05-04 04:27:42 +01:00
|
|
|
|
}
|
|
|
|
|
])
|
2017-05-01 17:07:42 +01:00
|
|
|
|
];
|
|
|
|
|
in
|
|
|
|
|
writeText "test-results.tap" (tap.output results)
|