aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)Author
2023-03-18tests/flake-in-submodule: Remove unnecessary rm -rfRobert Hensing
2023-03-17Add a test with flake.nix in a submoduleJosef Kemetmüller
I noticed a regression in the lazy-trees branch, which I'm trying to capture with this test. While the tests succeeds in master, the lazy-trees branch gives the following error message: error: access to path '/build/nix-test/tests/flakes/flake-in-submodule/rootRepo/submodule/flake.nix' is forbidden because it is not under Git control; maybe you should 'git add' it to the repository '/build/nix-test/tests/flakes/flake-in-submodule/rootRepo'?
2023-03-16Cleanup test skippingJohn Ericson
- Try not to put cryptic "99" in many places Factor out `exit 99` into `skipTest` function - Alows make sure skipping a test is done with a reason `skipTest` takes a mandatory argument - Separate pure conditionals vs side-effectful test skipping. "require daemon" already had this, but "sandbox support" did not.
2023-03-16nix-hash: support base-64 and SRI formatYueh-Shun Li
Add the --base64 and --sri flags for the Base64 and SRI format output. Add the --base16 flag to explicitly specify the hexadecimal format. Add the --to-base64 and --to-sri flag to convert a hash to the above mentioned format.
2023-03-16test/hash.sh: add to-base32 test for nix hashYueh-Shun Li
2023-03-16tests/hash.sh: try: Use FORMAT_FLAG instead of EXTRAYueh-Shun Li
Do not rely on the "multiple format flag specified" behavior. Explicitly test without the format flag / with the --base16 flag.
2023-03-13Merge pull request #8033 from lbodor/stop-adding-dot-to-nix-dev-env-pathRobert Hensing
`print-dev-env`: stop inadvertently adding `.` to `PATH`
2023-03-14Use $TEST_ROOTlbodor
2023-03-13make clean: Delete vars-and-functions.shEelco Dolstra
2023-03-13print-dev-env: test the case when PATH is emptylbodor
2023-03-08Harden tests' bashJohn Ericson
Use `set -u` and `set -o pipefail` to catch accidental mistakes and failures more strongly. - `set -u` catches the use of undefined variables - `set -o pipefail` catches failures (like `set -e`) earlier in the pipeline. This makes the tests a bit more robust. It is nice to read code not worrying about these spurious success paths (via uncaught) errors undermining the tests. Indeed, I caught some bugs doing this. There are a few tests where we run a command that should fail, and then search its output to make sure the failure message is one that we expect. Before, since the `grep` was the last command in the pipeline the exit code of those failing programs was silently ignored. Now with `set -o pipefail` it won't be, and we have to do something so the expected failure doesn't accidentally fail the test. To do that we use `expect` and a new `expectStderr` to check for the exact failing exit code. See the comments on each for why. `grep -q` is replaced with `grepQuiet`, see the comments on that function for why. `grep -v` when we just want the exit code is replaced with `grepInverse, see the comments on that function for why. `grep -q -v` together is, surprise surprise, replaced with `grepQuietInverse`, which is both combined. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-03-07Fix `nix-collect-garbage -d` with the new profile locationThéophane Hufschmitt
Low-hanging fix for https://github.com/NixOS/nix/pull/5226#issuecomment-1454669399
2023-03-01Remove needless `--experimental-feature` in a CA drvs testJohn Ericson
This is already blanket enabled for these tests
2023-03-01Merge pull request #7788 from ↵Valentin Gagarin
bobvanderlinden/pr-improve-nix-profile-install-error Improve error on conflict for nix profile install
2023-02-28Get rid of `.drv` special-casing for store path installablesJohn Ericson
The release notes document the change in behavior, I don't include it here so there is no risk to it getting out of sync. > Motivation >> Plumbing CLI should be simple Store derivation installations are intended as "plumbing": very simple utilities for advanced users and scripts, and not what regular users interact with. (Similarly, regular Git users will use branch and tag names not explicit hashes for most things.) The plumbing CLI should prize simplicity over convenience; that is its raison d'etre. If the user provides a path, we should treat it the same way not caring what sort of path it is. >> Scripting This is especially important for the scripting use-case. when arbitrary paths are sent to e.g. `nix copy` and the script author wants consistent behavior regardless of what those store paths are. Otherwise the script author needs to be careful to filter out `.drv` ones, and then run `nix copy` again with those paths and `--derivation`. That is not good! >> Surprisingly low impact Only two lines in the tests need changing, showing that the impact of this is pretty light. Many command, like `nix log` will continue to work with just the derivation passed as before. This because we used to: - Special case the drv path and replace it with it's outputs (what this gets rid of). - Turn those output path *back* into the original drv path. Now we just skip that entire round trip! > Context Issue #7261 lays out a broader vision for getting rid of `--derivation`, and has this as one of its dependencies. But we can do this with or without that. `Installable::toDerivations` is changed to handle the case of a `DerivedPath::Opaque` ending in `.drv`, which is new: it simply doesn't need to do any extra work in that case. On this basis, commands like `nix {show-derivation,log} /nix/store/...-foo.drv` still work as before, as described above. When testing older daemons, the post-build-hook will be run against the old CLI, so we need the old version of the post-build-hook to support that use-case. Co-authored-by: Travis A. Everett <travis.a.everett@gmail.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-02-28fixup! tests: nix-profile: test install error message upon conflicting filesBob van der Linden
2023-02-28tests: nix-profile: test install error message upon conflicting filesBob van der Linden
2023-02-28Merge pull request #7911 from edolstra/revert-7689Eelco Dolstra
Revert #7689
2023-02-27Merge pull request #7776 from yorickvP/fix-path-escapes-7707Théophane Hufschmitt
Properly escape local paths into URLs in fetchTree
2023-02-27tests/fetchGit: add regression test for #7707Yorick van Pelt
2023-02-27Revert "getDefaultNixPath: actually respect `{restrict,pure}-eval`"Eelco Dolstra
This reverts commit 1cba5984a68a489c4a56691032e4c87991c678f4.
2023-02-27Merge pull request #7796 from hercules-ci/fix-7263Théophane Hufschmitt
Ensure that `self.outPath == ./.`
2023-02-23Clean up daemon handlingJohn Ericson
Split `common.sh` into the vars and functions definitions vs starting the daemon (and possibly other initialization logic). This way, `init.sh` can just `source` the former. Trying to start the daemon before `nix.conf` is written will fail because `nix daemon` requires `--experimental-features 'nix-command'`. `killDaemon` is idempotent, so it's safe to call when no daemon is running. `startDaemon` and `killDaemon` use the PID (which is now exported to subshells) to decide whether there is work to be done, rather than `NIX_REMOTE`, which might conceivably be set differently even if a daemon is running. `startDaemon` and `killDaemon` can save/restore the old `NIX_REMOTE` as `NIX_REMOTE_OLD`. `init.sh` kills daemon before deleting everything (including the daemon socket).
2023-02-23Make init.sh safe to run twiceJohn Ericson
`init.sh` is tested on its own. We used to do that. I deleted it in 4720853129b6866775edd9f90ad6f10701f98a3c but I am not sure why. Better to just restore it; at one point working on this every other test passed, so seems good to check whether `init.sh` can be run twice. We don't *need* to run `init.sh` twice, but I want to try to make our tests as robust as possible so that manual debugging (where tests for better or worse might be run ways that we didn't expect) is less fragile.
2023-02-22flakes: Differentiate `self.outPath` and `self.sourceInfo.outPath`Robert Hensing
It would be incorrect to say that the `sourceInfo` has an `outPath` that isn't the root. `sourceInfo` is about the root, whereas only the flake may not be about the root. Thanks Eelco for pointing that out.
2023-02-22flakes: Ensure that `self.outPath == ./.`Robert Hensing
Users expect `self` to refer to the directory where the `flake.nix` file resides.
2023-02-20Nix's own flake: Dedup and memoize moreJohn Ericson
- `nixpkgsFor` does all of native, static, cross, and the different stdenvs. - The main Nix derivation is no longer duplicated for static. - DRY nixpkgs.lib and lib.genAttrs calls.
2023-02-19Merge pull request #7158 from sternenseemann/foldl-strict-accumulation-valueValentin Gagarin
2023-02-14Make /etc writability conditional on uid-range featureYorick van Pelt
2023-02-14container test: make /etc writableYorick van Pelt
2023-02-14Don't allow writing to /etcYorick van Pelt
2023-02-10Test `nix build --json` return output paths in floating CA caseJohn Ericson
Adding a test to ensure there is no regression. The tests that are split out of `tests/build.sh` are ones that don't yet work with CA derivation. I have not yet evaluated whether they should or not. This behavior, reported missing in issue #4661, already got fixed in PR #4818, but didn't get a test case then.
2023-02-10Merge pull request #7797 from hercules-ci/tests-set-ps4Eelco Dolstra
tests: Add command source locations to test log
2023-02-10Merge pull request #7802 from edolstra/fix-7783Eelco Dolstra
Fix PID namespace support check
2023-02-10Merge pull request #5588 from tweag/balsoft/xdgThéophane Hufschmitt
Follow XDG Base Directory standard
2023-02-10Add regression testEelco Dolstra
2023-02-10A setting to follow XDG Base Directory standardAlexander Bantyev
XDG Base Directory is a standard for locations for storing various files. Nix has a few files which seem to fit in the standard, but currently use a custom location directly in the user's ~, polluting it: - ~/.nix-profile - ~/.nix-defexpr - ~/.nix-channels This commit adds a config option (use-xdg-base-directories) to follow the XDG spec and instead use the following locations: - $XDG_STATE_HOME/nix/profile - $XDG_STATE_HOME/nix/defexpr - $XDG_STATE_HOME/nix/channels If $XDG_STATE_HOME is not set, it is assumed to be ~/.local/state. Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> Co-authored-by: Tim Fenney <kodekata@gmail.com> Co-authored-by: pasqui23 <pasqui23@users.noreply.github.com> Co-authored-by: Artturin <Artturin@artturin.com> Co-authored-by: John Ericson <Ericson2314@Yahoo.com>
2023-02-10Merge pull request #7775 from hercules-ci/test-authorizationRobert Hensing
Add a basic daemon authorization test
2023-02-10tests/authorization: Simplify assertionRobert Hensing
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2023-02-09tests: Add command source locations to test logRobert Hensing
2023-02-09Merge pull request #7754 from obsidiansystems/narrower-scope-derivation-flagThéophane Hufschmitt
Scope down `--derivation` to just the commands that use it
2023-02-07Add some testsEelco Dolstra
2023-02-07Add a basic daemon authorization testRobert Hensing
2023-02-04Remove `--derivation` from testJohn Ericson
It doesn't do anything here, and in the next commit `show-derivation will no longer accept this flag.
2023-02-01Merge pull request #7723 from yorickvP/nix-store-ping-jsonEelco Dolstra
nix store ping: add --json flag
2023-01-31nix flake show: Ignore empty attrsetsRobert Hensing
For frameworks it's important that structures are as lazy as possible to prevent infinite recursions, performance issues and errors that aren't related to the thing to evaluate. As a consequence, they have to emit more attributes than strictly (sic) necessary. However, these attributes with empty values are not useful to the user so we omit them.
2023-01-31tests/store-ping: test nix store ping --jsonYorick van Pelt
2023-01-30Merge pull request #5226 from NixOS/client-side-profilesEelco Dolstra
Move the default profiles to the user’s home
2023-01-30Merge pull request #6988 from max-privatevoid/pr-flake-show-foreignThéophane Hufschmitt
nix flake show: don't evaluate derivations for foreign systems by default
2023-01-30Fix the flakes init testThéophane Hufschmitt
Things leading to another...