2023-02-19 18:11:20 +02:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
#include "experimental-features.hh"
|
2023-02-19 18:11:20 +02:00
|
|
|
#include "derivations.hh"
|
|
|
|
|
|
|
|
#include "tests/libstore.hh"
|
2023-10-27 00:58:45 +03:00
|
|
|
#include "tests/characterization.hh"
|
2023-02-19 18:11:20 +02:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
|
2023-10-27 00:58:45 +03:00
|
|
|
using nlohmann::json;
|
|
|
|
|
2023-11-01 17:15:21 +02:00
|
|
|
class DerivationTest : public CharacterizationTest, public LibStoreTest
|
2023-02-19 18:11:20 +02:00
|
|
|
{
|
2023-08-25 17:20:28 +03:00
|
|
|
Path unitTestData = getUnitTestData() + "/derivation";
|
2023-11-01 17:15:21 +02:00
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
public:
|
2023-11-01 17:15:21 +02:00
|
|
|
Path goldenMaster(std::string_view testStem) const override {
|
|
|
|
return unitTestData + "/" + testStem;
|
|
|
|
}
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
/**
|
|
|
|
* 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;
|
2023-02-19 18:11:20 +02:00
|
|
|
};
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
class CaDerivationTest : public DerivationTest
|
|
|
|
{
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
mockXpSettings.set("experimental-features", "ca-derivations");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-19 18:33:48 +03:00
|
|
|
class DynDerivationTest : public DerivationTest
|
|
|
|
{
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
mockXpSettings.set("experimental-features", "dynamic-derivations ca-derivations");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
class ImpureDerivationTest : public DerivationTest
|
|
|
|
{
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
mockXpSettings.set("experimental-features", "impure-derivations");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
TEST_F(DerivationTest, BadATerm_version) {
|
|
|
|
ASSERT_THROW(
|
|
|
|
parseDerivation(
|
|
|
|
*store,
|
2023-10-27 00:58:45 +03:00
|
|
|
readFile(goldenMaster("bad-version.drv")),
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
"whatever",
|
|
|
|
mockXpSettings),
|
|
|
|
FormatError);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(DynDerivationTest, BadATerm_oldVersionDynDeps) {
|
|
|
|
ASSERT_THROW(
|
|
|
|
parseDerivation(
|
|
|
|
*store,
|
2023-10-27 00:58:45 +03:00
|
|
|
readFile(goldenMaster("bad-old-version-dyn-deps.drv")),
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
"dyn-dep-derivation",
|
|
|
|
mockXpSettings),
|
|
|
|
FormatError);
|
|
|
|
}
|
|
|
|
|
2023-10-27 00:58:45 +03:00
|
|
|
#define TEST_JSON(FIXTURE, NAME, VAL, DRV_NAME, OUTPUT_NAME) \
|
|
|
|
TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _from_json) { \
|
2023-11-01 17:15:21 +02:00
|
|
|
readTest("output-" #NAME ".json", [&](const auto & encoded_) { \
|
|
|
|
auto encoded = json::parse(encoded_); \
|
2023-10-27 00:58:45 +03:00
|
|
|
DerivationOutput got = DerivationOutput::fromJSON( \
|
|
|
|
*store, \
|
|
|
|
DRV_NAME, \
|
|
|
|
OUTPUT_NAME, \
|
|
|
|
encoded, \
|
|
|
|
mockXpSettings); \
|
|
|
|
DerivationOutput expected { VAL }; \
|
|
|
|
ASSERT_EQ(got, expected); \
|
2023-11-01 17:15:21 +02:00
|
|
|
}); \
|
2023-10-27 00:58:45 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _to_json) { \
|
2023-11-01 22:11:20 +02:00
|
|
|
writeTest("output-" #NAME ".json", [&]() -> json { \
|
2023-11-01 17:15:21 +02:00
|
|
|
return DerivationOutput { (VAL) }.toJSON( \
|
|
|
|
*store, \
|
|
|
|
(DRV_NAME), \
|
|
|
|
(OUTPUT_NAME)); \
|
|
|
|
}, [](const auto & file) { \
|
|
|
|
return json::parse(readFile(file)); \
|
|
|
|
}, [](const auto & file, const auto & got) { \
|
|
|
|
return writeFile(file, got.dump(2) + "\n"); \
|
|
|
|
}); \
|
2023-02-19 18:11:20 +02:00
|
|
|
}
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
TEST_JSON(DerivationTest, inputAddressed,
|
2023-02-19 18:11:20 +02:00
|
|
|
(DerivationOutput::InputAddressed {
|
|
|
|
.path = store->parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-drv-name-output-name"),
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-19 21:48:53 +03:00
|
|
|
TEST_JSON(DerivationTest, caFixedFlat,
|
|
|
|
(DerivationOutput::CAFixed {
|
2023-07-06 01:53:44 +03:00
|
|
|
.ca = {
|
2023-04-19 21:48:53 +03:00
|
|
|
.method = FileIngestionMethod::Flat,
|
|
|
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
|
|
|
TEST_JSON(DerivationTest, caFixedNAR,
|
2023-02-19 18:11:20 +02:00
|
|
|
(DerivationOutput::CAFixed {
|
2023-07-06 01:53:44 +03:00
|
|
|
.ca = {
|
2023-04-19 21:48:53 +03:00
|
|
|
.method = FileIngestionMethod::Recursive,
|
|
|
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
2023-02-28 19:46:00 +02:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-19 18:33:48 +03:00
|
|
|
TEST_JSON(DynDerivationTest, caFixedText,
|
2023-02-28 19:46:00 +02:00
|
|
|
(DerivationOutput::CAFixed {
|
2023-07-06 01:53:44 +03:00
|
|
|
.ca = {
|
2023-04-19 21:48:53 +03:00
|
|
|
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
2023-02-19 18:11:20 +02:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
TEST_JSON(CaDerivationTest, caFloating,
|
2023-02-19 18:11:20 +02:00
|
|
|
(DerivationOutput::CAFloating {
|
|
|
|
.method = FileIngestionMethod::Recursive,
|
2023-11-28 15:20:27 +02:00
|
|
|
.hashAlgo = HashAlgorithm::SHA256,
|
2023-02-19 18:11:20 +02:00
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
TEST_JSON(DerivationTest, deferred,
|
2023-02-19 18:11:20 +02:00
|
|
|
DerivationOutput::Deferred { },
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-04-17 18:22:31 +03:00
|
|
|
TEST_JSON(ImpureDerivationTest, impure,
|
2023-02-19 18:11:20 +02:00
|
|
|
(DerivationOutput::Impure {
|
|
|
|
.method = FileIngestionMethod::Recursive,
|
2023-11-28 15:20:27 +02:00
|
|
|
.hashAlgo = HashAlgorithm::SHA256,
|
2023-02-19 18:11:20 +02:00
|
|
|
}),
|
|
|
|
"drv-name", "output-name")
|
|
|
|
|
2023-02-18 01:37:35 +02:00
|
|
|
#undef TEST_JSON
|
|
|
|
|
2023-10-27 00:58:45 +03:00
|
|
|
#define TEST_JSON(FIXTURE, NAME, VAL) \
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _from_json) { \
|
2023-11-01 17:15:21 +02:00
|
|
|
readTest(#NAME ".json", [&](const auto & encoded_) { \
|
|
|
|
auto encoded = json::parse(encoded_); \
|
2023-10-27 00:58:45 +03:00
|
|
|
Derivation expected { VAL }; \
|
|
|
|
Derivation got = Derivation::fromJSON( \
|
|
|
|
*store, \
|
|
|
|
encoded, \
|
|
|
|
mockXpSettings); \
|
|
|
|
ASSERT_EQ(got, expected); \
|
2023-11-01 17:15:21 +02:00
|
|
|
}); \
|
2023-10-27 00:58:45 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _to_json) { \
|
2023-11-01 22:11:20 +02:00
|
|
|
writeTest(#NAME ".json", [&]() -> json { \
|
2023-11-01 17:15:21 +02:00
|
|
|
return Derivation { VAL }.toJSON(*store); \
|
|
|
|
}, [](const auto & file) { \
|
|
|
|
return json::parse(readFile(file)); \
|
|
|
|
}, [](const auto & file, const auto & got) { \
|
|
|
|
return writeFile(file, got.dump(2) + "\n"); \
|
|
|
|
}); \
|
2023-02-18 01:37:35 +02:00
|
|
|
}
|
|
|
|
|
2023-10-27 00:58:45 +03:00
|
|
|
#define TEST_ATERM(FIXTURE, NAME, VAL, DRV_NAME) \
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _from_aterm) { \
|
2023-11-01 17:15:21 +02:00
|
|
|
readTest(#NAME ".drv", [&](auto encoded) { \
|
2023-10-27 00:58:45 +03:00
|
|
|
Derivation expected { VAL }; \
|
|
|
|
auto got = parseDerivation( \
|
|
|
|
*store, \
|
|
|
|
std::move(encoded), \
|
|
|
|
DRV_NAME, \
|
|
|
|
mockXpSettings); \
|
|
|
|
ASSERT_EQ(got.toJSON(*store), expected.toJSON(*store)) ; \
|
|
|
|
ASSERT_EQ(got, expected); \
|
2023-11-01 17:15:21 +02:00
|
|
|
}); \
|
2023-10-27 00:58:45 +03:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
TEST_F(FIXTURE, Derivation_ ## NAME ## _to_aterm) { \
|
2023-11-01 17:15:21 +02:00
|
|
|
writeTest(#NAME ".drv", [&]() -> std::string { \
|
|
|
|
return (VAL).unparse(*store, false); \
|
|
|
|
}); \
|
2023-09-05 18:16:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Derivation makeSimpleDrv(const Store & store) {
|
|
|
|
Derivation drv;
|
|
|
|
drv.name = "simple-derivation";
|
|
|
|
drv.inputSrcs = {
|
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
|
|
|
|
};
|
|
|
|
drv.inputDrvs = {
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
.map = {
|
2023-09-05 18:16:39 +03:00
|
|
|
{
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
|
|
|
{
|
|
|
|
.value = {
|
|
|
|
"cat",
|
|
|
|
"dog",
|
|
|
|
},
|
|
|
|
},
|
2023-09-05 18:16:39 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
drv.platform = "wasm-sel4";
|
|
|
|
drv.builder = "foo";
|
|
|
|
drv.args = {
|
|
|
|
"bar",
|
|
|
|
"baz",
|
|
|
|
};
|
|
|
|
drv.env = {
|
|
|
|
{
|
|
|
|
"BIG_BAD",
|
|
|
|
"WOLF",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
2023-10-27 00:58:45 +03:00
|
|
|
TEST_JSON(DerivationTest, simple, makeSimpleDrv(*store))
|
2023-09-05 18:16:39 +03:00
|
|
|
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
TEST_ATERM(DerivationTest, simple,
|
2023-09-05 18:16:39 +03:00
|
|
|
makeSimpleDrv(*store),
|
|
|
|
"simple-derivation")
|
2023-02-19 18:11:20 +02:00
|
|
|
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
Derivation makeDynDepDerivation(const Store & store) {
|
|
|
|
Derivation drv;
|
|
|
|
drv.name = "dyn-dep-derivation";
|
|
|
|
drv.inputSrcs = {
|
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
|
|
|
|
};
|
|
|
|
drv.inputDrvs = {
|
|
|
|
.map = {
|
|
|
|
{
|
|
|
|
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
|
|
|
DerivedPathMap<StringSet>::ChildNode {
|
|
|
|
.value = {
|
|
|
|
"cat",
|
|
|
|
"dog",
|
|
|
|
},
|
|
|
|
.childMap = {
|
|
|
|
{
|
|
|
|
"cat",
|
|
|
|
DerivedPathMap<StringSet>::ChildNode {
|
|
|
|
.value = {
|
|
|
|
"kitten",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"goose",
|
|
|
|
DerivedPathMap<StringSet>::ChildNode {
|
|
|
|
.value = {
|
|
|
|
"gosling",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
drv.platform = "wasm-sel4";
|
|
|
|
drv.builder = "foo";
|
|
|
|
drv.args = {
|
|
|
|
"bar",
|
|
|
|
"baz",
|
|
|
|
};
|
|
|
|
drv.env = {
|
|
|
|
{
|
|
|
|
"BIG_BAD",
|
|
|
|
"WOLF",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
return drv;
|
|
|
|
}
|
|
|
|
|
2023-10-27 00:58:45 +03:00
|
|
|
TEST_JSON(DynDerivationTest, dynDerivationDeps, makeDynDepDerivation(*store))
|
Allow dynamic derivation deps in `inputDrvs`
We use the same nested map representation we used for goals, again in
order to save space. We might someday want to combine with `inputDrvs`,
by doing `V = bool` instead of `V = std::set<OutputName>`, but we are
not doing that yet for sake of a smaller diff.
The ATerm format for Derivations also needs to be extended, in addition
to the in-memory format. To accomodate this, we added a new basic
versioning scheme, so old versions of Nix will get nice errors. (And
going forward, if the ATerm format changes again the errors will be even
better.)
`parsedStrings`, an internal function used as part of parsing
derivations in A-Term format, used to consume the final `]` but expect
the initial `[` to already be consumed. This made for what looked like
unbalanced brackets at callsites, which was confusing. Now it consumes
both which is hopefully less confusing.
As part of testing, we also created a unit test for the A-Term format for
regular non-experimental derivations too.
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Apply suggestions from code review
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2021-10-02 01:05:53 +03:00
|
|
|
|
|
|
|
TEST_ATERM(DynDerivationTest, dynDerivationDeps,
|
|
|
|
makeDynDepDerivation(*store),
|
|
|
|
"dyn-dep-derivation")
|
|
|
|
|
2023-02-19 18:11:20 +02:00
|
|
|
#undef TEST_JSON
|
2023-09-05 18:16:39 +03:00
|
|
|
#undef TEST_ATERM
|
2023-02-19 18:11:20 +02:00
|
|
|
|
|
|
|
}
|