summaryrefslogtreecommitdiff
path: root/lib/tests (follow)
Commit message (Expand)AuthorAgeFilesLines
* lib/modules: add suggestions to invalid option name errors (#442263)Silvan Mosberger2026-02-037-0/+192
|\
| * lib/modules: Fix suggestions in submodulesRobert Hensing2025-10-283-0/+72
| * lib/modules: Support multiple suggestions, optimizeRobert Hensing2025-10-283-0/+80
| * lib/modules: add suggestions to invalid option name errors•••This change introduces the suggesting of possible valid option names for a given invalid option, based on the keys of said invalid option's parent attrset. That is, `foo.bar.baz` will only be suggested keys from `foo.bar`, while `(config).baz` will only be suggested keys from the toplevel. Winter2025-09-113-0/+40
* | treewide: apply nixfmt 1.2.0Dyego Aurélio2026-01-222-6/+6
* | lib.lists.replaceElemAt: init (#477775)Johannes Kirschbauer2026-01-221-0/+13
|\ \
| * | lib.lists.replaceElemAt: init•••It's very easy to resort to lib.take + lib.drop to accomplish this, but it's not obvious that it actually performs quite badly. Replacing an item in a list should be a relative common operation. Glen Huang2026-01-121-0/+13
* | | lib/types: add tests for types.mkStructuredTypeJohannes Kirschbauer2026-01-202-0/+45
* | | lib/tests: add strict option to checkConfigOutputJohannes Kirschbauer2026-01-201-4/+11
|/ /
* | lib/strings.escapeNixIdentifier: quote keywords•••Previously `lib.strings.escapeNixIdentifier "assert"` would return `"assert"`; This is wrong, `assert` is not a valid identifier unless quoted.\ This also fixes `lib.generators.toPretty`: `toPretty {} { "assert" = false; }` would previously return an invalid expression. Shelvacu2026-01-021-1/+17
* | lib.makeOverridable: preserve constructor override and metadata attributes (#...Robert Hensing2025-12-221-0/+79
|\ \
| * | lib.makeOverrdable: preserve constructor override and metadata attributesYueh-Shun Li2025-11-131-0/+79
* | | lib/tests: Use --option to enable abort-on-warnTom Hubrecht2025-12-081-39/+43
* | | lib/tests: move throwTestFailures tests to standalone script•••The throwTestFailures tests in misc.nix produce confusing trace output that looks like test failures even when tests pass. This commit moves these tests to a new lib/tests/debug.sh script, following the pattern from modules.sh, sources.sh, and filesystem.sh. The confusing trace output does not appear in any logs anymore. Example of the confusing log: trace: FAIL "testDerivation": Expected: <derivation a> Result: <derivation b> evaluation warning: Using `lib.generators.toPlist` without `escape = true` is deprecated [ ] Robert Hensing2025-11-263-29/+85
* | | lib/types: make `attrTag`'s `description` field list valid choices (#464627)Robert Hensing2025-11-251-6/+6
|\ \ \
| * | | lib/types: make `attrTag`'s `description` field list valid choices•••Lists the valid choices in `attrTag` type's `description` field. Given this description is used in error messages, this serves to make for somewhat more descriptive errors in the event an option involving this type turns out not to match. Signed-off-by: cinereal <cinereal@riseup.net> cinereal2025-11-241-6/+6
| |/ /
* | | lib: deprecate fold (#456532)Johannes Kirschbauer2025-11-251-9/+6
|\ \ \ | |/ / |/| |
| * | lib: deprecate foldAliaksandr2025-10-301-9/+6
* | | lib.debug.throwTestFailures: init•••`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"}] ``` Rebecca Turner2025-11-101-2/+27
* | | lib/types: add externalPathFelix Buehler2025-11-042-0/+17
* | | lib.types: introduce a `fileset` type (#428293)Robert Hensing2025-11-043-0/+62
|\ \ \
| * | | lib.types: add module tests for `fileset`Niols2025-08-293-0/+62
* | | | lib: Add splicing utilities (#426889)Robert Hensing2025-10-301-0/+78
|\ \ \ \ | |_|/ / |/| | |
| * | | lib: Introduce Cross Index concept•••A Cross Index, short for Cross Platform Pair Index, is the essential shape of a splice, without the invoking the more mind bending concept of adding variations of for these 6 pairings to an existing thing so that it can be switched out for something else. So the purpose of a Cross Index is to contain the result of `f`\ (which may be reified in code, or just an abstract concept): - f "build" "build" - f "build" "host" - ... Splicing on the other hand refers not just to these six variants, but to the idea of tacking them onto one of the variants. (hostTarget, I believe) Cross Indexes are a necessity for making cross compilation work, but splicing is more than necessary. Robert Hensing2025-09-091-9/+9
| * | | lib: Add splice structure utilitiesRobert Hensing2025-09-091-0/+78
* | | | lib/modules: Report error for unsupported `t // { check = ...; }` (#454964)Robert Hensing2025-10-282-0/+136
|\ \ \ \
| * | | | lib/modules: Report error for unsupported // { check }•••`check` can have a new place since the introduction of merge.v2. This makes the // { check = ... } idiom unreliable. In this PR we add checks to detect and report this. merge.v2 introduced in: https://github.com/NixOS/nixpkgs/pull/391544 Real world case: https://hercules-ci.com/github/hercules-ci/hercules-ci-effects/jobs/875 Robert Hensing2025-10-232-0/+136
* | | | | lib.teams: Add githubId from associated github teams•••This will allow the code for https://github.com/NixOS/nixpkgs/issues/447514 to make sure that the right team is requested for review, even if it has been renamed in the meantime. While the matching is currently based on the teams slug/name and not the id, renames won't cause problems with `lib.teams`, because CI would error if there's no match. Changing this can be future work. Silvan Mosberger2025-10-281-0/+4
* | | | | lib.teams: Add githubMaintainers field•••This is so you can figure out who to ask to get added to the team Also avoid an unecessary `{ inherit lib; }` argument Silvan Mosberger2025-10-271-1/+5
* | | | | treewide: remove deprecated lib functions that had warning for more than 2 yearsAliaksandr2025-10-241-1/+1
|/ / / /
* | | | lib/cli: add toCommandLineLukas Wurzinger2025-10-211-0/+80
* | | | lib.teams: Remove .githubTeams in favor of singular .github•••No team was using the feature of having multiple GitHub teams, and this would make it tricky to try to sync maintainer teams with GitHub teams. Silvan Mosberger2025-10-081-3/+3
* | | | treewide: remove redundant parentheses•••Auto-fixed by nixf-diagnose. Wolfgang Walther2025-10-055-20/+18
* | | | lib: init strings.join (#446278)Robert Hensing2025-10-021-0/+10
|\ \ \ \
| * | | | lib: init strings.joinJohannes Kirschbauer2025-09-271-0/+10
* | | | | lib: remove optional builtins prefixes from prelude functions (#447402)Philip Taron2025-09-305-5/+5
|\ \ \ \ \
| * | | | | lib: add builtins prefixes for prelude functions to improve clarityNAHO2025-09-301-1/+1
| * | | | | lib: remove optional builtins prefixes from prelude functions•••Remove optional builtins prefixes from prelude functions by running: builtins=( abort baseNameOf break derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true ) fd --type file . lib --exec-batch sed --in-place --regexp-extended " s/\<builtins\.($( printf '%s\n' "${builtins[@]}" | paste --delimiter '|' --serial - ))\>/\1/g " nix fmt NAHO2025-09-305-6/+6
| |/ / / /
* | | | | cygwin: add as a cross-compilation target, and get hello to build (#444470)John Ericson2025-09-301-2/+1
|\ \ \ \ \ | |/ / / / |/| | | |
| * | | | cygwin: init as a target toolchain•••The old cygwin support used -pc-windows-cygnus as the config. This is supported by LLVM, but not by GNU. This will change it to -pc-cygwin, which is more generally supported. Because the kernel is now 'cygwin' rather than 'windows', isWindows will return false. There are lots of different reasons isWindows is used in nixpkgs, but in my experience they often have to do with posix compatibility and don't apply to cygwin. Co-authored-by: Brian McKenna <brian@brianmckenna.org> David McFarland2025-09-271-2/+1
* | | | | lib/types: submodule fix description with freeformType (#443134)Johannes Kirschbauer2025-09-252-0/+462
|\ \ \ \ \ | |/ / / / |/| | | |
| * | | | lib/tests/modules: Test description compositionRobert Hensing2025-09-172-0/+462
| |/ / /
* | | | lib/types: minimal fix for the regression of either when used in freeformType...Johannes Kirschbauer2025-09-145-0/+107
|\ \ \ \
| * | | | lib/types.either: add tests for warning in legacy caseJohannes Kirschbauer2025-09-065-0/+107
| | |/ / | |/| |
* | | | lib.options.optionAttrSetToDocList: add `visible = "transparent"` (#441782)Robert Hensing2025-09-111-0/+105
|\ \ \ \
| * | | | lib.options.optionAttrSetToDocList: add `visible = "transparent"`•••Allows marking an option as invisible, without excluding its sub-options. In practice, this is similar to `visible = true; internal = true;`, however it is more explicit and less reliant on implementation details. Matt Sturgeon2025-09-111-0/+16
| * | | | lib/tests/misc: add option visibility testMatt Sturgeon2025-09-101-0/+89
* | | | | lib.mkEUI64Suffix: init (#416086)misuzu2025-09-111-0/+44
|\ \ \ \ \ | |/ / / / |/| | | |
| * | | | lib.mkEUI64Suffix: fix syntax errors and testsnukdokplex2025-09-111-25/+25
| * | | | lib.mkEUI64Suffix: bring @hsjobeki suggestions•••renamed `mac` to `octets` in hextets combining step for better var naming; rephrased error message to provide a hint of expected format; replaced `Arguments` with `Inputs` in docstring; added more test cases for invalid hex digits; added comments in hextets combining step; nukdokplex2025-09-101-19/+25