Basically working. Checking against actual use cases.
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
/*
|
||||
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
|
||||
*/
|
||||
{ writeText, lib, ruby, defaultGemConfig, callPackage }:
|
||||
let
|
||||
test = import ./testing.nix;
|
||||
tap = import ./tap-support.nix;
|
||||
|
||||
bundlerEnv = callPackage ./default.nix {};
|
||||
basicEnv = callPackage ./basic.nix {};
|
||||
|
||||
testConfigs = {
|
||||
groups = ["default"];
|
||||
@@ -22,6 +30,18 @@ let
|
||||
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 {
|
||||
@@ -29,9 +49,12 @@ let
|
||||
gemset = ./test/gemset.nix;
|
||||
};
|
||||
|
||||
pnamed = bundlerEnv {
|
||||
pnamed = basicEnv {
|
||||
pname = "test";
|
||||
gemdir = ./test;
|
||||
gemset = ./test/gemset.nix;
|
||||
gemfile = ./test/Gemfile;
|
||||
lockfile = ./test/Gemfile.lock;
|
||||
};
|
||||
|
||||
results = builtins.concatLists [
|
||||
@@ -40,10 +63,14 @@ let
|
||||
name = should.equal "test";
|
||||
})
|
||||
(test.run "bundlerEnv { pname }" pnamed
|
||||
{
|
||||
name = should.equal "test-0.1.2";
|
||||
env = should.beASet;
|
||||
})
|
||||
[
|
||||
(should.haveKeys [ "name" "env" "postBuild" ])
|
||||
{
|
||||
name = should.equal "test-0.1.2";
|
||||
env = should.beASet;
|
||||
postBuild = should.havePrefix "nananana";
|
||||
}
|
||||
])
|
||||
];
|
||||
in
|
||||
writeText "test-results.tap" (tap.output results)
|
||||
|
||||
Reference in New Issue
Block a user