mirror of
https://github.com/NixOS/nix
synced 2025-06-30 15:48:00 +02: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
71 lines
2.2 KiB
C++
71 lines
2.2 KiB
C++
#include <nlohmann/json.hpp>
|
|
#include <gtest/gtest.h>
|
|
#include <rapidcheck/gtest.h>
|
|
|
|
#include "nix/store/tests/derived-path.hh"
|
|
#include "nix/expr/tests/libexpr.hh"
|
|
|
|
namespace nix {
|
|
|
|
// Testing of trivial expressions
|
|
class DerivedPathExpressionTest : public LibExprTest {};
|
|
|
|
// FIXME: `RC_GTEST_FIXTURE_PROP` isn't calling `SetUpTestSuite` because it is
|
|
// no a real fixture.
|
|
//
|
|
// See https://github.com/emil-e/rapidcheck/blob/master/doc/gtest.md#rc_gtest_fixture_propfixture-name-args
|
|
TEST_F(DerivedPathExpressionTest, force_init)
|
|
{
|
|
}
|
|
|
|
#ifndef COVERAGE
|
|
|
|
RC_GTEST_FIXTURE_PROP(
|
|
DerivedPathExpressionTest,
|
|
prop_opaque_path_round_trip,
|
|
(const SingleDerivedPath::Opaque & o))
|
|
{
|
|
auto * v = state.allocValue();
|
|
state.mkStorePathString(o.path, *v);
|
|
auto d = state.coerceToSingleDerivedPath(noPos, *v, "");
|
|
RC_ASSERT(SingleDerivedPath { o } == d);
|
|
}
|
|
|
|
// TODO use DerivedPath::Built for parameter once it supports a single output
|
|
// path only.
|
|
|
|
RC_GTEST_FIXTURE_PROP(
|
|
DerivedPathExpressionTest,
|
|
prop_derived_path_built_placeholder_round_trip,
|
|
(const SingleDerivedPath::Built & b))
|
|
{
|
|
/**
|
|
* We set these in tests rather than the regular globals so we don't have
|
|
* to worry about race conditions if the tests run concurrently.
|
|
*/
|
|
ExperimentalFeatureSettings mockXpSettings;
|
|
mockXpSettings.set("experimental-features", "ca-derivations dynamic-derivations");
|
|
|
|
auto * v = state.allocValue();
|
|
state.mkOutputString(*v, b, std::nullopt, mockXpSettings);
|
|
auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, *v, "", mockXpSettings);
|
|
RC_ASSERT(SingleDerivedPath { b } == d);
|
|
}
|
|
|
|
RC_GTEST_FIXTURE_PROP(
|
|
DerivedPathExpressionTest,
|
|
prop_derived_path_built_out_path_round_trip,
|
|
(const SingleDerivedPath::Built & b, const StorePath & outPath))
|
|
{
|
|
ExperimentalFeatureSettings mockXpSettings;
|
|
mockXpSettings.set("experimental-features", "dynamic-derivations");
|
|
|
|
auto * v = state.allocValue();
|
|
state.mkOutputString(*v, b, outPath, mockXpSettings);
|
|
auto [d, _] = state.coerceToSingleDerivedPathUnchecked(noPos, *v, "", mockXpSettings);
|
|
RC_ASSERT(SingleDerivedPath { b } == d);
|
|
}
|
|
|
|
#endif
|
|
|
|
} /* namespace nix */
|