mirror of
https://github.com/NixOS/nix.git
synced 2025-11-18 16:29:36 +01:00
For example, instead of doing
#include "nix/store-config.hh"
#include "nix/derived-path.hh"
Now do
#include "nix/store/config.hh"
#include "nix/store/derived-path.hh"
This was originally planned in the issue, and also recent requested by
Eelco.
Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.
Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!
Progress on #7876
(cherry picked from commit cc24766fa6)
42 lines
1.5 KiB
C++
42 lines
1.5 KiB
C++
#include <gtest/gtest.h>
|
|
#include <cstdlib>
|
|
#include "nix/store/globals.hh"
|
|
#include "nix/util/logging.hh"
|
|
|
|
using namespace nix;
|
|
|
|
int main (int argc, char **argv) {
|
|
if (argc > 1 && std::string_view(argv[1]) == "__build-remote") {
|
|
printError("test-build-remote: not supported in libexpr unit tests");
|
|
return 1;
|
|
}
|
|
|
|
// Disable build hook. We won't be testing remote builds in these unit tests. If we do, fix the above build hook.
|
|
settings.buildHook = {};
|
|
|
|
#if __linux__ // should match the conditional around sandboxBuildDir declaration.
|
|
|
|
// When building and testing nix within the host's Nix sandbox, our store dir will be located in the host's sandboxBuildDir, e.g.:
|
|
// Host
|
|
// storeDir = /nix/store
|
|
// sandboxBuildDir = /build
|
|
// This process
|
|
// storeDir = /build/foo/bar/store
|
|
// sandboxBuildDir = /build
|
|
// However, we have a rule that the store dir must not be inside the storeDir, so we need to pick a different sandboxBuildDir.
|
|
settings.sandboxBuildDir = "/test-build-dir-instead-of-usual-build-dir";
|
|
#endif
|
|
|
|
#if __APPLE__
|
|
// Avoid this error, when already running in a sandbox:
|
|
// sandbox-exec: sandbox_apply: Operation not permitted
|
|
settings.sandboxMode = smDisabled;
|
|
setEnv("_NIX_TEST_NO_SANDBOX", "1");
|
|
#endif
|
|
|
|
// For pipe operator tests in trivial.cc
|
|
experimentalFeatureSettings.set("experimental-features", "pipe-operators");
|
|
|
|
::testing::InitGoogleTest(&argc, argv);
|
|
return RUN_ALL_TESTS();
|
|
}
|