mirror of
https://github.com/NixOS/nix.git
synced 2025-11-14 22:42:41 +01:00
Apply clang-format universally.
* It is tough to contribute to a project that doesn't use a formatter, * It is extra hard to contribute to a project which has configured the formatter, but ignores it for some files * Code formatting makes it harder to hide obscure / weird bugs by accident or on purpose, Let's rip the bandaid off? Note that PRs currently in flight should be able to be merged relatively easily by applying `clang-format` to their tip prior to merge.
This commit is contained in:
parent
41bf87ec70
commit
e4f62e4608
587 changed files with 23258 additions and 23135 deletions
|
|
@ -24,10 +24,8 @@ public:
|
|||
{
|
||||
CharacterizationTest::readTest(testStem, [&](const auto & encoded) {
|
||||
T got = ({
|
||||
StringSource from { encoded };
|
||||
CommonProto::Serialise<T>::read(
|
||||
*store,
|
||||
CommonProto::ReadConn { .from = from });
|
||||
StringSource from{encoded};
|
||||
CommonProto::Serialise<T>::read(*store, CommonProto::ReadConn{.from = from});
|
||||
});
|
||||
|
||||
ASSERT_EQ(got, expected);
|
||||
|
|
@ -42,27 +40,26 @@ public:
|
|||
{
|
||||
CharacterizationTest::writeTest(testStem, [&]() -> std::string {
|
||||
StringSink to;
|
||||
CommonProto::Serialise<T>::write(
|
||||
*store,
|
||||
CommonProto::WriteConn { .to = to },
|
||||
decoded);
|
||||
CommonProto::Serialise<T>::write(*store, CommonProto::WriteConn{.to = to}, decoded);
|
||||
return to.s;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
#define CHARACTERIZATION_TEST(NAME, STEM, VALUE) \
|
||||
TEST_F(CommonProtoTest, NAME ## _read) { \
|
||||
readProtoTest(STEM, VALUE); \
|
||||
} \
|
||||
TEST_F(CommonProtoTest, NAME ## _write) { \
|
||||
writeProtoTest(STEM, VALUE); \
|
||||
TEST_F(CommonProtoTest, NAME##_read) \
|
||||
{ \
|
||||
readProtoTest(STEM, VALUE); \
|
||||
} \
|
||||
TEST_F(CommonProtoTest, NAME##_write) \
|
||||
{ \
|
||||
writeProtoTest(STEM, VALUE); \
|
||||
}
|
||||
|
||||
CHARACTERIZATION_TEST(
|
||||
string,
|
||||
"string",
|
||||
(std::tuple<std::string, std::string, std::string, std::string, std::string> {
|
||||
(std::tuple<std::string, std::string, std::string, std::string, std::string>{
|
||||
"",
|
||||
"hi",
|
||||
"white rabbit",
|
||||
|
|
@ -73,24 +70,24 @@ CHARACTERIZATION_TEST(
|
|||
CHARACTERIZATION_TEST(
|
||||
storePath,
|
||||
"store-path",
|
||||
(std::tuple<StorePath, StorePath> {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
|
||||
(std::tuple<StorePath, StorePath>{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"},
|
||||
}))
|
||||
|
||||
CHARACTERIZATION_TEST(
|
||||
contentAddress,
|
||||
"content-address",
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
|
||||
ContentAddress {
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress>{
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "Derive(...)"),
|
||||
},
|
||||
ContentAddress {
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
ContentAddress {
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
},
|
||||
|
|
@ -99,12 +96,12 @@ CHARACTERIZATION_TEST(
|
|||
CHARACTERIZATION_TEST(
|
||||
drvOutput,
|
||||
"drv-output",
|
||||
(std::tuple<DrvOutput, DrvOutput> {
|
||||
(std::tuple<DrvOutput, DrvOutput>{
|
||||
{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
DrvOutput {
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
|
|
@ -113,75 +110,82 @@ CHARACTERIZATION_TEST(
|
|||
CHARACTERIZATION_TEST(
|
||||
realisation,
|
||||
"realisation",
|
||||
(std::tuple<Realisation, Realisation> {
|
||||
Realisation {
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.signatures = { "asdf", "qwer" },
|
||||
},
|
||||
Realisation {
|
||||
.id = {
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.signatures = { "asdf", "qwer" },
|
||||
.dependentRealisations = {
|
||||
{
|
||||
DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
(std::tuple<Realisation, Realisation>{
|
||||
Realisation{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
.signatures = {"asdf", "qwer"},
|
||||
},
|
||||
Realisation{
|
||||
.id =
|
||||
{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
.signatures = {"asdf", "qwer"},
|
||||
.dependentRealisations =
|
||||
{
|
||||
{
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
CHARACTERIZATION_TEST(
|
||||
vector,
|
||||
"vector",
|
||||
(std::tuple<std::vector<std::string>, std::vector<std::string>, std::vector<std::string>, std::vector<std::vector<std::string>>> {
|
||||
{ },
|
||||
{ "" },
|
||||
{ "", "foo", "bar" },
|
||||
{ {}, { "" }, { "", "1", "2" } },
|
||||
(std::tuple<
|
||||
std::vector<std::string>,
|
||||
std::vector<std::string>,
|
||||
std::vector<std::string>,
|
||||
std::vector<std::vector<std::string>>>{
|
||||
{},
|
||||
{""},
|
||||
{"", "foo", "bar"},
|
||||
{{}, {""}, {"", "1", "2"}},
|
||||
}))
|
||||
|
||||
CHARACTERIZATION_TEST(
|
||||
set,
|
||||
"set",
|
||||
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>> {
|
||||
{ },
|
||||
{ "" },
|
||||
{ "", "foo", "bar" },
|
||||
{ {}, { "" }, { "", "1", "2" } },
|
||||
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>>{
|
||||
{},
|
||||
{""},
|
||||
{"", "foo", "bar"},
|
||||
{{}, {""}, {"", "1", "2"}},
|
||||
}))
|
||||
|
||||
CHARACTERIZATION_TEST(
|
||||
optionalStorePath,
|
||||
"optional-store-path",
|
||||
(std::tuple<std::optional<StorePath>, std::optional<StorePath>> {
|
||||
(std::tuple<std::optional<StorePath>, std::optional<StorePath>>{
|
||||
std::nullopt,
|
||||
std::optional {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
|
||||
std::optional{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"},
|
||||
},
|
||||
}))
|
||||
|
||||
CHARACTERIZATION_TEST(
|
||||
optionalContentAddress,
|
||||
"optional-content-address",
|
||||
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>> {
|
||||
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>>{
|
||||
std::nullopt,
|
||||
std::optional {
|
||||
ContentAddress {
|
||||
std::optional{
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -8,30 +8,33 @@ namespace nix {
|
|||
* ContentAddressMethod::parse, ContentAddressMethod::render
|
||||
* --------------------------------------------------------------------------*/
|
||||
|
||||
TEST(ContentAddressMethod, testRoundTripPrintParse_1) {
|
||||
TEST(ContentAddressMethod, testRoundTripPrintParse_1)
|
||||
{
|
||||
for (ContentAddressMethod cam : {
|
||||
ContentAddressMethod::Raw::Text,
|
||||
ContentAddressMethod::Raw::Flat,
|
||||
ContentAddressMethod::Raw::NixArchive,
|
||||
ContentAddressMethod::Raw::Git,
|
||||
}) {
|
||||
ContentAddressMethod::Raw::Text,
|
||||
ContentAddressMethod::Raw::Flat,
|
||||
ContentAddressMethod::Raw::NixArchive,
|
||||
ContentAddressMethod::Raw::Git,
|
||||
}) {
|
||||
EXPECT_EQ(ContentAddressMethod::parse(cam.render()), cam);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ContentAddressMethod, testRoundTripPrintParse_2) {
|
||||
TEST(ContentAddressMethod, testRoundTripPrintParse_2)
|
||||
{
|
||||
for (const std::string_view camS : {
|
||||
"text",
|
||||
"flat",
|
||||
"nar",
|
||||
"git",
|
||||
}) {
|
||||
"text",
|
||||
"flat",
|
||||
"nar",
|
||||
"git",
|
||||
}) {
|
||||
EXPECT_EQ(ContentAddressMethod::parse(camS).render(), camS);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ContentAddressMethod, testParseContentAddressMethodOptException) {
|
||||
TEST(ContentAddressMethod, testParseContentAddressMethodOptException)
|
||||
{
|
||||
EXPECT_THROW(ContentAddressMethod::parse("narwhal"), UsageError);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -497,4 +497,4 @@ TEST_F(CaDerivationAdvancedAttrsTest, advancedAttributes_structuredAttrs)
|
|||
});
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@ class DerivationTest : public CharacterizationTest, public LibStoreTest
|
|||
std::filesystem::path unitTestData = getUnitTestData() / "derivation";
|
||||
|
||||
public:
|
||||
std::filesystem::path goldenMaster(std::string_view testStem) const override {
|
||||
std::filesystem::path goldenMaster(std::string_view testStem) const override
|
||||
{
|
||||
return unitTestData / testStem;
|
||||
}
|
||||
|
||||
|
|
@ -51,168 +52,169 @@ class ImpureDerivationTest : public DerivationTest
|
|||
}
|
||||
};
|
||||
|
||||
TEST_F(DerivationTest, BadATerm_version) {
|
||||
TEST_F(DerivationTest, BadATerm_version)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
parseDerivation(*store, readFile(goldenMaster("bad-version.drv")), "whatever", mockXpSettings), FormatError);
|
||||
}
|
||||
|
||||
TEST_F(DynDerivationTest, BadATerm_oldVersionDynDeps)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
parseDerivation(
|
||||
*store,
|
||||
readFile(goldenMaster("bad-version.drv")),
|
||||
"whatever",
|
||||
mockXpSettings),
|
||||
*store, readFile(goldenMaster("bad-old-version-dyn-deps.drv")), "dyn-dep-derivation", mockXpSettings),
|
||||
FormatError);
|
||||
}
|
||||
|
||||
TEST_F(DynDerivationTest, BadATerm_oldVersionDynDeps) {
|
||||
ASSERT_THROW(
|
||||
parseDerivation(
|
||||
*store,
|
||||
readFile(goldenMaster("bad-old-version-dyn-deps.drv")),
|
||||
"dyn-dep-derivation",
|
||||
mockXpSettings),
|
||||
FormatError);
|
||||
}
|
||||
|
||||
#define TEST_JSON(FIXTURE, NAME, VAL, DRV_NAME, OUTPUT_NAME) \
|
||||
TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _from_json) { \
|
||||
readTest("output-" #NAME ".json", [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
DerivationOutput got = DerivationOutput::fromJSON( \
|
||||
*store, \
|
||||
DRV_NAME, \
|
||||
OUTPUT_NAME, \
|
||||
encoded, \
|
||||
mockXpSettings); \
|
||||
DerivationOutput expected { VAL }; \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(FIXTURE, DerivationOutput_ ## NAME ## _to_json) { \
|
||||
writeTest("output-" #NAME ".json", [&]() -> json { \
|
||||
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"); \
|
||||
}); \
|
||||
#define TEST_JSON(FIXTURE, NAME, VAL, DRV_NAME, OUTPUT_NAME) \
|
||||
TEST_F(FIXTURE, DerivationOutput_##NAME##_from_json) \
|
||||
{ \
|
||||
readTest("output-" #NAME ".json", [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
DerivationOutput got = DerivationOutput::fromJSON(*store, DRV_NAME, OUTPUT_NAME, encoded, mockXpSettings); \
|
||||
DerivationOutput expected{VAL}; \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(FIXTURE, DerivationOutput_##NAME##_to_json) \
|
||||
{ \
|
||||
writeTest( \
|
||||
"output-" #NAME ".json", \
|
||||
[&]() -> json { 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"); }); \
|
||||
}
|
||||
|
||||
TEST_JSON(DerivationTest, inputAddressed,
|
||||
(DerivationOutput::InputAddressed {
|
||||
TEST_JSON(
|
||||
DerivationTest,
|
||||
inputAddressed,
|
||||
(DerivationOutput::InputAddressed{
|
||||
.path = store->parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-drv-name-output-name"),
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
"drv-name",
|
||||
"output-name")
|
||||
|
||||
TEST_JSON(DerivationTest, caFixedFlat,
|
||||
(DerivationOutput::CAFixed {
|
||||
.ca = {
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
TEST_JSON(
|
||||
DerivationTest,
|
||||
caFixedFlat,
|
||||
(DerivationOutput::CAFixed{
|
||||
.ca =
|
||||
{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
"drv-name",
|
||||
"output-name")
|
||||
|
||||
TEST_JSON(DerivationTest, caFixedNAR,
|
||||
(DerivationOutput::CAFixed {
|
||||
.ca = {
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
TEST_JSON(
|
||||
DerivationTest,
|
||||
caFixedNAR,
|
||||
(DerivationOutput::CAFixed{
|
||||
.ca =
|
||||
{
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
"drv-name",
|
||||
"output-name")
|
||||
|
||||
TEST_JSON(DynDerivationTest, caFixedText,
|
||||
(DerivationOutput::CAFixed {
|
||||
.ca = {
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
TEST_JSON(
|
||||
DynDerivationTest,
|
||||
caFixedText,
|
||||
(DerivationOutput::CAFixed{
|
||||
.ca =
|
||||
{
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = Hash::parseAnyPrefixed("sha256-iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="),
|
||||
},
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
"drv-name",
|
||||
"output-name")
|
||||
|
||||
TEST_JSON(CaDerivationTest, caFloating,
|
||||
(DerivationOutput::CAFloating {
|
||||
TEST_JSON(
|
||||
CaDerivationTest,
|
||||
caFloating,
|
||||
(DerivationOutput::CAFloating{
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hashAlgo = HashAlgorithm::SHA256,
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
"drv-name",
|
||||
"output-name")
|
||||
|
||||
TEST_JSON(DerivationTest, deferred,
|
||||
DerivationOutput::Deferred { },
|
||||
"drv-name", "output-name")
|
||||
TEST_JSON(DerivationTest, deferred, DerivationOutput::Deferred{}, "drv-name", "output-name")
|
||||
|
||||
TEST_JSON(ImpureDerivationTest, impure,
|
||||
(DerivationOutput::Impure {
|
||||
TEST_JSON(
|
||||
ImpureDerivationTest,
|
||||
impure,
|
||||
(DerivationOutput::Impure{
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hashAlgo = HashAlgorithm::SHA256,
|
||||
}),
|
||||
"drv-name", "output-name")
|
||||
"drv-name",
|
||||
"output-name")
|
||||
|
||||
#undef TEST_JSON
|
||||
|
||||
#define TEST_JSON(FIXTURE, NAME, VAL) \
|
||||
TEST_F(FIXTURE, Derivation_ ## NAME ## _from_json) { \
|
||||
readTest(#NAME ".json", [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
Derivation expected { VAL }; \
|
||||
Derivation got = Derivation::fromJSON( \
|
||||
*store, \
|
||||
encoded, \
|
||||
mockXpSettings); \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(FIXTURE, Derivation_ ## NAME ## _to_json) { \
|
||||
writeTest(#NAME ".json", [&]() -> json { \
|
||||
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"); \
|
||||
}); \
|
||||
#define TEST_JSON(FIXTURE, NAME, VAL) \
|
||||
TEST_F(FIXTURE, Derivation_##NAME##_from_json) \
|
||||
{ \
|
||||
readTest(#NAME ".json", [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
Derivation expected{VAL}; \
|
||||
Derivation got = Derivation::fromJSON(*store, encoded, mockXpSettings); \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(FIXTURE, Derivation_##NAME##_to_json) \
|
||||
{ \
|
||||
writeTest( \
|
||||
#NAME ".json", \
|
||||
[&]() -> json { 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"); }); \
|
||||
}
|
||||
|
||||
#define TEST_ATERM(FIXTURE, NAME, VAL, DRV_NAME) \
|
||||
TEST_F(FIXTURE, Derivation_ ## NAME ## _from_aterm) { \
|
||||
readTest(#NAME ".drv", [&](auto encoded) { \
|
||||
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); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(FIXTURE, Derivation_ ## NAME ## _to_aterm) { \
|
||||
writeTest(#NAME ".drv", [&]() -> std::string { \
|
||||
return (VAL).unparse(*store, false); \
|
||||
}); \
|
||||
#define TEST_ATERM(FIXTURE, NAME, VAL, DRV_NAME) \
|
||||
TEST_F(FIXTURE, Derivation_##NAME##_from_aterm) \
|
||||
{ \
|
||||
readTest(#NAME ".drv", [&](auto encoded) { \
|
||||
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); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(FIXTURE, Derivation_##NAME##_to_aterm) \
|
||||
{ \
|
||||
writeTest(#NAME ".drv", [&]() -> std::string { return (VAL).unparse(*store, false); }); \
|
||||
}
|
||||
|
||||
Derivation makeSimpleDrv(const Store & store) {
|
||||
Derivation makeSimpleDrv(const Store & store)
|
||||
{
|
||||
Derivation drv;
|
||||
drv.name = "simple-derivation";
|
||||
drv.inputSrcs = {
|
||||
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
|
||||
};
|
||||
drv.inputDrvs = {
|
||||
.map = {
|
||||
.map =
|
||||
{
|
||||
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
||||
{
|
||||
.value = {
|
||||
"cat",
|
||||
"dog",
|
||||
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
||||
{
|
||||
.value =
|
||||
{
|
||||
"cat",
|
||||
"dog",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
drv.platform = "wasm-sel4";
|
||||
drv.builder = "foo";
|
||||
|
|
@ -231,46 +233,50 @@ Derivation makeSimpleDrv(const Store & store) {
|
|||
|
||||
TEST_JSON(DerivationTest, simple, makeSimpleDrv(*store))
|
||||
|
||||
TEST_ATERM(DerivationTest, simple,
|
||||
makeSimpleDrv(*store),
|
||||
"simple-derivation")
|
||||
TEST_ATERM(DerivationTest, simple, makeSimpleDrv(*store), "simple-derivation")
|
||||
|
||||
Derivation makeDynDepDerivation(const Store & store) {
|
||||
Derivation makeDynDepDerivation(const Store & store)
|
||||
{
|
||||
Derivation drv;
|
||||
drv.name = "dyn-dep-derivation";
|
||||
drv.inputSrcs = {
|
||||
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
|
||||
};
|
||||
drv.inputDrvs = {
|
||||
.map = {
|
||||
.map =
|
||||
{
|
||||
store.parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep2.drv"),
|
||||
DerivedPathMap<StringSet>::ChildNode {
|
||||
.value = {
|
||||
"cat",
|
||||
"dog",
|
||||
},
|
||||
.childMap = {
|
||||
{
|
||||
"cat",
|
||||
DerivedPathMap<StringSet>::ChildNode {
|
||||
.value = {
|
||||
"kitten",
|
||||
{
|
||||
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",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"goose",
|
||||
DerivedPathMap<StringSet>::ChildNode {
|
||||
.value = {
|
||||
"gosling",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
drv.platform = "wasm-sel4";
|
||||
drv.builder = "foo";
|
||||
|
|
@ -289,11 +295,9 @@ Derivation makeDynDepDerivation(const Store & store) {
|
|||
|
||||
TEST_JSON(DynDerivationTest, dynDerivationDeps, makeDynDepDerivation(*store))
|
||||
|
||||
TEST_ATERM(DynDerivationTest, dynDerivationDeps,
|
||||
makeDynDepDerivation(*store),
|
||||
"dyn-dep-derivation")
|
||||
TEST_ATERM(DynDerivationTest, dynDerivationDeps, makeDynDepDerivation(*store), "dyn-dep-derivation")
|
||||
|
||||
#undef TEST_JSON
|
||||
#undef TEST_ATERM
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@
|
|||
namespace nix {
|
||||
|
||||
class DerivedPathTest : public LibStoreTest
|
||||
{
|
||||
};
|
||||
{};
|
||||
|
||||
/**
|
||||
* Round trip (string <-> data structure) test for
|
||||
* `DerivedPath::Opaque`.
|
||||
*/
|
||||
TEST_F(DerivedPathTest, opaque) {
|
||||
TEST_F(DerivedPathTest, opaque)
|
||||
{
|
||||
std::string_view opaque = "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x";
|
||||
auto elem = DerivedPath::parse(*store, opaque);
|
||||
auto * p = std::get_if<DerivedPath::Opaque>(&elem);
|
||||
|
|
@ -29,15 +29,18 @@ TEST_F(DerivedPathTest, opaque) {
|
|||
* Round trip (string <-> data structure) test for a simpler
|
||||
* `DerivedPath::Built`.
|
||||
*/
|
||||
TEST_F(DerivedPathTest, built_opaque) {
|
||||
TEST_F(DerivedPathTest, built_opaque)
|
||||
{
|
||||
std::string_view built = "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x.drv^bar,foo";
|
||||
auto elem = DerivedPath::parse(*store, built);
|
||||
auto * p = std::get_if<DerivedPath::Built>(&elem);
|
||||
ASSERT_TRUE(p);
|
||||
ASSERT_EQ(p->outputs, ((OutputsSpec) OutputsSpec::Names { "foo", "bar" }));
|
||||
ASSERT_EQ(*p->drvPath, ((SingleDerivedPath) SingleDerivedPath::Opaque {
|
||||
.path = store->parseStorePath(built.substr(0, 49)),
|
||||
}));
|
||||
ASSERT_EQ(p->outputs, ((OutputsSpec) OutputsSpec::Names{"foo", "bar"}));
|
||||
ASSERT_EQ(
|
||||
*p->drvPath,
|
||||
((SingleDerivedPath) SingleDerivedPath::Opaque{
|
||||
.path = store->parseStorePath(built.substr(0, 49)),
|
||||
}));
|
||||
ASSERT_EQ(elem.to_string(*store), built);
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +48,8 @@ TEST_F(DerivedPathTest, built_opaque) {
|
|||
* Round trip (string <-> data structure) test for a more complex,
|
||||
* inductive `DerivedPath::Built`.
|
||||
*/
|
||||
TEST_F(DerivedPathTest, built_built) {
|
||||
TEST_F(DerivedPathTest, built_built)
|
||||
{
|
||||
/**
|
||||
* 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.
|
||||
|
|
@ -57,13 +61,15 @@ TEST_F(DerivedPathTest, built_built) {
|
|||
auto elem = DerivedPath::parse(*store, built, mockXpSettings);
|
||||
auto * p = std::get_if<DerivedPath::Built>(&elem);
|
||||
ASSERT_TRUE(p);
|
||||
ASSERT_EQ(p->outputs, ((OutputsSpec) OutputsSpec::Names { "bar", "baz" }));
|
||||
ASSERT_EQ(p->outputs, ((OutputsSpec) OutputsSpec::Names{"bar", "baz"}));
|
||||
auto * drvPath = std::get_if<SingleDerivedPath::Built>(&*p->drvPath);
|
||||
ASSERT_TRUE(drvPath);
|
||||
ASSERT_EQ(drvPath->output, "foo");
|
||||
ASSERT_EQ(*drvPath->drvPath, ((SingleDerivedPath) SingleDerivedPath::Opaque {
|
||||
.path = store->parseStorePath(built.substr(0, 49)),
|
||||
}));
|
||||
ASSERT_EQ(
|
||||
*drvPath->drvPath,
|
||||
((SingleDerivedPath) SingleDerivedPath::Opaque{
|
||||
.path = store->parseStorePath(built.substr(0, 49)),
|
||||
}));
|
||||
ASSERT_EQ(elem.to_string(*store), built);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +77,8 @@ TEST_F(DerivedPathTest, built_built) {
|
|||
* Without the right experimental features enabled, we cannot parse a
|
||||
* complex inductive derived path.
|
||||
*/
|
||||
TEST_F(DerivedPathTest, built_built_xp) {
|
||||
TEST_F(DerivedPathTest, built_built_xp)
|
||||
{
|
||||
ASSERT_THROW(
|
||||
DerivedPath::parse(*store, "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-x.drv^foo^bar,baz"),
|
||||
MissingExperimentalFeature);
|
||||
|
|
@ -84,20 +91,14 @@ TEST_F(DerivedPathTest, built_built_xp) {
|
|||
path '00000000000000000000000000000000-0^0' is not a valid store path:
|
||||
name '0^0' contains illegal character '^'
|
||||
*/
|
||||
RC_GTEST_FIXTURE_PROP(
|
||||
DerivedPathTest,
|
||||
DISABLED_prop_legacy_round_rip,
|
||||
(const DerivedPath & o))
|
||||
RC_GTEST_FIXTURE_PROP(DerivedPathTest, DISABLED_prop_legacy_round_rip, (const DerivedPath & o))
|
||||
{
|
||||
ExperimentalFeatureSettings xpSettings;
|
||||
xpSettings.set("experimental-features", "dynamic-derivations");
|
||||
RC_ASSERT(o == DerivedPath::parseLegacy(*store, o.to_string_legacy(*store), xpSettings));
|
||||
}
|
||||
|
||||
RC_GTEST_FIXTURE_PROP(
|
||||
DerivedPathTest,
|
||||
prop_round_rip,
|
||||
(const DerivedPath & o))
|
||||
RC_GTEST_FIXTURE_PROP(DerivedPathTest, prop_round_rip, (const DerivedPath & o))
|
||||
{
|
||||
ExperimentalFeatureSettings xpSettings;
|
||||
xpSettings.set("experimental-features", "dynamic-derivations");
|
||||
|
|
@ -106,4 +107,4 @@ RC_GTEST_FIXTURE_PROP(
|
|||
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
TEST(DownstreamPlaceholder, unknownCaOutput) {
|
||||
TEST(DownstreamPlaceholder, unknownCaOutput)
|
||||
{
|
||||
/**
|
||||
* 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.
|
||||
|
|
@ -14,13 +15,13 @@ TEST(DownstreamPlaceholder, unknownCaOutput) {
|
|||
|
||||
ASSERT_EQ(
|
||||
DownstreamPlaceholder::unknownCaOutput(
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv" },
|
||||
"out",
|
||||
mockXpSettings).render(),
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"}, "out", mockXpSettings)
|
||||
.render(),
|
||||
"/0c6rn30q4frawknapgwq386zq358m8r6msvywcvc89n6m5p2dgbz");
|
||||
}
|
||||
|
||||
TEST(DownstreamPlaceholder, unknownDerivation) {
|
||||
TEST(DownstreamPlaceholder, unknownDerivation)
|
||||
{
|
||||
/**
|
||||
* Same reason as above
|
||||
*/
|
||||
|
|
@ -30,12 +31,11 @@ TEST(DownstreamPlaceholder, unknownDerivation) {
|
|||
ASSERT_EQ(
|
||||
DownstreamPlaceholder::unknownDerivation(
|
||||
DownstreamPlaceholder::unknownCaOutput(
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv.drv" },
|
||||
"out",
|
||||
mockXpSettings),
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv.drv"}, "out", mockXpSettings),
|
||||
"out",
|
||||
mockXpSettings).render(),
|
||||
mockXpSettings)
|
||||
.render(),
|
||||
"/0gn6agqxjyyalf0dpihgyf49xq5hqxgw100f0wydnj6yqrhqsb3w");
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ TEST(LegacySSHStore, constructConfig)
|
|||
"bar",
|
||||
}));
|
||||
}
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -13,16 +13,20 @@ using testing::Eq;
|
|||
using testing::Field;
|
||||
using testing::SizeIs;
|
||||
|
||||
namespace nix::fs { using namespace std::filesystem; }
|
||||
namespace nix::fs {
|
||||
using namespace std::filesystem;
|
||||
}
|
||||
|
||||
using namespace nix;
|
||||
|
||||
TEST(machines, getMachinesWithEmptyBuilders) {
|
||||
TEST(machines, getMachinesWithEmptyBuilders)
|
||||
{
|
||||
auto actual = Machine::parseConfig({}, "");
|
||||
ASSERT_THAT(actual, SizeIs(0));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesUriOnly) {
|
||||
TEST(machines, getMachinesUriOnly)
|
||||
{
|
||||
auto actual = Machine::parseConfig({"TEST_ARCH-TEST_OS"}, "nix@scratchy.labs.cs.uu.nl");
|
||||
ASSERT_THAT(actual, SizeIs(1));
|
||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq(StoreReference::parse("ssh://nix@scratchy.labs.cs.uu.nl"))));
|
||||
|
|
@ -35,7 +39,8 @@ TEST(machines, getMachinesUriOnly) {
|
|||
EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, SizeIs(0)));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesDefaults) {
|
||||
TEST(machines, getMachinesDefaults)
|
||||
{
|
||||
auto actual = Machine::parseConfig({"TEST_ARCH-TEST_OS"}, "nix@scratchy.labs.cs.uu.nl - - - - - - -");
|
||||
ASSERT_THAT(actual, SizeIs(1));
|
||||
EXPECT_THAT(actual[0], Field(&Machine::storeUri, Eq(StoreReference::parse("ssh://nix@scratchy.labs.cs.uu.nl"))));
|
||||
|
|
@ -48,33 +53,35 @@ TEST(machines, getMachinesDefaults) {
|
|||
EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, SizeIs(0)));
|
||||
}
|
||||
|
||||
MATCHER_P(AuthorityMatches, authority, "") {
|
||||
*result_listener
|
||||
<< "where the authority of "
|
||||
<< arg.render()
|
||||
<< " is "
|
||||
<< authority;
|
||||
MATCHER_P(AuthorityMatches, authority, "")
|
||||
{
|
||||
*result_listener << "where the authority of " << arg.render() << " is " << authority;
|
||||
auto * generic = std::get_if<StoreReference::Specified>(&arg.variant);
|
||||
if (!generic) return false;
|
||||
if (!generic)
|
||||
return false;
|
||||
return generic->authority == authority;
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithNewLineSeparator) {
|
||||
TEST(machines, getMachinesWithNewLineSeparator)
|
||||
{
|
||||
auto actual = Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl\nnix@itchy.labs.cs.uu.nl");
|
||||
ASSERT_THAT(actual, SizeIs(2));
|
||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scratchy.labs.cs.uu.nl"))));
|
||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@itchy.labs.cs.uu.nl"))));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithSemicolonSeparator) {
|
||||
TEST(machines, getMachinesWithSemicolonSeparator)
|
||||
{
|
||||
auto actual = Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl");
|
||||
EXPECT_THAT(actual, SizeIs(2));
|
||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scratchy.labs.cs.uu.nl"))));
|
||||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@itchy.labs.cs.uu.nl"))));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithCommentsAndSemicolonSeparator) {
|
||||
auto actual = Machine::parseConfig({},
|
||||
TEST(machines, getMachinesWithCommentsAndSemicolonSeparator)
|
||||
{
|
||||
auto actual = Machine::parseConfig(
|
||||
{},
|
||||
"# This is a comment ; this is still that comment\n"
|
||||
"nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl\n"
|
||||
"# This is also a comment ; this also is still that comment\n"
|
||||
|
|
@ -85,8 +92,10 @@ TEST(machines, getMachinesWithCommentsAndSemicolonSeparator) {
|
|||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scabby.labs.cs.uu.nl"))));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithFunnyWhitespace) {
|
||||
auto actual = Machine::parseConfig({},
|
||||
TEST(machines, getMachinesWithFunnyWhitespace)
|
||||
{
|
||||
auto actual = Machine::parseConfig(
|
||||
{},
|
||||
" # comment ; comment\n"
|
||||
" nix@scratchy.labs.cs.uu.nl ; nix@itchy.labs.cs.uu.nl \n"
|
||||
"\n \n"
|
||||
|
|
@ -99,8 +108,10 @@ TEST(machines, getMachinesWithFunnyWhitespace) {
|
|||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@scabby.labs.cs.uu.nl"))));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
||||
auto actual = Machine::parseConfig({},
|
||||
TEST(machines, getMachinesWithCorrectCompleteSingleBuilder)
|
||||
{
|
||||
auto actual = Machine::parseConfig(
|
||||
{},
|
||||
"nix@scratchy.labs.cs.uu.nl i686-linux "
|
||||
"/home/nix/.ssh/id_scratchy_auto 8 3 kvm "
|
||||
"benchmark SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==");
|
||||
|
|
@ -115,9 +126,10 @@ TEST(machines, getMachinesWithCorrectCompleteSingleBuilder) {
|
|||
EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, Eq("SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==")));
|
||||
}
|
||||
|
||||
TEST(machines,
|
||||
getMachinesWithCorrectCompleteSingleBuilderWithTabColumnDelimiter) {
|
||||
auto actual = Machine::parseConfig({},
|
||||
TEST(machines, getMachinesWithCorrectCompleteSingleBuilderWithTabColumnDelimiter)
|
||||
{
|
||||
auto actual = Machine::parseConfig(
|
||||
{},
|
||||
"nix@scratchy.labs.cs.uu.nl\ti686-linux\t/home/nix/.ssh/"
|
||||
"id_scratchy_auto\t8\t3\tkvm\tbenchmark\tSSH+HOST+PUBLIC+"
|
||||
"KEY+BASE64+ENCODED==");
|
||||
|
|
@ -132,8 +144,10 @@ TEST(machines,
|
|||
EXPECT_THAT(actual[0], Field(&Machine::sshPublicHostKey, Eq("SSH+HOST+PUBLIC+KEY+BASE64+ENCODED==")));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithMultiOptions) {
|
||||
auto actual = Machine::parseConfig({},
|
||||
TEST(machines, getMachinesWithMultiOptions)
|
||||
{
|
||||
auto actual = Machine::parseConfig(
|
||||
{},
|
||||
"nix@scratchy.labs.cs.uu.nl Arch1,Arch2 - - - "
|
||||
"SupportedFeature1,SupportedFeature2 "
|
||||
"MandatoryFeature1,MandatoryFeature2");
|
||||
|
|
@ -144,25 +158,17 @@ TEST(machines, getMachinesWithMultiOptions) {
|
|||
EXPECT_THAT(actual[0], Field(&Machine::mandatoryFeatures, ElementsAre("MandatoryFeature1", "MandatoryFeature2")));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithIncorrectFormat) {
|
||||
EXPECT_THROW(
|
||||
Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - eight"),
|
||||
FormatError);
|
||||
EXPECT_THROW(
|
||||
Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - -1"),
|
||||
FormatError);
|
||||
EXPECT_THROW(
|
||||
Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - 8 three"),
|
||||
FormatError);
|
||||
EXPECT_THROW(
|
||||
Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - 8 -3"),
|
||||
UsageError);
|
||||
EXPECT_THROW(
|
||||
Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - 8 3 - - BAD_BASE64"),
|
||||
FormatError);
|
||||
TEST(machines, getMachinesWithIncorrectFormat)
|
||||
{
|
||||
EXPECT_THROW(Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - eight"), FormatError);
|
||||
EXPECT_THROW(Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - -1"), FormatError);
|
||||
EXPECT_THROW(Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - 8 three"), FormatError);
|
||||
EXPECT_THROW(Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - 8 -3"), UsageError);
|
||||
EXPECT_THROW(Machine::parseConfig({}, "nix@scratchy.labs.cs.uu.nl - - 8 3 - - BAD_BASE64"), FormatError);
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithCorrectFileReference) {
|
||||
TEST(machines, getMachinesWithCorrectFileReference)
|
||||
{
|
||||
auto path = std::filesystem::weakly_canonical(getUnitTestData() / "machines/valid");
|
||||
ASSERT_TRUE(std::filesystem::exists(path));
|
||||
|
||||
|
|
@ -173,7 +179,8 @@ TEST(machines, getMachinesWithCorrectFileReference) {
|
|||
EXPECT_THAT(actual, Contains(Field(&Machine::storeUri, AuthorityMatches("nix@poochie.labs.cs.uu.nl"))));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithCorrectFileReferenceToEmptyFile) {
|
||||
TEST(machines, getMachinesWithCorrectFileReferenceToEmptyFile)
|
||||
{
|
||||
std::filesystem::path path = "/dev/null";
|
||||
ASSERT_TRUE(std::filesystem::exists(path));
|
||||
|
||||
|
|
@ -181,15 +188,18 @@ TEST(machines, getMachinesWithCorrectFileReferenceToEmptyFile) {
|
|||
ASSERT_THAT(actual, SizeIs(0));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithIncorrectFileReference) {
|
||||
TEST(machines, getMachinesWithIncorrectFileReference)
|
||||
{
|
||||
auto path = std::filesystem::weakly_canonical("/not/a/file");
|
||||
ASSERT_TRUE(!std::filesystem::exists(path));
|
||||
auto actual = Machine::parseConfig({}, "@" + path.string());
|
||||
ASSERT_THAT(actual, SizeIs(0));
|
||||
}
|
||||
|
||||
TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile) {
|
||||
TEST(machines, getMachinesWithCorrectFileReferenceToIncorrectFile)
|
||||
{
|
||||
EXPECT_THROW(
|
||||
Machine::parseConfig({}, "@" + std::filesystem::weakly_canonical(getUnitTestData() / "machines" / "bad_format").string()),
|
||||
Machine::parseConfig(
|
||||
{}, "@" + std::filesystem::weakly_canonical(getUnitTestData() / "machines" / "bad_format").string()),
|
||||
FormatError);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@
|
|||
#include "nix/store/sqlite.hh"
|
||||
#include <sqlite3.h>
|
||||
|
||||
|
||||
namespace nix {
|
||||
|
||||
TEST(NarInfoDiskCacheImpl, create_and_read) {
|
||||
TEST(NarInfoDiskCacheImpl, create_and_read)
|
||||
{
|
||||
// This is a large single test to avoid some setup overhead.
|
||||
|
||||
int prio = 12345;
|
||||
|
|
@ -36,7 +36,8 @@ TEST(NarInfoDiskCacheImpl, create_and_read) {
|
|||
|
||||
// Check that the fields are saved and returned correctly. This does not test
|
||||
// the select statement yet, because of in-memory caching.
|
||||
savedId = cache->createCache("http://foo", "/nix/storedir", wantMassQuery, prio);;
|
||||
savedId = cache->createCache("http://foo", "/nix/storedir", wantMassQuery, prio);
|
||||
;
|
||||
{
|
||||
auto r = cache->upToDateCacheExists("http://foo");
|
||||
ASSERT_TRUE(r);
|
||||
|
|
@ -120,4 +121,4 @@ TEST(NarInfoDiskCacheImpl, create_and_read) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -15,38 +15,42 @@ class NarInfoTest : public CharacterizationTest, public LibStoreTest
|
|||
{
|
||||
std::filesystem::path unitTestData = getUnitTestData() / "nar-info";
|
||||
|
||||
std::filesystem::path goldenMaster(PathView testStem) const override {
|
||||
std::filesystem::path goldenMaster(PathView testStem) const override
|
||||
{
|
||||
return unitTestData / (testStem + ".json");
|
||||
}
|
||||
};
|
||||
|
||||
static NarInfo makeNarInfo(const Store & store, bool includeImpureInfo) {
|
||||
NarInfo info = ValidPathInfo {
|
||||
static NarInfo makeNarInfo(const Store & store, bool includeImpureInfo)
|
||||
{
|
||||
NarInfo info = ValidPathInfo{
|
||||
store,
|
||||
"foo",
|
||||
FixedOutputInfo {
|
||||
FixedOutputInfo{
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
|
||||
.references = {
|
||||
.others = {
|
||||
StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
.references =
|
||||
{
|
||||
.others =
|
||||
{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
},
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
info.narSize = 34878;
|
||||
if (includeImpureInfo) {
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.registrationTime = 23423;
|
||||
info.ultimate = true;
|
||||
info.sigs = { "asdf", "qwer" };
|
||||
info.sigs = {"asdf", "qwer"};
|
||||
|
||||
info.url = "nar/1w1fff338fvdw53sqgamddn1b2xgds473pv6y13gizdbqjv4i5p3.nar.xz";
|
||||
info.compression = "xz";
|
||||
|
|
@ -56,31 +60,27 @@ static NarInfo makeNarInfo(const Store & store, bool includeImpureInfo) {
|
|||
return info;
|
||||
}
|
||||
|
||||
#define JSON_TEST(STEM, PURE) \
|
||||
TEST_F(NarInfoTest, NarInfo_ ## STEM ## _from_json) { \
|
||||
readTest(#STEM, [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
auto expected = makeNarInfo(*store, PURE); \
|
||||
NarInfo got = NarInfo::fromJSON( \
|
||||
*store, \
|
||||
expected.path, \
|
||||
encoded); \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(NarInfoTest, NarInfo_ ## STEM ## _to_json) { \
|
||||
writeTest(#STEM, [&]() -> json { \
|
||||
return makeNarInfo(*store, PURE) \
|
||||
.toJSON(*store, PURE, HashFormat::SRI); \
|
||||
}, [](const auto & file) { \
|
||||
return json::parse(readFile(file)); \
|
||||
}, [](const auto & file, const auto & got) { \
|
||||
return writeFile(file, got.dump(2) + "\n"); \
|
||||
}); \
|
||||
#define JSON_TEST(STEM, PURE) \
|
||||
TEST_F(NarInfoTest, NarInfo_##STEM##_from_json) \
|
||||
{ \
|
||||
readTest(#STEM, [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
auto expected = makeNarInfo(*store, PURE); \
|
||||
NarInfo got = NarInfo::fromJSON(*store, expected.path, encoded); \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(NarInfoTest, NarInfo_##STEM##_to_json) \
|
||||
{ \
|
||||
writeTest( \
|
||||
#STEM, \
|
||||
[&]() -> json { return makeNarInfo(*store, PURE).toJSON(*store, PURE, HashFormat::SRI); }, \
|
||||
[](const auto & file) { return json::parse(readFile(file)); }, \
|
||||
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
||||
}
|
||||
|
||||
JSON_TEST(pure, false)
|
||||
JSON_TEST(impure, true)
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -6,15 +6,16 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
TEST(OutputsSpec, no_empty_names) {
|
||||
ASSERT_DEATH(OutputsSpec::Names { StringSet { } }, "");
|
||||
TEST(OutputsSpec, no_empty_names)
|
||||
{
|
||||
ASSERT_DEATH(OutputsSpec::Names{StringSet{}}, "");
|
||||
}
|
||||
|
||||
#define TEST_DONT_PARSE(NAME, STR) \
|
||||
TEST(OutputsSpec, bad_ ## NAME) { \
|
||||
std::optional OutputsSpecOpt = \
|
||||
OutputsSpec::parseOpt(STR); \
|
||||
ASSERT_FALSE(OutputsSpecOpt); \
|
||||
#define TEST_DONT_PARSE(NAME, STR) \
|
||||
TEST(OutputsSpec, bad_##NAME) \
|
||||
{ \
|
||||
std::optional OutputsSpecOpt = OutputsSpec::parseOpt(STR); \
|
||||
ASSERT_FALSE(OutputsSpecOpt); \
|
||||
}
|
||||
|
||||
TEST_DONT_PARSE(empty, "")
|
||||
|
|
@ -25,96 +26,109 @@ TEST_DONT_PARSE(star_second, "foo,*")
|
|||
|
||||
#undef TEST_DONT_PARSE
|
||||
|
||||
TEST(OutputsSpec, all) {
|
||||
TEST(OutputsSpec, all)
|
||||
{
|
||||
std::string_view str = "*";
|
||||
OutputsSpec expected = OutputsSpec::All { };
|
||||
OutputsSpec expected = OutputsSpec::All{};
|
||||
ASSERT_EQ(OutputsSpec::parse(str), expected);
|
||||
ASSERT_EQ(expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, names_out) {
|
||||
TEST(OutputsSpec, names_out)
|
||||
{
|
||||
std::string_view str = "out";
|
||||
OutputsSpec expected = OutputsSpec::Names { "out" };
|
||||
OutputsSpec expected = OutputsSpec::Names{"out"};
|
||||
ASSERT_EQ(OutputsSpec::parse(str), expected);
|
||||
ASSERT_EQ(expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, names_underscore) {
|
||||
TEST(OutputsSpec, names_underscore)
|
||||
{
|
||||
std::string_view str = "a_b";
|
||||
OutputsSpec expected = OutputsSpec::Names { "a_b" };
|
||||
OutputsSpec expected = OutputsSpec::Names{"a_b"};
|
||||
ASSERT_EQ(OutputsSpec::parse(str), expected);
|
||||
ASSERT_EQ(expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, names_numeric) {
|
||||
TEST(OutputsSpec, names_numeric)
|
||||
{
|
||||
std::string_view str = "01";
|
||||
OutputsSpec expected = OutputsSpec::Names { "01" };
|
||||
OutputsSpec expected = OutputsSpec::Names{"01"};
|
||||
ASSERT_EQ(OutputsSpec::parse(str), expected);
|
||||
ASSERT_EQ(expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, names_out_bin) {
|
||||
OutputsSpec expected = OutputsSpec::Names { "out", "bin" };
|
||||
TEST(OutputsSpec, names_out_bin)
|
||||
{
|
||||
OutputsSpec expected = OutputsSpec::Names{"out", "bin"};
|
||||
ASSERT_EQ(OutputsSpec::parse("out,bin"), expected);
|
||||
// N.B. This normalization is OK.
|
||||
ASSERT_EQ(expected.to_string(), "bin,out");
|
||||
}
|
||||
|
||||
#define TEST_SUBSET(X, THIS, THAT) \
|
||||
X((OutputsSpec { THIS }).isSubsetOf(THAT));
|
||||
#define TEST_SUBSET(X, THIS, THAT) X((OutputsSpec{THIS}).isSubsetOf(THAT));
|
||||
|
||||
TEST(OutputsSpec, subsets_all_all) {
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::All { }, OutputsSpec::All { });
|
||||
TEST(OutputsSpec, subsets_all_all)
|
||||
{
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::All{}, OutputsSpec::All{});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, subsets_names_all) {
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names { "a" }, OutputsSpec::All { });
|
||||
TEST(OutputsSpec, subsets_names_all)
|
||||
{
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names{"a"}, OutputsSpec::All{});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, subsets_names_names_eq) {
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names { "a" }, OutputsSpec::Names { "a" });
|
||||
TEST(OutputsSpec, subsets_names_names_eq)
|
||||
{
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names{"a"}, OutputsSpec::Names{"a"});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, subsets_names_names_noneq) {
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names { "a" }, (OutputsSpec::Names { "a", "b" }));
|
||||
TEST(OutputsSpec, subsets_names_names_noneq)
|
||||
{
|
||||
TEST_SUBSET(ASSERT_TRUE, OutputsSpec::Names{"a"}, (OutputsSpec::Names{"a", "b"}));
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, not_subsets_all_names) {
|
||||
TEST_SUBSET(ASSERT_FALSE, OutputsSpec::All { }, OutputsSpec::Names { "a" });
|
||||
TEST(OutputsSpec, not_subsets_all_names)
|
||||
{
|
||||
TEST_SUBSET(ASSERT_FALSE, OutputsSpec::All{}, OutputsSpec::Names{"a"});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, not_subsets_names_names) {
|
||||
TEST_SUBSET(ASSERT_FALSE, (OutputsSpec::Names { "a", "b" }), (OutputsSpec::Names { "a" }));
|
||||
TEST(OutputsSpec, not_subsets_names_names)
|
||||
{
|
||||
TEST_SUBSET(ASSERT_FALSE, (OutputsSpec::Names{"a", "b"}), (OutputsSpec::Names{"a"}));
|
||||
}
|
||||
|
||||
#undef TEST_SUBSET
|
||||
|
||||
#define TEST_UNION(RES, THIS, THAT) \
|
||||
ASSERT_EQ(OutputsSpec { RES }, (OutputsSpec { THIS }).union_(THAT));
|
||||
#define TEST_UNION(RES, THIS, THAT) ASSERT_EQ(OutputsSpec{RES}, (OutputsSpec{THIS}).union_(THAT));
|
||||
|
||||
TEST(OutputsSpec, union_all_all) {
|
||||
TEST_UNION(OutputsSpec::All { }, OutputsSpec::All { }, OutputsSpec::All { });
|
||||
TEST(OutputsSpec, union_all_all)
|
||||
{
|
||||
TEST_UNION(OutputsSpec::All{}, OutputsSpec::All{}, OutputsSpec::All{});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, union_all_names) {
|
||||
TEST_UNION(OutputsSpec::All { }, OutputsSpec::All { }, OutputsSpec::Names { "a" });
|
||||
TEST(OutputsSpec, union_all_names)
|
||||
{
|
||||
TEST_UNION(OutputsSpec::All{}, OutputsSpec::All{}, OutputsSpec::Names{"a"});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, union_names_all) {
|
||||
TEST_UNION(OutputsSpec::All { }, OutputsSpec::Names { "a" }, OutputsSpec::All { });
|
||||
TEST(OutputsSpec, union_names_all)
|
||||
{
|
||||
TEST_UNION(OutputsSpec::All{}, OutputsSpec::Names{"a"}, OutputsSpec::All{});
|
||||
}
|
||||
|
||||
TEST(OutputsSpec, union_names_names) {
|
||||
TEST_UNION((OutputsSpec::Names { "a", "b" }), OutputsSpec::Names { "a" }, OutputsSpec::Names { "b" });
|
||||
TEST(OutputsSpec, union_names_names)
|
||||
{
|
||||
TEST_UNION((OutputsSpec::Names{"a", "b"}), OutputsSpec::Names{"a"}, OutputsSpec::Names{"b"});
|
||||
}
|
||||
|
||||
#undef TEST_UNION
|
||||
|
||||
#define TEST_DONT_PARSE(NAME, STR) \
|
||||
TEST(ExtendedOutputsSpec, bad_ ## NAME) { \
|
||||
std::optional extendedOutputsSpecOpt = \
|
||||
ExtendedOutputsSpec::parseOpt(STR); \
|
||||
ASSERT_FALSE(extendedOutputsSpecOpt); \
|
||||
#define TEST_DONT_PARSE(NAME, STR) \
|
||||
TEST(ExtendedOutputsSpec, bad_##NAME) \
|
||||
{ \
|
||||
std::optional extendedOutputsSpecOpt = ExtendedOutputsSpec::parseOpt(STR); \
|
||||
ASSERT_FALSE(extendedOutputsSpecOpt); \
|
||||
}
|
||||
|
||||
TEST_DONT_PARSE(carot_empty, "^")
|
||||
|
|
@ -126,87 +140,86 @@ TEST_DONT_PARSE(star_second, "^foo,*")
|
|||
|
||||
#undef TEST_DONT_PARSE
|
||||
|
||||
TEST(ExtendedOutputsSpec, default) {
|
||||
TEST(ExtendedOutputsSpec, default)
|
||||
{
|
||||
std::string_view str = "foo";
|
||||
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(str);
|
||||
ASSERT_EQ(prefix, "foo");
|
||||
ExtendedOutputsSpec expected = ExtendedOutputsSpec::Default { };
|
||||
ExtendedOutputsSpec expected = ExtendedOutputsSpec::Default{};
|
||||
ASSERT_EQ(extendedOutputsSpec, expected);
|
||||
ASSERT_EQ(std::string { prefix } + expected.to_string(), str);
|
||||
ASSERT_EQ(std::string{prefix} + expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(ExtendedOutputsSpec, all) {
|
||||
TEST(ExtendedOutputsSpec, all)
|
||||
{
|
||||
std::string_view str = "foo^*";
|
||||
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(str);
|
||||
ASSERT_EQ(prefix, "foo");
|
||||
ExtendedOutputsSpec expected = OutputsSpec::All { };
|
||||
ExtendedOutputsSpec expected = OutputsSpec::All{};
|
||||
ASSERT_EQ(extendedOutputsSpec, expected);
|
||||
ASSERT_EQ(std::string { prefix } + expected.to_string(), str);
|
||||
ASSERT_EQ(std::string{prefix} + expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(ExtendedOutputsSpec, out) {
|
||||
TEST(ExtendedOutputsSpec, out)
|
||||
{
|
||||
std::string_view str = "foo^out";
|
||||
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse(str);
|
||||
ASSERT_EQ(prefix, "foo");
|
||||
ExtendedOutputsSpec expected = OutputsSpec::Names { "out" };
|
||||
ExtendedOutputsSpec expected = OutputsSpec::Names{"out"};
|
||||
ASSERT_EQ(extendedOutputsSpec, expected);
|
||||
ASSERT_EQ(std::string { prefix } + expected.to_string(), str);
|
||||
ASSERT_EQ(std::string{prefix} + expected.to_string(), str);
|
||||
}
|
||||
|
||||
TEST(ExtendedOutputsSpec, out_bin) {
|
||||
TEST(ExtendedOutputsSpec, out_bin)
|
||||
{
|
||||
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse("foo^out,bin");
|
||||
ASSERT_EQ(prefix, "foo");
|
||||
ExtendedOutputsSpec expected = OutputsSpec::Names { "out", "bin" };
|
||||
ExtendedOutputsSpec expected = OutputsSpec::Names{"out", "bin"};
|
||||
ASSERT_EQ(extendedOutputsSpec, expected);
|
||||
ASSERT_EQ(std::string { prefix } + expected.to_string(), "foo^bin,out");
|
||||
ASSERT_EQ(std::string{prefix} + expected.to_string(), "foo^bin,out");
|
||||
}
|
||||
|
||||
TEST(ExtendedOutputsSpec, many_carrot) {
|
||||
TEST(ExtendedOutputsSpec, many_carrot)
|
||||
{
|
||||
auto [prefix, extendedOutputsSpec] = ExtendedOutputsSpec::parse("foo^bar^out,bin");
|
||||
ASSERT_EQ(prefix, "foo^bar");
|
||||
ExtendedOutputsSpec expected = OutputsSpec::Names { "out", "bin" };
|
||||
ExtendedOutputsSpec expected = OutputsSpec::Names{"out", "bin"};
|
||||
ASSERT_EQ(extendedOutputsSpec, expected);
|
||||
ASSERT_EQ(std::string { prefix } + expected.to_string(), "foo^bar^bin,out");
|
||||
ASSERT_EQ(std::string{prefix} + expected.to_string(), "foo^bar^bin,out");
|
||||
}
|
||||
|
||||
|
||||
#define TEST_JSON(TYPE, NAME, STR, VAL) \
|
||||
\
|
||||
TEST(TYPE, NAME ## _to_json) { \
|
||||
using nlohmann::literals::operator "" _json; \
|
||||
ASSERT_EQ( \
|
||||
STR ## _json, \
|
||||
((nlohmann::json) TYPE { VAL })); \
|
||||
} \
|
||||
\
|
||||
TEST(TYPE, NAME ## _from_json) { \
|
||||
using nlohmann::literals::operator "" _json; \
|
||||
ASSERT_EQ( \
|
||||
TYPE { VAL }, \
|
||||
(STR ## _json).get<TYPE>()); \
|
||||
#define TEST_JSON(TYPE, NAME, STR, VAL) \
|
||||
\
|
||||
TEST(TYPE, NAME##_to_json) \
|
||||
{ \
|
||||
using nlohmann::literals::operator"" _json; \
|
||||
ASSERT_EQ(STR##_json, ((nlohmann::json) TYPE{VAL})); \
|
||||
} \
|
||||
\
|
||||
TEST(TYPE, NAME##_from_json) \
|
||||
{ \
|
||||
using nlohmann::literals::operator"" _json; \
|
||||
ASSERT_EQ(TYPE{VAL}, (STR##_json).get<TYPE>()); \
|
||||
}
|
||||
|
||||
TEST_JSON(OutputsSpec, all, R"(["*"])", OutputsSpec::All { })
|
||||
TEST_JSON(OutputsSpec, name, R"(["a"])", OutputsSpec::Names { "a" })
|
||||
TEST_JSON(OutputsSpec, names, R"(["a","b"])", (OutputsSpec::Names { "a", "b" }))
|
||||
TEST_JSON(OutputsSpec, all, R"(["*"])", OutputsSpec::All{})
|
||||
TEST_JSON(OutputsSpec, name, R"(["a"])", OutputsSpec::Names{"a"})
|
||||
TEST_JSON(OutputsSpec, names, R"(["a","b"])", (OutputsSpec::Names{"a", "b"}))
|
||||
|
||||
TEST_JSON(ExtendedOutputsSpec, def, R"(null)", ExtendedOutputsSpec::Default { })
|
||||
TEST_JSON(ExtendedOutputsSpec, all, R"(["*"])", ExtendedOutputsSpec::Explicit { OutputsSpec::All { } })
|
||||
TEST_JSON(ExtendedOutputsSpec, name, R"(["a"])", ExtendedOutputsSpec::Explicit { OutputsSpec::Names { "a" } })
|
||||
TEST_JSON(ExtendedOutputsSpec, names, R"(["a","b"])", (ExtendedOutputsSpec::Explicit { OutputsSpec::Names { "a", "b" } }))
|
||||
TEST_JSON(ExtendedOutputsSpec, def, R"(null)", ExtendedOutputsSpec::Default{})
|
||||
TEST_JSON(ExtendedOutputsSpec, all, R"(["*"])", ExtendedOutputsSpec::Explicit{OutputsSpec::All{}})
|
||||
TEST_JSON(ExtendedOutputsSpec, name, R"(["a"])", ExtendedOutputsSpec::Explicit{OutputsSpec::Names{"a"}})
|
||||
TEST_JSON(ExtendedOutputsSpec, names, R"(["a","b"])", (ExtendedOutputsSpec::Explicit{OutputsSpec::Names{"a", "b"}}))
|
||||
|
||||
#undef TEST_JSON
|
||||
|
||||
#ifndef COVERAGE
|
||||
|
||||
RC_GTEST_PROP(
|
||||
OutputsSpec,
|
||||
prop_round_rip,
|
||||
(const OutputsSpec & o))
|
||||
RC_GTEST_PROP(OutputsSpec, prop_round_rip, (const OutputsSpec & o))
|
||||
{
|
||||
RC_ASSERT(o == OutputsSpec::parse(o.to_string()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ class PathInfoTest : public CharacterizationTest, public LibStoreTest
|
|||
{
|
||||
std::filesystem::path unitTestData = getUnitTestData() / "path-info";
|
||||
|
||||
std::filesystem::path goldenMaster(PathView testStem) const override {
|
||||
std::filesystem::path goldenMaster(PathView testStem) const override
|
||||
{
|
||||
return unitTestData / (testStem + ".json");
|
||||
}
|
||||
};
|
||||
|
|
@ -28,59 +29,61 @@ static UnkeyedValidPathInfo makeEmpty()
|
|||
|
||||
static ValidPathInfo makeFullKeyed(const Store & store, bool includeImpureInfo)
|
||||
{
|
||||
ValidPathInfo info = ValidPathInfo {
|
||||
ValidPathInfo info = ValidPathInfo{
|
||||
store,
|
||||
"foo",
|
||||
FixedOutputInfo {
|
||||
FixedOutputInfo{
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
|
||||
.references = {
|
||||
.others = {
|
||||
StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
.references =
|
||||
{
|
||||
.others =
|
||||
{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
},
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
info.narSize = 34878;
|
||||
if (includeImpureInfo) {
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.registrationTime = 23423;
|
||||
info.ultimate = true;
|
||||
info.sigs = { "asdf", "qwer" };
|
||||
info.sigs = {"asdf", "qwer"};
|
||||
}
|
||||
return info;
|
||||
}
|
||||
static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo) {
|
||||
|
||||
static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo)
|
||||
{
|
||||
return makeFullKeyed(store, includeImpureInfo);
|
||||
}
|
||||
|
||||
#define JSON_TEST(STEM, OBJ, PURE) \
|
||||
TEST_F(PathInfoTest, PathInfo_ ## STEM ## _from_json) { \
|
||||
readTest(#STEM, [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
UnkeyedValidPathInfo got = UnkeyedValidPathInfo::fromJSON( \
|
||||
*store, \
|
||||
encoded); \
|
||||
auto expected = OBJ; \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(PathInfoTest, PathInfo_ ## STEM ## _to_json) { \
|
||||
writeTest(#STEM, [&]() -> json { \
|
||||
return OBJ.toJSON(*store, PURE, HashFormat::SRI); \
|
||||
}, [](const auto & file) { \
|
||||
return json::parse(readFile(file)); \
|
||||
}, [](const auto & file, const auto & got) { \
|
||||
return writeFile(file, got.dump(2) + "\n"); \
|
||||
}); \
|
||||
#define JSON_TEST(STEM, OBJ, PURE) \
|
||||
TEST_F(PathInfoTest, PathInfo_##STEM##_from_json) \
|
||||
{ \
|
||||
readTest(#STEM, [&](const auto & encoded_) { \
|
||||
auto encoded = json::parse(encoded_); \
|
||||
UnkeyedValidPathInfo got = UnkeyedValidPathInfo::fromJSON(*store, encoded); \
|
||||
auto expected = OBJ; \
|
||||
ASSERT_EQ(got, expected); \
|
||||
}); \
|
||||
} \
|
||||
\
|
||||
TEST_F(PathInfoTest, PathInfo_##STEM##_to_json) \
|
||||
{ \
|
||||
writeTest( \
|
||||
#STEM, \
|
||||
[&]() -> json { return OBJ.toJSON(*store, PURE, HashFormat::SRI); }, \
|
||||
[](const auto & file) { return json::parse(readFile(file)); }, \
|
||||
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
||||
}
|
||||
|
||||
JSON_TEST(empty_pure, makeEmpty(), false)
|
||||
|
|
@ -89,7 +92,8 @@ JSON_TEST(empty_impure, makeEmpty(), true)
|
|||
JSON_TEST(pure, makeFull(*store, false), false)
|
||||
JSON_TEST(impure, makeFull(*store, true), true)
|
||||
|
||||
TEST_F(PathInfoTest, PathInfo_full_shortRefs) {
|
||||
TEST_F(PathInfoTest, PathInfo_full_shortRefs)
|
||||
{
|
||||
ValidPathInfo it = makeFullKeyed(*store, true);
|
||||
// it.references = unkeyed.references;
|
||||
auto refs = it.shortRefs();
|
||||
|
|
|
|||
|
|
@ -17,29 +17,20 @@ namespace nix {
|
|||
#define HASH_PART "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q"
|
||||
|
||||
class StorePathTest : public LibStoreTest
|
||||
{
|
||||
};
|
||||
{};
|
||||
|
||||
static std::regex nameRegex { std::string { nameRegexStr } };
|
||||
static std::regex nameRegex{std::string{nameRegexStr}};
|
||||
|
||||
#define TEST_DONT_PARSE(NAME, STR) \
|
||||
TEST_F(StorePathTest, bad_ ## NAME) { \
|
||||
std::string_view str = \
|
||||
STORE_DIR HASH_PART "-" STR; \
|
||||
/* ASSERT_THROW generates a duplicate goto label */ \
|
||||
/* A lambda isolates those labels. */ \
|
||||
[&](){ \
|
||||
ASSERT_THROW( \
|
||||
store->parseStorePath(str), \
|
||||
BadStorePath); \
|
||||
}(); \
|
||||
std::string name { STR }; \
|
||||
[&](){ \
|
||||
ASSERT_THROW( \
|
||||
nix::checkName(name), \
|
||||
BadStorePathName); \
|
||||
}(); \
|
||||
EXPECT_FALSE(std::regex_match(name, nameRegex)); \
|
||||
#define TEST_DONT_PARSE(NAME, STR) \
|
||||
TEST_F(StorePathTest, bad_##NAME) \
|
||||
{ \
|
||||
std::string_view str = STORE_DIR HASH_PART "-" STR; \
|
||||
/* ASSERT_THROW generates a duplicate goto label */ \
|
||||
/* A lambda isolates those labels. */ \
|
||||
[&]() { ASSERT_THROW(store->parseStorePath(str), BadStorePath); }(); \
|
||||
std::string name{STR}; \
|
||||
[&]() { ASSERT_THROW(nix::checkName(name), BadStorePathName); }(); \
|
||||
EXPECT_FALSE(std::regex_match(name, nameRegex)); \
|
||||
}
|
||||
|
||||
TEST_DONT_PARSE(empty, "")
|
||||
|
|
@ -57,14 +48,14 @@ TEST_DONT_PARSE(dot_dash_a, ".-a")
|
|||
|
||||
#undef TEST_DONT_PARSE
|
||||
|
||||
#define TEST_DO_PARSE(NAME, STR) \
|
||||
TEST_F(StorePathTest, good_ ## NAME) { \
|
||||
std::string_view str = \
|
||||
STORE_DIR HASH_PART "-" STR; \
|
||||
auto p = store->parseStorePath(str); \
|
||||
std::string name { p.name() }; \
|
||||
EXPECT_EQ(p.name(), STR); \
|
||||
EXPECT_TRUE(std::regex_match(name, nameRegex)); \
|
||||
#define TEST_DO_PARSE(NAME, STR) \
|
||||
TEST_F(StorePathTest, good_##NAME) \
|
||||
{ \
|
||||
std::string_view str = STORE_DIR HASH_PART "-" STR; \
|
||||
auto p = store->parseStorePath(str); \
|
||||
std::string name{p.name()}; \
|
||||
EXPECT_EQ(p.name(), STR); \
|
||||
EXPECT_TRUE(std::regex_match(name, nameRegex)); \
|
||||
}
|
||||
|
||||
// 0-9 a-z A-Z + - . _ ? =
|
||||
|
|
@ -88,67 +79,46 @@ TEST_DO_PARSE(triple_dot, "...")
|
|||
|
||||
#ifndef COVERAGE
|
||||
|
||||
RC_GTEST_FIXTURE_PROP(
|
||||
StorePathTest,
|
||||
prop_regex_accept,
|
||||
(const StorePath & p))
|
||||
RC_GTEST_FIXTURE_PROP(StorePathTest, prop_regex_accept, (const StorePath & p))
|
||||
{
|
||||
RC_ASSERT(std::regex_match(std::string { p.name() }, nameRegex));
|
||||
RC_ASSERT(std::regex_match(std::string{p.name()}, nameRegex));
|
||||
}
|
||||
|
||||
RC_GTEST_FIXTURE_PROP(
|
||||
StorePathTest,
|
||||
prop_round_rip,
|
||||
(const StorePath & p))
|
||||
RC_GTEST_FIXTURE_PROP(StorePathTest, prop_round_rip, (const StorePath & p))
|
||||
{
|
||||
RC_ASSERT(p == store->parseStorePath(store->printStorePath(p)));
|
||||
}
|
||||
|
||||
|
||||
RC_GTEST_FIXTURE_PROP(
|
||||
StorePathTest,
|
||||
prop_check_regex_eq_parse,
|
||||
())
|
||||
RC_GTEST_FIXTURE_PROP(StorePathTest, prop_check_regex_eq_parse, ())
|
||||
{
|
||||
static auto nameFuzzer =
|
||||
rc::gen::container<std::string>(
|
||||
rc::gen::oneOf(
|
||||
// alphanum, repeated to weigh heavier
|
||||
rc::gen::oneOf(
|
||||
rc::gen::inRange('0', '9'),
|
||||
rc::gen::inRange('a', 'z'),
|
||||
rc::gen::inRange('A', 'Z')
|
||||
),
|
||||
// valid symbols
|
||||
rc::gen::oneOf(
|
||||
rc::gen::just('+'),
|
||||
rc::gen::just('-'),
|
||||
rc::gen::just('.'),
|
||||
rc::gen::just('_'),
|
||||
rc::gen::just('?'),
|
||||
rc::gen::just('=')
|
||||
),
|
||||
// symbols for scary .- and ..- cases, repeated for weight
|
||||
rc::gen::just('.'), rc::gen::just('.'),
|
||||
rc::gen::just('.'), rc::gen::just('.'),
|
||||
rc::gen::just('-'), rc::gen::just('-'),
|
||||
// ascii symbol ranges
|
||||
rc::gen::oneOf(
|
||||
rc::gen::inRange(' ', '/'),
|
||||
rc::gen::inRange(':', '@'),
|
||||
rc::gen::inRange('[', '`'),
|
||||
rc::gen::inRange('{', '~')
|
||||
),
|
||||
// typical whitespace
|
||||
rc::gen::oneOf(
|
||||
rc::gen::just(' '),
|
||||
rc::gen::just('\t'),
|
||||
rc::gen::just('\n'),
|
||||
rc::gen::just('\r')
|
||||
),
|
||||
// some chance of control codes, non-ascii or other garbage we missed
|
||||
rc::gen::inRange('\0', '\xff')
|
||||
));
|
||||
static auto nameFuzzer = rc::gen::container<std::string>(rc::gen::oneOf(
|
||||
// alphanum, repeated to weigh heavier
|
||||
rc::gen::oneOf(rc::gen::inRange('0', '9'), rc::gen::inRange('a', 'z'), rc::gen::inRange('A', 'Z')),
|
||||
// valid symbols
|
||||
rc::gen::oneOf(
|
||||
rc::gen::just('+'),
|
||||
rc::gen::just('-'),
|
||||
rc::gen::just('.'),
|
||||
rc::gen::just('_'),
|
||||
rc::gen::just('?'),
|
||||
rc::gen::just('=')),
|
||||
// symbols for scary .- and ..- cases, repeated for weight
|
||||
rc::gen::just('.'),
|
||||
rc::gen::just('.'),
|
||||
rc::gen::just('.'),
|
||||
rc::gen::just('.'),
|
||||
rc::gen::just('-'),
|
||||
rc::gen::just('-'),
|
||||
// ascii symbol ranges
|
||||
rc::gen::oneOf(
|
||||
rc::gen::inRange(' ', '/'),
|
||||
rc::gen::inRange(':', '@'),
|
||||
rc::gen::inRange('[', '`'),
|
||||
rc::gen::inRange('{', '~')),
|
||||
// typical whitespace
|
||||
rc::gen::oneOf(rc::gen::just(' '), rc::gen::just('\t'), rc::gen::just('\n'), rc::gen::just('\r')),
|
||||
// some chance of control codes, non-ascii or other garbage we missed
|
||||
rc::gen::inRange('\0', '\xff')));
|
||||
|
||||
auto name = *nameFuzzer;
|
||||
|
||||
|
|
@ -159,9 +129,9 @@ RC_GTEST_FIXTURE_PROP(
|
|||
parsed = true;
|
||||
} catch (const BadStorePath &) {
|
||||
}
|
||||
RC_ASSERT(parsed == std::regex_match(std::string { name }, nameRegex));
|
||||
RC_ASSERT(parsed == std::regex_match(std::string{name}, nameRegex));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -42,4 +42,4 @@ TEST(references, scan)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
string,
|
||||
"string",
|
||||
defaultVersion,
|
||||
(std::tuple<std::string, std::string, std::string, std::string, std::string> {
|
||||
(std::tuple<std::string, std::string, std::string, std::string, std::string>{
|
||||
"",
|
||||
"hi",
|
||||
"white rabbit",
|
||||
|
|
@ -45,9 +45,9 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
storePath,
|
||||
"store-path",
|
||||
defaultVersion,
|
||||
(std::tuple<StorePath, StorePath> {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
|
||||
(std::tuple<StorePath, StorePath>{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -55,16 +55,16 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
contentAddress,
|
||||
"content-address",
|
||||
defaultVersion,
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
|
||||
ContentAddress {
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress>{
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "Derive(...)"),
|
||||
},
|
||||
ContentAddress {
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
ContentAddress {
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
},
|
||||
|
|
@ -75,12 +75,12 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
drvOutput,
|
||||
"drv-output",
|
||||
defaultVersion,
|
||||
(std::tuple<DrvOutput, DrvOutput> {
|
||||
(std::tuple<DrvOutput, DrvOutput>{
|
||||
{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
DrvOutput {
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
|
|
@ -93,70 +93,88 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
realisation,
|
||||
"realisation",
|
||||
defaultVersion,
|
||||
(std::tuple<Realisation, Realisation> {
|
||||
Realisation {
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.signatures = { "asdf", "qwer" },
|
||||
},
|
||||
Realisation {
|
||||
.id = {
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.signatures = { "asdf", "qwer" },
|
||||
.dependentRealisations = {
|
||||
{
|
||||
DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
(std::tuple<Realisation, Realisation>{
|
||||
Realisation{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
.signatures = {"asdf", "qwer"},
|
||||
},
|
||||
Realisation{
|
||||
.id =
|
||||
{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
.signatures = {"asdf", "qwer"},
|
||||
.dependentRealisations =
|
||||
{
|
||||
{
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
ServeProtoTest,
|
||||
buildResult_2_2,
|
||||
"build-result-2.2",
|
||||
2 << 8 | 2,
|
||||
({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
.status = BuildResult::Built,
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
VERSIONED_CHARACTERIZATION_TEST(ServeProtoTest, buildResult_2_2, "build-result-2.2", 2 << 8 | 2, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(ServeProtoTest, buildResult_2_3, "build-result-2.3", 2 << 8 | 3, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
.isNonDeterministic = true,
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
ServeProtoTest,
|
||||
buildResult_2_3,
|
||||
"build-result-2.3",
|
||||
2 << 8 | 3,
|
||||
({
|
||||
ServeProtoTest, buildResult_2_6, "build-result-2.6", 2 << 8 | 6, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
|
|
@ -164,60 +182,36 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
BuildResult {
|
||||
.status = BuildResult::Built,
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
ServeProtoTest,
|
||||
buildResult_2_6,
|
||||
"build-result-2.6",
|
||||
2 << 8 | 6,
|
||||
({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
.isNonDeterministic = true,
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
.timesBuilt = 1,
|
||||
.builtOutputs = {
|
||||
.builtOutputs =
|
||||
{
|
||||
"foo",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
"foo",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar" },
|
||||
},
|
||||
},
|
||||
},
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
#if 0
|
||||
|
|
@ -237,19 +231,19 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
unkeyedValidPathInfo_2_3,
|
||||
"unkeyed-valid-path-info-2.3",
|
||||
2 << 8 | 3,
|
||||
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo> {
|
||||
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
|
||||
({
|
||||
UnkeyedValidPathInfo info { Hash::dummy };
|
||||
UnkeyedValidPathInfo info{Hash::dummy};
|
||||
info.narSize = 34878;
|
||||
info;
|
||||
}),
|
||||
({
|
||||
UnkeyedValidPathInfo info { Hash::dummy };
|
||||
info.deriver = StorePath {
|
||||
UnkeyedValidPathInfo info{Hash::dummy};
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.references = {
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv",
|
||||
},
|
||||
};
|
||||
|
|
@ -263,16 +257,16 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
unkeyedValidPathInfo_2_4,
|
||||
"unkeyed-valid-path-info-2.4",
|
||||
2 << 8 | 4,
|
||||
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo> {
|
||||
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
|
||||
({
|
||||
UnkeyedValidPathInfo info {
|
||||
UnkeyedValidPathInfo info{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.references = {
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv",
|
||||
},
|
||||
};
|
||||
|
|
@ -280,31 +274,34 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
info;
|
||||
}),
|
||||
({
|
||||
ValidPathInfo info {
|
||||
ValidPathInfo info{
|
||||
*LibStoreTest::store,
|
||||
"foo",
|
||||
FixedOutputInfo {
|
||||
FixedOutputInfo{
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
.references = {
|
||||
.others = {
|
||||
StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
.references =
|
||||
{
|
||||
.others =
|
||||
{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
},
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.narSize = 34878;
|
||||
info.sigs = {
|
||||
"fake-sig-1",
|
||||
"fake-sig-2",
|
||||
},
|
||||
info.sigs =
|
||||
{
|
||||
"fake-sig-1",
|
||||
"fake-sig-2",
|
||||
},
|
||||
static_cast<UnkeyedValidPathInfo>(std::move(info));
|
||||
}),
|
||||
}))
|
||||
|
|
@ -314,7 +311,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
build_options_2_1,
|
||||
"build-options-2.1",
|
||||
2 << 8 | 1,
|
||||
(ServeProto::BuildOptions {
|
||||
(ServeProto::BuildOptions{
|
||||
.maxSilentTime = 5,
|
||||
.buildTimeout = 6,
|
||||
}))
|
||||
|
|
@ -324,7 +321,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
build_options_2_2,
|
||||
"build-options-2.2",
|
||||
2 << 8 | 2,
|
||||
(ServeProto::BuildOptions {
|
||||
(ServeProto::BuildOptions{
|
||||
.maxSilentTime = 5,
|
||||
.buildTimeout = 6,
|
||||
.maxLogSize = 7,
|
||||
|
|
@ -335,7 +332,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
build_options_2_3,
|
||||
"build-options-2.3",
|
||||
2 << 8 | 3,
|
||||
(ServeProto::BuildOptions {
|
||||
(ServeProto::BuildOptions{
|
||||
.maxSilentTime = 5,
|
||||
.buildTimeout = 6,
|
||||
.maxLogSize = 7,
|
||||
|
|
@ -348,7 +345,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
build_options_2_7,
|
||||
"build-options-2.7",
|
||||
2 << 8 | 7,
|
||||
(ServeProto::BuildOptions {
|
||||
(ServeProto::BuildOptions{
|
||||
.maxSilentTime = 5,
|
||||
.buildTimeout = 6,
|
||||
.maxLogSize = 7,
|
||||
|
|
@ -362,11 +359,15 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
vector,
|
||||
"vector",
|
||||
defaultVersion,
|
||||
(std::tuple<std::vector<std::string>, std::vector<std::string>, std::vector<std::string>, std::vector<std::vector<std::string>>> {
|
||||
{ },
|
||||
{ "" },
|
||||
{ "", "foo", "bar" },
|
||||
{ {}, { "" }, { "", "1", "2" } },
|
||||
(std::tuple<
|
||||
std::vector<std::string>,
|
||||
std::vector<std::string>,
|
||||
std::vector<std::string>,
|
||||
std::vector<std::vector<std::string>>>{
|
||||
{},
|
||||
{""},
|
||||
{"", "foo", "bar"},
|
||||
{{}, {""}, {"", "1", "2"}},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -374,11 +375,11 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
set,
|
||||
"set",
|
||||
defaultVersion,
|
||||
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>> {
|
||||
{ },
|
||||
{ "" },
|
||||
{ "", "foo", "bar" },
|
||||
{ {}, { "" }, { "", "1", "2" } },
|
||||
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>>{
|
||||
{},
|
||||
{""},
|
||||
{"", "foo", "bar"},
|
||||
{{}, {""}, {"", "1", "2"}},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -386,10 +387,10 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
optionalStorePath,
|
||||
"optional-store-path",
|
||||
defaultVersion,
|
||||
(std::tuple<std::optional<StorePath>, std::optional<StorePath>> {
|
||||
(std::tuple<std::optional<StorePath>, std::optional<StorePath>>{
|
||||
std::nullopt,
|
||||
std::optional {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
|
||||
std::optional{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"},
|
||||
},
|
||||
}))
|
||||
|
||||
|
|
@ -398,10 +399,10 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
optionalContentAddress,
|
||||
"optional-content-address",
|
||||
defaultVersion,
|
||||
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>> {
|
||||
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>>{
|
||||
std::nullopt,
|
||||
std::optional {
|
||||
ContentAddress {
|
||||
std::optional{
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
|
|
@ -420,18 +421,16 @@ TEST_F(ServeProtoTest, handshake_log)
|
|||
ServeProto::Version clientResult;
|
||||
|
||||
auto thread = std::thread([&]() {
|
||||
FdSink out { toServer.writeSide.get() };
|
||||
FdSource in0 { toClient.readSide.get() };
|
||||
TeeSource in { in0, toClientLog };
|
||||
clientResult = ServeProto::BasicClientConnection::handshake(
|
||||
out, in, defaultVersion, "blah");
|
||||
FdSink out{toServer.writeSide.get()};
|
||||
FdSource in0{toClient.readSide.get()};
|
||||
TeeSource in{in0, toClientLog};
|
||||
clientResult = ServeProto::BasicClientConnection::handshake(out, in, defaultVersion, "blah");
|
||||
});
|
||||
|
||||
{
|
||||
FdSink out { toClient.writeSide.get() };
|
||||
FdSource in { toServer.readSide.get() };
|
||||
ServeProto::BasicServerConnection::handshake(
|
||||
out, in, defaultVersion);
|
||||
FdSink out{toClient.writeSide.get()};
|
||||
FdSource in{toServer.readSide.get()};
|
||||
ServeProto::BasicServerConnection::handshake(out, in, defaultVersion);
|
||||
};
|
||||
|
||||
thread.join();
|
||||
|
|
@ -441,8 +440,9 @@ TEST_F(ServeProtoTest, handshake_log)
|
|||
}
|
||||
|
||||
/// Has to be a `BufferedSink` for handshake.
|
||||
struct NullBufferedSink : BufferedSink {
|
||||
void writeUnbuffered(std::string_view data) override { }
|
||||
struct NullBufferedSink : BufferedSink
|
||||
{
|
||||
void writeUnbuffered(std::string_view data) override {}
|
||||
};
|
||||
|
||||
TEST_F(ServeProtoTest, handshake_client_replay)
|
||||
|
|
@ -450,9 +450,8 @@ TEST_F(ServeProtoTest, handshake_client_replay)
|
|||
CharacterizationTest::readTest("handshake-to-client", [&](std::string toClientLog) {
|
||||
NullBufferedSink nullSink;
|
||||
|
||||
StringSource in { toClientLog };
|
||||
auto clientResult = ServeProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, "blah");
|
||||
StringSource in{toClientLog};
|
||||
auto clientResult = ServeProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, "blah");
|
||||
|
||||
EXPECT_EQ(clientResult, defaultVersion);
|
||||
});
|
||||
|
|
@ -486,23 +485,18 @@ TEST_F(ServeProtoTest, handshake_client_corrupted_throws)
|
|||
++toClientLogCorrupt[idx];
|
||||
|
||||
NullBufferedSink nullSink;
|
||||
StringSource in { toClientLogCorrupt };
|
||||
StringSource in{toClientLogCorrupt};
|
||||
|
||||
if (idx < 4 || idx == 9) {
|
||||
// magic bytes don't match
|
||||
EXPECT_THROW(
|
||||
ServeProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, "blah"),
|
||||
Error);
|
||||
EXPECT_THROW(ServeProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, "blah"), Error);
|
||||
} else if (idx < 8 || idx >= 12) {
|
||||
// Number out of bounds
|
||||
EXPECT_THROW(
|
||||
ServeProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, "blah"),
|
||||
ServeProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, "blah"),
|
||||
SerialisationError);
|
||||
} else {
|
||||
auto ver = ServeProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, "blah");
|
||||
auto ver = ServeProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, "blah");
|
||||
// `std::min` of this and the other version saves us
|
||||
EXPECT_EQ(ver, defaultVersion);
|
||||
}
|
||||
|
|
@ -510,4 +504,4 @@ TEST_F(ServeProtoTest, handshake_client_corrupted_throws)
|
|||
});
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -120,4 +120,4 @@ URI_TEST(
|
|||
.params = {},
|
||||
}))
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -25,13 +25,12 @@ struct WorkerProtoTest : VersionedProtoTest<WorkerProto, workerProtoDir>
|
|||
WorkerProto::Version defaultVersion = 1 << 8 | 10;
|
||||
};
|
||||
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
string,
|
||||
"string",
|
||||
defaultVersion,
|
||||
(std::tuple<std::string, std::string, std::string, std::string, std::string> {
|
||||
(std::tuple<std::string, std::string, std::string, std::string, std::string>{
|
||||
"",
|
||||
"hi",
|
||||
"white rabbit",
|
||||
|
|
@ -46,9 +45,9 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
storePath,
|
||||
"store-path",
|
||||
defaultVersion,
|
||||
(std::tuple<StorePath, StorePath> {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
|
||||
(std::tuple<StorePath, StorePath>{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -56,16 +55,16 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
contentAddress,
|
||||
"content-address",
|
||||
defaultVersion,
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
|
||||
ContentAddress {
|
||||
(std::tuple<ContentAddress, ContentAddress, ContentAddress>{
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Text,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "Derive(...)"),
|
||||
},
|
||||
ContentAddress {
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
ContentAddress {
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
},
|
||||
|
|
@ -78,21 +77,23 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
derivedPath_1_29,
|
||||
"derived-path-1.29",
|
||||
1 << 8 | 29,
|
||||
(std::tuple<DerivedPath, DerivedPath, DerivedPath> {
|
||||
DerivedPath::Opaque {
|
||||
.path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
(std::tuple<DerivedPath, DerivedPath, DerivedPath>{
|
||||
DerivedPath::Opaque{
|
||||
.path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::All { },
|
||||
DerivedPath::Built{
|
||||
.drvPath = makeConstantStorePathRef(
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::All{},
|
||||
},
|
||||
DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::Names { "x", "y" },
|
||||
DerivedPath::Built{
|
||||
.drvPath = makeConstantStorePathRef(
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::Names{"x", "y"},
|
||||
},
|
||||
}))
|
||||
|
||||
|
|
@ -101,24 +102,26 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
derivedPath_1_30,
|
||||
"derived-path-1.30",
|
||||
1 << 8 | 30,
|
||||
(std::tuple<DerivedPath, DerivedPath, DerivedPath, DerivedPath> {
|
||||
DerivedPath::Opaque {
|
||||
.path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
(std::tuple<DerivedPath, DerivedPath, DerivedPath, DerivedPath>{
|
||||
DerivedPath::Opaque{
|
||||
.path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
DerivedPath::Opaque {
|
||||
.path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv" },
|
||||
DerivedPath::Opaque{
|
||||
.path = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
|
||||
},
|
||||
DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::All { },
|
||||
DerivedPath::Built{
|
||||
.drvPath = makeConstantStorePathRef(
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::All{},
|
||||
},
|
||||
DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::Names { "x", "y" },
|
||||
DerivedPath::Built{
|
||||
.drvPath = makeConstantStorePathRef(
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::Names{"x", "y"},
|
||||
},
|
||||
}))
|
||||
|
||||
|
|
@ -127,12 +130,12 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
drvOutput,
|
||||
"drv-output",
|
||||
defaultVersion,
|
||||
(std::tuple<DrvOutput, DrvOutput> {
|
||||
(std::tuple<DrvOutput, DrvOutput>{
|
||||
{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
DrvOutput {
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
|
|
@ -143,115 +146,110 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
realisation,
|
||||
"realisation",
|
||||
defaultVersion,
|
||||
(std::tuple<Realisation, Realisation> {
|
||||
Realisation {
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.signatures = { "asdf", "qwer" },
|
||||
(std::tuple<Realisation, Realisation>{
|
||||
Realisation{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
.signatures = {"asdf", "qwer"},
|
||||
},
|
||||
Realisation {
|
||||
.id = {
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.signatures = { "asdf", "qwer" },
|
||||
.dependentRealisations = {
|
||||
Realisation{
|
||||
.id =
|
||||
{
|
||||
DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
.outputName = "baz",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
.signatures = {"asdf", "qwer"},
|
||||
.dependentRealisations =
|
||||
{
|
||||
{
|
||||
DrvOutput{
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "quux",
|
||||
},
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(WorkerProtoTest, buildResult_1_27, "build-result-1.27", 1 << 8 | 27, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
buildResult_1_27,
|
||||
"build-result-1.27",
|
||||
1 << 8 | 27,
|
||||
({
|
||||
WorkerProtoTest, buildResult_1_28, "build-result-1.28", 1 << 8 | 28, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
.builtOutputs =
|
||||
{
|
||||
{
|
||||
"foo",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
buildResult_1_28,
|
||||
"build-result-1.28",
|
||||
1 << 8 | 28,
|
||||
({
|
||||
WorkerProtoTest, buildResult_1_29, "build-result-1.29", 1 << 8 | 29, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
.status = BuildResult::Built,
|
||||
.builtOutputs = {
|
||||
{
|
||||
"foo",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
buildResult_1_29,
|
||||
"build-result-1.29",
|
||||
1 << 8 | 29,
|
||||
({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
|
|
@ -259,31 +257,36 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
.timesBuilt = 1,
|
||||
.builtOutputs = {
|
||||
.builtOutputs =
|
||||
{
|
||||
"foo",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
"foo",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar" },
|
||||
},
|
||||
},
|
||||
},
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
|
|
@ -292,18 +295,14 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
buildResult_1_37,
|
||||
"build-result-1.37",
|
||||
1 << 8 | 37,
|
||||
({
|
||||
WorkerProtoTest, buildResult_1_37, "build-result-1.37", 1 << 8 | 37, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t {
|
||||
BuildResult {
|
||||
std::tuple<BuildResult, BuildResult, BuildResult> t{
|
||||
BuildResult{
|
||||
.status = BuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
|
|
@ -311,31 +310,36 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
BuildResult {
|
||||
BuildResult{
|
||||
.status = BuildResult::Built,
|
||||
.timesBuilt = 1,
|
||||
.builtOutputs = {
|
||||
.builtOutputs =
|
||||
{
|
||||
"foo",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
"foo",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "foo",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id =
|
||||
DrvOutput{
|
||||
.drvHash =
|
||||
Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"bar",
|
||||
{
|
||||
.id = DrvOutput {
|
||||
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
|
||||
.outputName = "bar",
|
||||
},
|
||||
.outPath = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar" },
|
||||
},
|
||||
},
|
||||
},
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
.cpuUser = std::chrono::microseconds(500s),
|
||||
|
|
@ -345,51 +349,49 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
keyedBuildResult_1_29,
|
||||
"keyed-build-result-1.29",
|
||||
1 << 8 | 29,
|
||||
({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<KeyedBuildResult, KeyedBuildResult/*, KeyedBuildResult*/> t {
|
||||
KeyedBuildResult {
|
||||
{
|
||||
.status = KeyedBuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
/* .path = */ DerivedPath::Opaque {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-xxx" },
|
||||
},
|
||||
},
|
||||
KeyedBuildResult {
|
||||
{
|
||||
.status = KeyedBuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
.isNonDeterministic = true,
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
/* .path = */ DerivedPath::Built {
|
||||
.drvPath = makeConstantStorePathRef(StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::Names { "out" },
|
||||
},
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
VERSIONED_CHARACTERIZATION_TEST(WorkerProtoTest, keyedBuildResult_1_29, "keyed-build-result-1.29", 1 << 8 | 29, ({
|
||||
using namespace std::literals::chrono_literals;
|
||||
std::tuple<KeyedBuildResult, KeyedBuildResult /*, KeyedBuildResult*/> t{
|
||||
KeyedBuildResult{
|
||||
{
|
||||
.status = KeyedBuildResult::OutputRejected,
|
||||
.errorMsg = "no idea why",
|
||||
},
|
||||
/* .path = */
|
||||
DerivedPath::Opaque{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-xxx"},
|
||||
},
|
||||
},
|
||||
KeyedBuildResult{
|
||||
{
|
||||
.status = KeyedBuildResult::NotDeterministic,
|
||||
.errorMsg = "no idea why",
|
||||
.timesBuilt = 3,
|
||||
.isNonDeterministic = true,
|
||||
.startTime = 30,
|
||||
.stopTime = 50,
|
||||
},
|
||||
/* .path = */
|
||||
DerivedPath::Built{
|
||||
.drvPath = makeConstantStorePathRef(
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
}),
|
||||
.outputs = OutputsSpec::Names{"out"},
|
||||
},
|
||||
},
|
||||
};
|
||||
t;
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
WorkerProtoTest,
|
||||
unkeyedValidPathInfo_1_15,
|
||||
"unkeyed-valid-path-info-1.15",
|
||||
1 << 8 | 15,
|
||||
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo> {
|
||||
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
|
||||
({
|
||||
UnkeyedValidPathInfo info {
|
||||
UnkeyedValidPathInfo info{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
info.registrationTime = 23423;
|
||||
|
|
@ -397,14 +399,14 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
info;
|
||||
}),
|
||||
({
|
||||
UnkeyedValidPathInfo info {
|
||||
UnkeyedValidPathInfo info{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.references = {
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv",
|
||||
},
|
||||
};
|
||||
|
|
@ -419,13 +421,13 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
validPathInfo_1_15,
|
||||
"valid-path-info-1.15",
|
||||
1 << 8 | 15,
|
||||
(std::tuple<ValidPathInfo, ValidPathInfo> {
|
||||
(std::tuple<ValidPathInfo, ValidPathInfo>{
|
||||
({
|
||||
ValidPathInfo info {
|
||||
StorePath {
|
||||
ValidPathInfo info{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
UnkeyedValidPathInfo {
|
||||
UnkeyedValidPathInfo{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
},
|
||||
};
|
||||
|
|
@ -434,24 +436,24 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
info;
|
||||
}),
|
||||
({
|
||||
ValidPathInfo info {
|
||||
StorePath {
|
||||
ValidPathInfo info{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
UnkeyedValidPathInfo {
|
||||
UnkeyedValidPathInfo{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
},
|
||||
};
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.references = {
|
||||
// other reference
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo",
|
||||
},
|
||||
// self reference
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
};
|
||||
|
|
@ -466,13 +468,13 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
validPathInfo_1_16,
|
||||
"valid-path-info-1.16",
|
||||
1 << 8 | 16,
|
||||
(std::tuple<ValidPathInfo, ValidPathInfo, ValidPathInfo> {
|
||||
(std::tuple<ValidPathInfo, ValidPathInfo, ValidPathInfo>{
|
||||
({
|
||||
ValidPathInfo info {
|
||||
StorePath {
|
||||
ValidPathInfo info{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
UnkeyedValidPathInfo {
|
||||
UnkeyedValidPathInfo{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
},
|
||||
};
|
||||
|
|
@ -482,50 +484,53 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
info;
|
||||
}),
|
||||
({
|
||||
ValidPathInfo info {
|
||||
StorePath {
|
||||
ValidPathInfo info{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
UnkeyedValidPathInfo {
|
||||
UnkeyedValidPathInfo{
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
},
|
||||
};
|
||||
info.deriver = StorePath {
|
||||
info.deriver = StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||
};
|
||||
info.references = {
|
||||
// other reference
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo",
|
||||
},
|
||||
// self reference
|
||||
StorePath {
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
};
|
||||
info.registrationTime = 23423;
|
||||
info.narSize = 34878;
|
||||
info.sigs = {
|
||||
"fake-sig-1",
|
||||
"fake-sig-2",
|
||||
},
|
||||
info.sigs =
|
||||
{
|
||||
"fake-sig-1",
|
||||
"fake-sig-2",
|
||||
},
|
||||
info;
|
||||
}),
|
||||
({
|
||||
ValidPathInfo info {
|
||||
ValidPathInfo info{
|
||||
*LibStoreTest::store,
|
||||
"foo",
|
||||
FixedOutputInfo {
|
||||
FixedOutputInfo{
|
||||
.method = FileIngestionMethod::NixArchive,
|
||||
.hash = hashString(HashAlgorithm::SHA256, "(...)"),
|
||||
.references = {
|
||||
.others = {
|
||||
StorePath {
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
.references =
|
||||
{
|
||||
.others =
|
||||
{
|
||||
StorePath{
|
||||
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||
},
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
.self = true,
|
||||
},
|
||||
},
|
||||
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
|
||||
};
|
||||
|
|
@ -540,7 +545,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
buildMode,
|
||||
"build-mode",
|
||||
defaultVersion,
|
||||
(std::tuple<BuildMode, BuildMode, BuildMode> {
|
||||
(std::tuple<BuildMode, BuildMode, BuildMode>{
|
||||
bmNormal,
|
||||
bmRepair,
|
||||
bmCheck,
|
||||
|
|
@ -551,10 +556,10 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
optionalTrustedFlag,
|
||||
"optional-trusted-flag",
|
||||
defaultVersion,
|
||||
(std::tuple<std::optional<TrustedFlag>, std::optional<TrustedFlag>, std::optional<TrustedFlag>> {
|
||||
(std::tuple<std::optional<TrustedFlag>, std::optional<TrustedFlag>, std::optional<TrustedFlag>>{
|
||||
std::nullopt,
|
||||
std::optional { Trusted },
|
||||
std::optional { NotTrusted },
|
||||
std::optional{Trusted},
|
||||
std::optional{NotTrusted},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -562,11 +567,15 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
vector,
|
||||
"vector",
|
||||
defaultVersion,
|
||||
(std::tuple<std::vector<std::string>, std::vector<std::string>, std::vector<std::string>, std::vector<std::vector<std::string>>> {
|
||||
{ },
|
||||
{ "" },
|
||||
{ "", "foo", "bar" },
|
||||
{ {}, { "" }, { "", "1", "2" } },
|
||||
(std::tuple<
|
||||
std::vector<std::string>,
|
||||
std::vector<std::string>,
|
||||
std::vector<std::string>,
|
||||
std::vector<std::vector<std::string>>>{
|
||||
{},
|
||||
{""},
|
||||
{"", "foo", "bar"},
|
||||
{{}, {""}, {"", "1", "2"}},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -574,11 +583,11 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
set,
|
||||
"set",
|
||||
defaultVersion,
|
||||
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>> {
|
||||
{ },
|
||||
{ "" },
|
||||
{ "", "foo", "bar" },
|
||||
{ {}, { "" }, { "", "1", "2" } },
|
||||
(std::tuple<StringSet, StringSet, StringSet, std::set<StringSet>>{
|
||||
{},
|
||||
{""},
|
||||
{"", "foo", "bar"},
|
||||
{{}, {""}, {"", "1", "2"}},
|
||||
}))
|
||||
|
||||
VERSIONED_CHARACTERIZATION_TEST(
|
||||
|
|
@ -586,10 +595,10 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
optionalStorePath,
|
||||
"optional-store-path",
|
||||
defaultVersion,
|
||||
(std::tuple<std::optional<StorePath>, std::optional<StorePath>> {
|
||||
(std::tuple<std::optional<StorePath>, std::optional<StorePath>>{
|
||||
std::nullopt,
|
||||
std::optional {
|
||||
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
|
||||
std::optional{
|
||||
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"},
|
||||
},
|
||||
}))
|
||||
|
||||
|
|
@ -598,10 +607,10 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
optionalContentAddress,
|
||||
"optional-content-address",
|
||||
defaultVersion,
|
||||
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>> {
|
||||
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>>{
|
||||
std::nullopt,
|
||||
std::optional {
|
||||
ContentAddress {
|
||||
std::optional{
|
||||
ContentAddress{
|
||||
.method = ContentAddressMethod::Raw::Flat,
|
||||
.hash = hashString(HashAlgorithm::SHA1, "blob blob..."),
|
||||
},
|
||||
|
|
@ -613,7 +622,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
clientHandshakeInfo_1_30,
|
||||
"client-handshake-info_1_30",
|
||||
1 << 8 | 30,
|
||||
(std::tuple<WorkerProto::ClientHandshakeInfo> {
|
||||
(std::tuple<WorkerProto::ClientHandshakeInfo>{
|
||||
{},
|
||||
}))
|
||||
|
||||
|
|
@ -622,12 +631,12 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
clientHandshakeInfo_1_33,
|
||||
"client-handshake-info_1_33",
|
||||
1 << 8 | 33,
|
||||
(std::tuple<WorkerProto::ClientHandshakeInfo, WorkerProto::ClientHandshakeInfo> {
|
||||
(std::tuple<WorkerProto::ClientHandshakeInfo, WorkerProto::ClientHandshakeInfo>{
|
||||
{
|
||||
.daemonNixVersion = std::optional { "foo" },
|
||||
.daemonNixVersion = std::optional{"foo"},
|
||||
},
|
||||
{
|
||||
.daemonNixVersion = std::optional { "bar" },
|
||||
.daemonNixVersion = std::optional{"bar"},
|
||||
},
|
||||
}))
|
||||
|
||||
|
|
@ -636,14 +645,14 @@ VERSIONED_CHARACTERIZATION_TEST(
|
|||
clientHandshakeInfo_1_35,
|
||||
"client-handshake-info_1_35",
|
||||
1 << 8 | 35,
|
||||
(std::tuple<WorkerProto::ClientHandshakeInfo, WorkerProto::ClientHandshakeInfo> {
|
||||
(std::tuple<WorkerProto::ClientHandshakeInfo, WorkerProto::ClientHandshakeInfo>{
|
||||
{
|
||||
.daemonNixVersion = std::optional { "foo" },
|
||||
.remoteTrustsUs = std::optional { NotTrusted },
|
||||
.daemonNixVersion = std::optional{"foo"},
|
||||
.remoteTrustsUs = std::optional{NotTrusted},
|
||||
},
|
||||
{
|
||||
.daemonNixVersion = std::optional { "bar" },
|
||||
.remoteTrustsUs = std::optional { Trusted },
|
||||
.daemonNixVersion = std::optional{"bar"},
|
||||
.remoteTrustsUs = std::optional{Trusted},
|
||||
},
|
||||
}))
|
||||
|
||||
|
|
@ -659,18 +668,16 @@ TEST_F(WorkerProtoTest, handshake_log)
|
|||
WorkerProto::Version clientResult;
|
||||
|
||||
auto thread = std::thread([&]() {
|
||||
FdSink out { toServer.writeSide.get() };
|
||||
FdSource in0 { toClient.readSide.get() };
|
||||
TeeSource in { in0, toClientLog };
|
||||
clientResult = std::get<0>(WorkerProto::BasicClientConnection::handshake(
|
||||
out, in, defaultVersion, {}));
|
||||
FdSink out{toServer.writeSide.get()};
|
||||
FdSource in0{toClient.readSide.get()};
|
||||
TeeSource in{in0, toClientLog};
|
||||
clientResult = std::get<0>(WorkerProto::BasicClientConnection::handshake(out, in, defaultVersion, {}));
|
||||
});
|
||||
|
||||
{
|
||||
FdSink out { toClient.writeSide.get() };
|
||||
FdSource in { toServer.readSide.get() };
|
||||
WorkerProto::BasicServerConnection::handshake(
|
||||
out, in, defaultVersion, {});
|
||||
FdSink out{toClient.writeSide.get()};
|
||||
FdSource in{toServer.readSide.get()};
|
||||
WorkerProto::BasicServerConnection::handshake(out, in, defaultVersion, {});
|
||||
};
|
||||
|
||||
thread.join();
|
||||
|
|
@ -688,16 +695,14 @@ TEST_F(WorkerProtoTest, handshake_features)
|
|||
std::tuple<WorkerProto::Version, WorkerProto::FeatureSet> clientResult;
|
||||
|
||||
auto clientThread = std::thread([&]() {
|
||||
FdSink out { toServer.writeSide.get() };
|
||||
FdSource in { toClient.readSide.get() };
|
||||
clientResult = WorkerProto::BasicClientConnection::handshake(
|
||||
out, in, 123, {"bar", "aap", "mies", "xyzzy"});
|
||||
FdSink out{toServer.writeSide.get()};
|
||||
FdSource in{toClient.readSide.get()};
|
||||
clientResult = WorkerProto::BasicClientConnection::handshake(out, in, 123, {"bar", "aap", "mies", "xyzzy"});
|
||||
});
|
||||
|
||||
FdSink out { toClient.writeSide.get() };
|
||||
FdSource in { toServer.readSide.get() };
|
||||
auto daemonResult = WorkerProto::BasicServerConnection::handshake(
|
||||
out, in, 456, {"foo", "bar", "xyzzy"});
|
||||
FdSink out{toClient.writeSide.get()};
|
||||
FdSource in{toServer.readSide.get()};
|
||||
auto daemonResult = WorkerProto::BasicServerConnection::handshake(out, in, 456, {"foo", "bar", "xyzzy"});
|
||||
|
||||
clientThread.join();
|
||||
|
||||
|
|
@ -707,8 +712,9 @@ TEST_F(WorkerProtoTest, handshake_features)
|
|||
}
|
||||
|
||||
/// Has to be a `BufferedSink` for handshake.
|
||||
struct NullBufferedSink : BufferedSink {
|
||||
void writeUnbuffered(std::string_view data) override { }
|
||||
struct NullBufferedSink : BufferedSink
|
||||
{
|
||||
void writeUnbuffered(std::string_view data) override {}
|
||||
};
|
||||
|
||||
TEST_F(WorkerProtoTest, handshake_client_replay)
|
||||
|
|
@ -716,9 +722,9 @@ TEST_F(WorkerProtoTest, handshake_client_replay)
|
|||
CharacterizationTest::readTest("handshake-to-client", [&](std::string toClientLog) {
|
||||
NullBufferedSink nullSink;
|
||||
|
||||
StringSource in { toClientLog };
|
||||
auto clientResult = std::get<0>(WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, {}));
|
||||
StringSource in{toClientLog};
|
||||
auto clientResult =
|
||||
std::get<0>(WorkerProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, {}));
|
||||
|
||||
EXPECT_EQ(clientResult, defaultVersion);
|
||||
});
|
||||
|
|
@ -752,23 +758,18 @@ TEST_F(WorkerProtoTest, handshake_client_corrupted_throws)
|
|||
++toClientLogCorrupt[idx];
|
||||
|
||||
NullBufferedSink nullSink;
|
||||
StringSource in { toClientLogCorrupt };
|
||||
StringSource in{toClientLogCorrupt};
|
||||
|
||||
if (idx < 4 || idx == 9) {
|
||||
// magic bytes don't match
|
||||
EXPECT_THROW(
|
||||
WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, {}),
|
||||
Error);
|
||||
EXPECT_THROW(WorkerProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, {}), Error);
|
||||
} else if (idx < 8 || idx >= 12) {
|
||||
// Number out of bounds
|
||||
EXPECT_THROW(
|
||||
WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, {}),
|
||||
WorkerProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, {}),
|
||||
SerialisationError);
|
||||
} else {
|
||||
auto ver = std::get<0>(WorkerProto::BasicClientConnection::handshake(
|
||||
nullSink, in, defaultVersion, {}));
|
||||
auto ver = std::get<0>(WorkerProto::BasicClientConnection::handshake(nullSink, in, defaultVersion, {}));
|
||||
// `std::min` of this and the other version saves us
|
||||
EXPECT_EQ(ver, defaultVersion);
|
||||
}
|
||||
|
|
@ -776,4 +777,4 @@ TEST_F(WorkerProtoTest, handshake_client_corrupted_throws)
|
|||
});
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue