push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
{ 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}'");
}

View File

@@ -0,0 +1,26 @@
/*
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)

View File

@@ -0,0 +1,56 @@
{
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';
}

View File

@@ -0,0 +1,29 @@
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}
'';
}

View File

@@ -0,0 +1,73 @@
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;
}