-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
lib.debug.throwTestFailures
: init
#416207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cute! I don't know how external systems, if any, consume this, so it will need review by the people responsible for CI who know that (and how failures are supposed to be reported). However, in content, LGTM.
36236c8
to
78448d8
Compare
I'm reasonably confident this is correct, e.g. I didn't change Line 3 in 6cae497
But I would still appreciate a review from the people who run CI. |
50a6e72
to
35b7c5e
Compare
`lib.debug.runTests` provides a unit test evaluator for Nix, but its results are returned in a raw and difficult-to-read form. Currently, different callers output the results in various ways: `builtins.throw (builtins.toJSON failures)` and `builtins.throw ("Tests failed: " + lib.generators.toPretty { } failures)` are both used. This change adds a new `lib.debug.throwTestFailures` function which displays the results nicely before throwing an exception (or returns `null` if no failures are given), unifying these disparate call-sites. First, each failing test is pretty-printed in a `trace` message: ``` trace: FAIL testDerivation: Expected: <derivation a> Result: <derivation b> ``` Then, an exception is thrown containing the number of tests that failed (and their names), followed by the raw JSON of the results (for parity with previous usage, and because `lib.generators.toPretty` sometimes omits information that `builins.toJSON` includes): ``` error: … while evaluating the file '...': … caused by explicit throw at /nix/store/.../lib/debug.nix:528:7: 527| in 528| throw ( | ^ 529| builtins.seq traceFailures ( error: 1 tests failed: - testDerivation [{"expected":"/nix/store/xh7kyqp69mxkwspmi81a94m9xx74r8dr-a","name":"testDerivation","result":"/nix/store/503l84nir4zw57d1shfhai25bxxn16c6-b"}] ```
35b7c5e
to
389e928
Compare
Hello, I've rebased this, is there anything I can do to get it merged? |
let's try asking @hsjobeki or @RaitoBezarius if they know where this is used in CI. I think it is the |
lib.debug.runTests
provides a unit test evaluator for Nix, but its results are returned in a raw and difficult-to-read form.Currently, different callers output the results in various ways:
builtins.throw (builtins.toJSON failures)
andbuiltins.throw ("Tests failed: " + lib.generators.toPretty { } failures)
are both used.This change adds a new
lib.debug.throwTestFailures
function which displays the results nicely before throwing an exception (or returnsnull
if no failures are given), unifying these disparate call-sites.First, each failing test is pretty-printed in a
trace
message:Then, an exception is thrown containing the number of tests that failed (and their names), followed by the raw JSON of the results (for parity with previous usage, and because
lib.generators.toPretty
sometimes omits information thatbuilins.toJSON
includes):Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.