Restructuring files
This commit is contained in:
parent
022be78eb2
commit
998d011e42
|
@ -0,0 +1,23 @@
|
||||||
|
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage, test, stubs, should }@defs:
|
||||||
|
let
|
||||||
|
testConfigs = {
|
||||||
|
inherit lib;
|
||||||
|
gemConfig = defaultGemConfig;
|
||||||
|
};
|
||||||
|
functions = (import ./functions.nix testConfigs);
|
||||||
|
in
|
||||||
|
builtins.concatLists [
|
||||||
|
(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 = []; }; };
|
||||||
|
in
|
||||||
|
test.run "Filter matches empty platforms list" gemSet (set: functions.filterGemset {inherit ruby; groups = [];} set == gemSet))
|
||||||
|
( let gemSet = { test = { platforms = [{engine = ruby.rubyEngine; version = ruby.version.majMin;}]; }; };
|
||||||
|
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 == {}))
|
||||||
|
]
|
|
@ -24,7 +24,7 @@
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (import ./functions.nix {inherit lib ruby gemConfig groups; }) genStubsScript;
|
inherit (import ../bundled-common/functions.nix {inherit lib ruby gemConfig groups; }) genStubsScript;
|
||||||
|
|
||||||
drvName =
|
drvName =
|
||||||
if name != null then lib.traceVal name
|
if name != null then lib.traceVal name
|
||||||
|
@ -43,7 +43,7 @@ let
|
||||||
if gemset == null then gemdir + "/gemset.nix"
|
if gemset == null then gemdir + "/gemset.nix"
|
||||||
else gemset;
|
else gemset;
|
||||||
|
|
||||||
basicEnv = (callPackage ./basic.nix {}) (args // { inherit pname name gemdir;
|
basicEnv = (callPackage ../bundled-common {}) (args // { inherit pname name gemdir;
|
||||||
gemfile = gemfile';
|
gemfile = gemfile';
|
||||||
lockfile = lockfile';
|
lockfile = lockfile';
|
||||||
gemset = gemset';
|
gemset = gemset';
|
||||||
|
|
|
@ -1,28 +1,9 @@
|
||||||
/*
|
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage, test, stubs, should}@defs:
|
||||||
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
|
|
||||||
*/
|
|
||||||
{ stdenv, writeText, lib, ruby, defaultGemConfig, callPackage }@defs:
|
|
||||||
let
|
let
|
||||||
test = import ./testing.nix;
|
|
||||||
tap = import ./tap-support.nix;
|
|
||||||
stubs = import ./stubs.nix defs;
|
|
||||||
should = import ./assertions.nix { inherit test lib; };
|
|
||||||
|
|
||||||
basicEnv = callPackage ./basic.nix stubs;
|
|
||||||
bundlerEnv = callPackage ./default.nix stubs // {
|
bundlerEnv = callPackage ./default.nix stubs // {
|
||||||
inherit basicEnv;
|
basicEnv = callPackage ../bundled-common stubs;
|
||||||
};
|
};
|
||||||
|
|
||||||
testConfigs = {
|
|
||||||
inherit lib;
|
|
||||||
gemConfig = defaultGemConfig;
|
|
||||||
};
|
|
||||||
functions = (import ./functions.nix testConfigs);
|
|
||||||
|
|
||||||
justName = bundlerEnv {
|
justName = bundlerEnv {
|
||||||
name = "test-0.1.2";
|
name = "test-0.1.2";
|
||||||
gemset = ./test/gemset.nix;
|
gemset = ./test/gemset.nix;
|
||||||
|
@ -35,21 +16,8 @@ let
|
||||||
gemfile = ./test/Gemfile;
|
gemfile = ./test/Gemfile;
|
||||||
lockfile = ./test/Gemfile.lock;
|
lockfile = ./test/Gemfile.lock;
|
||||||
};
|
};
|
||||||
|
in
|
||||||
results = builtins.concatLists [
|
builtins.concatLists [
|
||||||
(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 = []; }; };
|
|
||||||
in
|
|
||||||
test.run "Filter matches empty platforms list" gemSet (set: functions.filterGemset {inherit ruby; groups = [];} set == gemSet))
|
|
||||||
( let gemSet = { test = { platforms = [{engine = ruby.rubyEngine; version = ruby.version.majMin;}]; }; };
|
|
||||||
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-0.1.2";
|
name = should.equal "test-0.1.2";
|
||||||
})
|
})
|
||||||
|
@ -62,6 +30,4 @@ let
|
||||||
postBuild = should.havePrefix "/nix/store";
|
postBuild = should.havePrefix "/nix/store";
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
];
|
]
|
||||||
in
|
|
||||||
writeText "test-results.tap" (tap.output results)
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o xtrace
|
||||||
|
pwd
|
||||||
|
find . -name text.nix
|
||||||
|
testfiles=$(find . -name test.nix)
|
||||||
|
nix-build -E "with import <nixpkgs> {}; callPackage testing/driver.nix { testFiles = [ $testfiles ]; }" --show-trace && cat result
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
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, callPackage, testFiles, stdenv, ruby }@defs:
|
||||||
|
let
|
||||||
|
testTools = rec {
|
||||||
|
test = import ./testing.nix;
|
||||||
|
stubs = import ./stubs.nix defs;
|
||||||
|
should = import ./assertions.nix { inherit test lib; };
|
||||||
|
};
|
||||||
|
|
||||||
|
tap = import ./tap-support.nix;
|
||||||
|
|
||||||
|
results = builtins.concatLists (map (file: callPackage file testTools) testFiles);
|
||||||
|
in
|
||||||
|
writeText "test-results.tap" (tap.output results)
|
Loading…
Reference in New Issue