uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
28
pkgs/development/ruby-modules/testing/assertions.nix
Normal file
28
pkgs/development/ruby-modules/testing/assertions.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{ test, lib, ...}:
|
||||
{
|
||||
equal = expected: actual:
|
||||
if actual == expected then
|
||||
(test.passed "= ${toString expected}") else
|
||||
(test.failed (
|
||||
"expected '${toString expected}'(${builtins.typeOf expected})"
|
||||
+ " != "+
|
||||
"actual '${toString actual}'(${builtins.typeOf actual})"
|
||||
));
|
||||
|
||||
beASet = actual:
|
||||
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}] actual: [${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}'");
|
||||
}
|
||||
20
pkgs/development/ruby-modules/testing/driver.nix
Normal file
20
pkgs/development/ruby-modules/testing/driver.nix
Normal file
|
|
@ -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, 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)
|
||||
30
pkgs/development/ruby-modules/testing/stubs.nix
Normal file
30
pkgs/development/ruby-modules/testing/stubs.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{ stdenv, lib, ruby, callPackage, ... }:
|
||||
let
|
||||
mkDerivation = {name, ...}@argSet:
|
||||
derivation {
|
||||
inherit name;
|
||||
text = (builtins.toJSON (lib.filterAttrs ( n: v: builtins.any (x: x == n) ["name" "system"]) argSet));
|
||||
builder = stdenv.shell;
|
||||
args = [ "-c" "echo $(<$textPath) > $out"];
|
||||
system = stdenv.hostPlatform.system;
|
||||
passAsFile = ["text"];
|
||||
};
|
||||
fetchurl = {url?"", urls ? [],...}: "fetchurl:${if urls == [] then url else builtins.head urls}";
|
||||
|
||||
stdenv' = stdenv // {
|
||||
inherit mkDerivation;
|
||||
stubbed = true;
|
||||
};
|
||||
ruby' = ruby // {
|
||||
stdenv = stdenv';
|
||||
stubbed = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
ruby = ruby';
|
||||
buildRubyGem = callPackage ../gem {
|
||||
inherit fetchurl;
|
||||
ruby = ruby';
|
||||
};
|
||||
stdenv = stdenv';
|
||||
}
|
||||
21
pkgs/development/ruby-modules/testing/tap-support.nix
Normal file
21
pkgs/development/ruby-modules/testing/tap-support.nix
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
with builtins;
|
||||
let
|
||||
withIndexes = list: genList (idx: (elemAt list idx) // {index = idx;}) (length list);
|
||||
|
||||
testLine = report: "${okStr report} ${toString (report.index + 1)} ${report.description}" + testDirective report + testYaml report;
|
||||
|
||||
# These are part of the TAP spec, not yet implemented.
|
||||
#c.f. https://github.com/NixOS/nixpkgs/issues/27071
|
||||
testDirective = report: "";
|
||||
testYaml = report: "";
|
||||
|
||||
okStr = { result, ...}: if result == "pass" then "ok" else "not ok";
|
||||
in
|
||||
{
|
||||
output = reports: ''
|
||||
TAP version 13
|
||||
1..${toString (length reports)}'' + (foldl' (l: r: l + "\n" + r) "" (map testLine (withIndexes reports))) + ''
|
||||
|
||||
# Finished at ${toString currentTime}
|
||||
'';
|
||||
}
|
||||
62
pkgs/development/ruby-modules/testing/testing.nix
Normal file
62
pkgs/development/ruby-modules/testing/testing.nix
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
with builtins;
|
||||
let
|
||||
/*
|
||||
underTest = {
|
||||
x = {
|
||||
a = 1;
|
||||
b = "2";
|
||||
};
|
||||
};
|
||||
|
||||
tests = [
|
||||
(root: false)
|
||||
{
|
||||
x = [
|
||||
(set: true)
|
||||
{
|
||||
a = (a: a > 1);
|
||||
b = (b: b == "3");
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
results = run "Examples" underTest tests;
|
||||
*/
|
||||
|
||||
passed = desc: {
|
||||
result = "pass";
|
||||
description = desc;
|
||||
};
|
||||
|
||||
failed = desc: {
|
||||
result = "failed";
|
||||
description = desc;
|
||||
};
|
||||
|
||||
prefixName = name: res: {
|
||||
inherit (res) result;
|
||||
description = "${name}: ${res.description}";
|
||||
};
|
||||
|
||||
run = name: under: tests: if isList tests then
|
||||
(concatLists (map (run name under) tests))
|
||||
else if isAttrs tests then
|
||||
(concatLists (map (
|
||||
subName: run (name + "." + subName) (if hasAttr subName under then getAttr subName under else "<MISSING!>") (getAttr subName tests)
|
||||
) (attrNames tests)))
|
||||
else if isFunction tests then
|
||||
let
|
||||
res = tests under;
|
||||
in
|
||||
if isBool res then
|
||||
[
|
||||
(prefixName name (if tests under then passed "passed" else failed "failed"))
|
||||
]
|
||||
else
|
||||
[ (prefixName name res) ]
|
||||
else [
|
||||
failed (name ": not a function, list or set")
|
||||
];
|
||||
in
|
||||
{ inherit run passed failed; }
|
||||
Loading…
Add table
Add a link
Reference in a new issue