aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjade <lix@jade.fyi>2024-08-08 22:43:10 +0000
committerGerrit Code Review <gerrit@localhost>2024-08-08 22:43:10 +0000
commit757041c3e74787c755b3de826078968119f706d6 (patch)
tree9f3ea456c45130fb3a0910f9a9be9f60a74577cc /tests
parente03cd8b3a6f70c60f359fd683c2b25f8eba4da0d (diff)
parent4ed8461cacced97717bf9a7525e12ba69fe168c0 (diff)
Merge changes I526cceed,Ia4e2f1fa,I22e66972,I9fbd55a9,Ifca22e44 into main
* changes: sqlite: add a Use::fromStrNullable util: implement charptr_cast tree-wide: fix a pile of lints refactor: make HashType and Base enum classes for type safety build: integrate clang-tidy into CI
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/libstore/common-protocol.cc8
-rw-r--r--tests/unit/libstore/derivation.cc4
-rw-r--r--tests/unit/libstore/filetransfer.cc3
-rw-r--r--tests/unit/libstore/serve-protocol.cc10
-rw-r--r--tests/unit/libstore/worker-protocol.cc10
-rw-r--r--tests/unit/libutil-support/tests/hash.cc4
-rw-r--r--tests/unit/libutil/closure.cc2
-rw-r--r--tests/unit/libutil/generator.cc5
-rw-r--r--tests/unit/libutil/hash.cc16
-rw-r--r--tests/unit/libutil/tests.cc6
10 files changed, 36 insertions, 32 deletions
diff --git a/tests/unit/libstore/common-protocol.cc b/tests/unit/libstore/common-protocol.cc
index 86ba537db..9523c9acb 100644
--- a/tests/unit/libstore/common-protocol.cc
+++ b/tests/unit/libstore/common-protocol.cc
@@ -102,15 +102,15 @@ CHARACTERIZATION_TEST(
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
ContentAddress {
.method = TextIngestionMethod {},
- .hash = hashString(HashType::htSHA256, "Derive(...)"),
+ .hash = hashString(HashType::SHA256, "Derive(...)"),
},
ContentAddress {
.method = FileIngestionMethod::Flat,
- .hash = hashString(HashType::htSHA1, "blob blob..."),
+ .hash = hashString(HashType::SHA1, "blob blob..."),
},
ContentAddress {
.method = FileIngestionMethod::Recursive,
- .hash = hashString(HashType::htSHA256, "(...)"),
+ .hash = hashString(HashType::SHA256, "(...)"),
},
}))
@@ -197,7 +197,7 @@ CHARACTERIZATION_TEST(
std::optional {
ContentAddress {
.method = FileIngestionMethod::Flat,
- .hash = hashString(HashType::htSHA1, "blob blob..."),
+ .hash = hashString(HashType::SHA1, "blob blob..."),
},
},
}))
diff --git a/tests/unit/libstore/derivation.cc b/tests/unit/libstore/derivation.cc
index ca0cdff71..f6401a095 100644
--- a/tests/unit/libstore/derivation.cc
+++ b/tests/unit/libstore/derivation.cc
@@ -148,7 +148,7 @@ TEST_JSON(DynDerivationTest, caFixedText,
TEST_JSON(CaDerivationTest, caFloating,
(DerivationOutput::CAFloating {
.method = FileIngestionMethod::Recursive,
- .hashType = htSHA256,
+ .hashType = HashType::SHA256,
}),
"drv-name", "output-name")
@@ -159,7 +159,7 @@ TEST_JSON(DerivationTest, deferred,
TEST_JSON(ImpureDerivationTest, impure,
(DerivationOutput::Impure {
.method = FileIngestionMethod::Recursive,
- .hashType = htSHA256,
+ .hashType = HashType::SHA256,
}),
"drv-name", "output-name")
diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc
index 6e8cf3bbe..71e7392fc 100644
--- a/tests/unit/libstore/filetransfer.cc
+++ b/tests/unit/libstore/filetransfer.cc
@@ -6,7 +6,6 @@
#include <future>
#include <gtest/gtest.h>
#include <netinet/in.h>
-#include <stdexcept>
#include <string>
#include <string_view>
#include <sys/poll.h>
@@ -130,7 +129,7 @@ serveHTTP(std::string status, std::string headers, std::function<std::string()>
TEST(FileTransfer, exceptionAbortsDownload)
{
- struct Done
+ struct Done : std::exception
{};
auto ft = makeFileTransfer();
diff --git a/tests/unit/libstore/serve-protocol.cc b/tests/unit/libstore/serve-protocol.cc
index 6cc60ca3e..c6793be74 100644
--- a/tests/unit/libstore/serve-protocol.cc
+++ b/tests/unit/libstore/serve-protocol.cc
@@ -53,15 +53,15 @@ VERSIONED_CHARACTERIZATION_TEST(
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
ContentAddress {
.method = TextIngestionMethod {},
- .hash = hashString(HashType::htSHA256, "Derive(...)"),
+ .hash = hashString(HashType::SHA256, "Derive(...)"),
},
ContentAddress {
.method = FileIngestionMethod::Flat,
- .hash = hashString(HashType::htSHA1, "blob blob..."),
+ .hash = hashString(HashType::SHA1, "blob blob..."),
},
ContentAddress {
.method = FileIngestionMethod::Recursive,
- .hash = hashString(HashType::htSHA256, "(...)"),
+ .hash = hashString(HashType::SHA256, "(...)"),
},
}))
@@ -278,7 +278,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"foo",
FixedOutputInfo {
.method = FileIngestionMethod::Recursive,
- .hash = hashString(HashType::htSHA256, "(...)"),
+ .hash = hashString(HashType::SHA256, "(...)"),
.references = {
.others = {
StorePath {
@@ -348,7 +348,7 @@ VERSIONED_CHARACTERIZATION_TEST(
std::optional {
ContentAddress {
.method = FileIngestionMethod::Flat,
- .hash = hashString(HashType::htSHA1, "blob blob..."),
+ .hash = hashString(HashType::SHA1, "blob blob..."),
},
},
}))
diff --git a/tests/unit/libstore/worker-protocol.cc b/tests/unit/libstore/worker-protocol.cc
index f36de9cf9..92a33f595 100644
--- a/tests/unit/libstore/worker-protocol.cc
+++ b/tests/unit/libstore/worker-protocol.cc
@@ -55,15 +55,15 @@ VERSIONED_CHARACTERIZATION_TEST(
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
ContentAddress {
.method = TextIngestionMethod {},
- .hash = hashString(HashType::htSHA256, "Derive(...)"),
+ .hash = hashString(HashType::SHA256, "Derive(...)"),
},
ContentAddress {
.method = FileIngestionMethod::Flat,
- .hash = hashString(HashType::htSHA1, "blob blob..."),
+ .hash = hashString(HashType::SHA1, "blob blob..."),
},
ContentAddress {
.method = FileIngestionMethod::Recursive,
- .hash = hashString(HashType::htSHA256, "(...)"),
+ .hash = hashString(HashType::SHA256, "(...)"),
},
}))
@@ -417,7 +417,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"foo",
FixedOutputInfo {
.method = FileIngestionMethod::Recursive,
- .hash = hashString(HashType::htSHA256, "(...)"),
+ .hash = hashString(HashType::SHA256, "(...)"),
.references = {
.others = {
StorePath {
@@ -492,7 +492,7 @@ VERSIONED_CHARACTERIZATION_TEST(
std::optional {
ContentAddress {
.method = FileIngestionMethod::Flat,
- .hash = hashString(HashType::htSHA1, "blob blob..."),
+ .hash = hashString(HashType::SHA1, "blob blob..."),
},
},
}))
diff --git a/tests/unit/libutil-support/tests/hash.cc b/tests/unit/libutil-support/tests/hash.cc
index 7cc994b40..1ff31ae6a 100644
--- a/tests/unit/libutil-support/tests/hash.cc
+++ b/tests/unit/libutil-support/tests/hash.cc
@@ -11,11 +11,11 @@ using namespace nix;
Gen<Hash> Arbitrary<Hash>::arbitrary()
{
- Hash prototype(htSHA1);
+ Hash prototype(HashType::SHA1);
return
gen::apply(
[](const std::vector<uint8_t> & v) {
- Hash hash(htSHA1);
+ Hash hash(HashType::SHA1);
assert(v.size() == hash.hashSize);
std::copy(v.begin(), v.end(), hash.hash);
return hash;
diff --git a/tests/unit/libutil/closure.cc b/tests/unit/libutil/closure.cc
index b4eaad6f9..8cac9a9fd 100644
--- a/tests/unit/libutil/closure.cc
+++ b/tests/unit/libutil/closure.cc
@@ -28,7 +28,7 @@ TEST(closure, correctClosure) {
}
TEST(closure, properlyHandlesDirectExceptions) {
- struct TestExn {};
+ struct TestExn : std::exception {};
EXPECT_THROW(
computeClosure<string>(
{"A"},
diff --git a/tests/unit/libutil/generator.cc b/tests/unit/libutil/generator.cc
index 800e6ca8a..22cc085f9 100644
--- a/tests/unit/libutil/generator.cc
+++ b/tests/unit/libutil/generator.cc
@@ -85,6 +85,7 @@ TEST(Generator, nestsExceptions)
co_yield 1;
co_yield []() -> Generator<int> {
co_yield 9;
+ // NOLINTNEXTLINE(hicpp-exception-baseclass)
throw 1;
co_yield 10;
}();
@@ -101,6 +102,7 @@ TEST(Generator, exception)
{
auto g = []() -> Generator<int> {
co_yield 1;
+ // NOLINTNEXTLINE(hicpp-exception-baseclass)
throw 1;
}();
@@ -110,6 +112,7 @@ TEST(Generator, exception)
}
{
auto g = []() -> Generator<int> {
+ // NOLINTNEXTLINE(hicpp-exception-baseclass)
throw 1;
co_return;
}();
@@ -173,11 +176,13 @@ struct ThrowTransform
int operator()(bool)
{
+ // NOLINTNEXTLINE(hicpp-exception-baseclass)
throw 2;
}
Generator<int, void> operator()(Generator<int> && inner)
{
+ // NOLINTNEXTLINE(hicpp-exception-baseclass)
throw false;
}
};
diff --git a/tests/unit/libutil/hash.cc b/tests/unit/libutil/hash.cc
index 1f40edc95..6c24eda10 100644
--- a/tests/unit/libutil/hash.cc
+++ b/tests/unit/libutil/hash.cc
@@ -13,28 +13,28 @@ namespace nix {
TEST(hashString, testKnownMD5Hashes1) {
// values taken from: https://tools.ietf.org/html/rfc1321
auto s1 = "";
- auto hash = hashString(HashType::htMD5, s1);
+ auto hash = hashString(HashType::MD5, s1);
ASSERT_EQ(hash.to_string(Base::Base16, true), "md5:d41d8cd98f00b204e9800998ecf8427e");
}
TEST(hashString, testKnownMD5Hashes2) {
// values taken from: https://tools.ietf.org/html/rfc1321
auto s2 = "abc";
- auto hash = hashString(HashType::htMD5, s2);
+ auto hash = hashString(HashType::MD5, s2);
ASSERT_EQ(hash.to_string(Base::Base16, true), "md5:900150983cd24fb0d6963f7d28e17f72");
}
TEST(hashString, testKnownSHA1Hashes1) {
// values taken from: https://tools.ietf.org/html/rfc3174
auto s = "abc";
- auto hash = hashString(HashType::htSHA1, s);
+ auto hash = hashString(HashType::SHA1, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),"sha1:a9993e364706816aba3e25717850c26c9cd0d89d");
}
TEST(hashString, testKnownSHA1Hashes2) {
// values taken from: https://tools.ietf.org/html/rfc3174
auto s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
- auto hash = hashString(HashType::htSHA1, s);
+ auto hash = hashString(HashType::SHA1, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),"sha1:84983e441c3bd26ebaae4aa1f95129e5e54670f1");
}
@@ -42,7 +42,7 @@ namespace nix {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abc";
- auto hash = hashString(HashType::htSHA256, s);
+ auto hash = hashString(HashType::SHA256, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
}
@@ -50,7 +50,7 @@ namespace nix {
TEST(hashString, testKnownSHA256Hashes2) {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
- auto hash = hashString(HashType::htSHA256, s);
+ auto hash = hashString(HashType::SHA256, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha256:248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
}
@@ -58,7 +58,7 @@ namespace nix {
TEST(hashString, testKnownSHA512Hashes1) {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abc";
- auto hash = hashString(HashType::htSHA512, s);
+ auto hash = hashString(HashType::SHA512, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha512:ddaf35a193617abacc417349ae20413112e6fa4e89a9"
"7ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd"
@@ -68,7 +68,7 @@ namespace nix {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
- auto hash = hashString(HashType::htSHA512, s);
+ auto hash = hashString(HashType::SHA512, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha512:8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa1"
"7299aeadb6889018501d289e4900f7e4331b99dec4b5433a"
diff --git a/tests/unit/libutil/tests.cc b/tests/unit/libutil/tests.cc
index 9a44ad59b..29a5f7164 100644
--- a/tests/unit/libutil/tests.cc
+++ b/tests/unit/libutil/tests.cc
@@ -29,12 +29,12 @@ namespace nix {
char cwd[PATH_MAX+1];
auto p = absPath("");
- ASSERT_EQ(p, getcwd((char*)&cwd, PATH_MAX));
+ ASSERT_EQ(p, getcwd(cwd, PATH_MAX));
}
TEST(absPath, usesOptionalBasePathWhenGiven) {
char _cwd[PATH_MAX+1];
- char* cwd = getcwd((char*)&_cwd, PATH_MAX);
+ char* cwd = getcwd(_cwd, PATH_MAX);
auto p = absPath("", cwd);
@@ -43,7 +43,7 @@ namespace nix {
TEST(absPath, isIdempotent) {
char _cwd[PATH_MAX+1];
- char* cwd = getcwd((char*)&_cwd, PATH_MAX);
+ char* cwd = getcwd(_cwd, PATH_MAX);
auto p1 = absPath(cwd);
auto p2 = absPath(p1);