aboutsummaryrefslogtreecommitdiff
path: root/tests/init.sh
AgeCommit message (Collapse)Author
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-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.
2021-07-27Allow running all the tests with the daemonregnat
When `NIX_DAEMON_PACKAGE` is set, make all the tests use the Nix daemon. That way we can test every piece of Nix functionality both with and without the daemon. Tests for which using the daemon isn’t possible or doesn’t make sens can selectively be disabled with `needLocalStore`
2021-07-07Add tests/dummyEelco Dolstra
2021-02-05Add a trace to readLine() failuresEelco Dolstra
Hopefully this helps to diagnose 'error: unexpected EOF reading a line' on macOS.
2020-12-09Use no substituers by default in the testsregnat
Otherwise https://cache.nixos.org is chosen by default, causing the OSX testsuite to hang inside the sandbox. (In a way, this is probably rugging an actual bug under the carpet as Nix should be able to gracefully timeout in such a case, but that's beyond mac OSX-fu)
2020-07-06Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-07-02Set gc-reserved-space to 0 in testsEelco Dolstra
This reduces the amount of disk space needed to run the tests from half a gigabyte to 10 megabytes.
2020-04-07Backport libfetchers from the flakes branchEelco Dolstra
This provides a pluggable mechanism for defining new fetchers. It adds a builtin function 'fetchTree' that generalizes existing fetchers like 'fetchGit', 'fetchMercurial' and 'fetchTarball'. 'fetchTree' takes a set of attributes, e.g. fetchTree { type = "git"; url = "https://example.org/repo.git"; ref = "some-branch"; rev = "abcdef..."; } The existing fetchers are just wrappers around this. Note that the input attributes to fetchTree are the same as flake input specifications and flake lock file entries. All fetchers share a common cache stored in ~/.cache/nix/fetcher-cache-v1.sqlite. This replaces the ad hoc caching mechanisms in fetchGit and download.cc (e.g. ~/.cache/nix/{tarballs,git-revs*}). This also adds support for Git worktrees (c169ea59049f861aaba429f48b828d0820b74d1d).
2020-01-28Simplify flake testsEelco Dolstra
2019-10-21Add experimental-features settingEelco Dolstra
Experimental features are now opt-in. There is currently one experimental feature: "nix-command" (which enables the "nix" command. This will allow us to merge experimental features more quickly, without committing to supporting them indefinitely. Typical usage: $ nix build --experimental-features 'nix-command flakes' nixpkgs#hello (cherry picked from commit 8e478c234100cf03ea1b777d4bd42a9be7be9e8c, without the "flakes" feature)
2019-10-16Add experimental-features settingEelco Dolstra
Experimental features are now opt-in. There are currently two experimental features: "nix-command" (which enables the "nix" command), and "flakes" (which enables support for flakes). This will allow us to merge experimental features more quickly, without committing to supporting them indefinitely. Typical usage: $ nix build --experimental-features 'nix-command flakes' nixpkgs#hello
2019-03-04Restore --init calls in testsEelco Dolstra
2019-02-22remove noop uses of nix-store --initzimbatm
the nix-store --init command is a noop apparently
2018-11-07Enable sandboxing by defaultEelco Dolstra
Closes #179.
2018-02-13Allow includes from nix.confShea Levy
2017-08-31Rename a few configuration optionsEelco Dolstra
In particular, drop the "build-" and "gc-" prefixes which are pointless. So now you can say nix build --no-sandbox instead of nix build --no-build-use-sandbox
2016-08-10Remove $NIX_DB_DIREelco Dolstra
This variable has no reason to exist, given $NIX_STATE_DIR.
2014-05-02Fix Debian testsEelco Dolstra
These actually run as root in a VM, so they get confused. http://hydra.nixos.org/build/10775854
2012-03-19Replace "make check" with "make installcheck"Eelco Dolstra
Ensuring that the tests work from the build tree requires a growing number of nasty hacks. The tests also don't verify that the installed Nix actually works. Thus, the tests now require "make install" to have been run.
2012-03-18Drop the externals directoryEelco Dolstra
Nix now requires SQLite and bzip2 to be pre-installed. SQLite is detected using pkg-config. We required DBD::SQLite anyway, so depending on SQLite is not a big problem. The --with-bzip2, --with-openssl and --with-sqlite flags are gone.
2012-01-11tests: Run `download-using-manifests' via libtool so that dlopening works.Ludovic Courtès
2012-01-03* Refactoring: Get rid of a few subdirectories in corepkgs/, and someEelco Dolstra
other simplifications. * Use <nix/...> to locate the corepkgs. This allows them to be overriden through $NIX_PATH. * Use bash's pipefail option in the NAR builder so that we don't need to create a temporary file.
2011-10-10* Refactoring: remove unnecessary variables from the tests.Eelco Dolstra
2011-10-10* Install NixManifest.pm, NixConfig.pm and GeneratePatches.pm underEelco Dolstra
the Nix:: namespace.
2010-12-05* Use CamelCase for the Perl modules.Eelco Dolstra
2010-12-05* Add a script `nix-generate-patches'.Eelco Dolstra
* Fix the binary patching test.
2010-11-17* Finally, a test for the binary patch functionality.Eelco Dolstra
2010-02-24* Disable fsync() in SQLite if the fsync-metadata option is set toEelco Dolstra
false. * Change the default for `fsync-metadata' to true. * Disable `fsync-metadata' in `make check'.
2010-02-18* Implemented queryValidPaths() and verifyStore().Eelco Dolstra
2009-11-13* In nix-pull/nix-channel, create the manifests directory if itEelco Dolstra
doesn't exist. The Debian packages don't include the manifests directory, so nix-channel would silently skip doing a nix-pull, resulting in everything being built from source. Thanks to Juan Pedro Bolívar Puente.
2008-12-03(no commit message)Eelco Dolstra
2008-11-20* Urgh.Eelco Dolstra
2008-11-20* Blindly doing a replacement of occurences of $bindir (when runningEelco Dolstra
the tests) is a bad idea when $bindir = /usr and some programs (like perl) live there. Fortunately it doesn't seem to be needed anymore.
2008-11-20* Don't set the prefix to /nix by default, rather use the AutoconfEelco Dolstra
default of /usr/local. However, localstatedir and storedir are set to /nix/var/nix and /nix/store respectively unless they're explicitly overriden.
2008-07-18* Fix the tests.Eelco Dolstra
2008-06-09* Merged the no-bdb branch (-r10900:HEADEelco Dolstra
https://svn.nixos.org/repos/nix/nix/branches/no-bdb).
2007-12-14* Another insane Mac OS X 10.5 compatibility hack.Eelco Dolstra
2007-09-04* nix-push / generate-patches: bzip the manifest.Eelco Dolstra
2007-08-13* A test for the nix-worker.Eelco Dolstra
2006-09-21* `nix-install-package --url': install from a URL (NIX-12).Eelco Dolstra
* `nix-install-package --help' (NIX-9). * `nix-install-package --non-interactive': don't prompt or pause. * Tests for nix-install-package. * Security fixes: filter the values obtained from the nixpkg.
2006-05-29* Handle $PATHs with spaces.Eelco Dolstra
2006-04-25* Unless --with-bzip2 is specified, use a copy of bzip2 in theEelco Dolstra
externals directory. This is in particular useful because though most systems have bzip2/bunzip2, they don't always have libbz2, which we need for bsdiff/bspatch.
2006-03-01* Test nix-build. This also tests indirect roots.Eelco Dolstra
2006-03-01* Simplification.Eelco Dolstra
2006-03-01* Make it easy to run individual tests from the command line.Eelco Dolstra
2006-02-08* Tests for nix-env, finally!Eelco Dolstra
2005-07-25* Hack to get around the libtool wrapper script around nix-store notEelco Dolstra
working when PATH is unset.
2005-04-07* Get rid of fetchurl, we don't need it anymore.Eelco Dolstra