aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/build.sh4
-rw-r--r--tests/unit/libstore/filetransfer.cc8
-rw-r--r--tests/unit/libutil/compression.cc3
3 files changed, 12 insertions, 3 deletions
diff --git a/tests/functional/build.sh b/tests/functional/build.sh
index a14f6e3c2..58fba83aa 100644
--- a/tests/functional/build.sh
+++ b/tests/functional/build.sh
@@ -144,8 +144,8 @@ test "$(<<<"$out" grep -E '^error:' | wc -l)" = 1
# --keep-going and FOD
out="$(nix build -f fod-failing.nix -L 2>&1)" && status=0 || status=$?
test "$status" = 1
-# one "hash mismatch" error, one "build of ... failed"
-test "$(<<<"$out" grep -E '^error:' | wc -l)" = 2
+# at least one "hash mismatch" error, one "build of ... failed"
+test "$(<<<"$out" grep -E '^error:' | wc -l)" -ge 2
<<<"$out" grepQuiet -E "hash mismatch in fixed-output derivation '.*-x.\\.drv'"
<<<"$out" grepQuiet -E "likely URL: "
<<<"$out" grepQuiet -E "error: build of '.*-x[1-4]\\.drv\\^out', '.*-x[1-4]\\.drv\\^out', '.*-x[1-4]\\.drv\\^out', '.*-x[1-4]\\.drv\\^out' failed"
diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc
index 71e7392fc..fd4d326f0 100644
--- a/tests/unit/libstore/filetransfer.cc
+++ b/tests/unit/libstore/filetransfer.cc
@@ -150,6 +150,14 @@ TEST(FileTransfer, exceptionAbortsDownload)
}
}
+TEST(FileTransfer, exceptionAbortsRead)
+{
+ auto [port, srv] = serveHTTP("200 ok", "content-length: 0\r\n", [] { return ""; });
+ auto ft = makeFileTransfer();
+ char buf[10] = "";
+ ASSERT_THROW(ft->download(FileTransferRequest(fmt("http://[::1]:%d/index", port)))->read(buf, 10), EndOfFile);
+}
+
TEST(FileTransfer, NOT_ON_DARWIN(reportsSetupErrors))
{
auto [port, srv] = serveHTTP("404 not found", "", [] { return ""; });
diff --git a/tests/unit/libutil/compression.cc b/tests/unit/libutil/compression.cc
index 8d181f53d..6dd8c96df 100644
--- a/tests/unit/libutil/compression.cc
+++ b/tests/unit/libutil/compression.cc
@@ -1,4 +1,5 @@
#include "compression.hh"
+#include <cstddef>
#include <gtest/gtest.h>
namespace nix {
@@ -147,7 +148,7 @@ TEST_P(PerTypeNonNullCompressionTest, truncatedValidInput)
/* n.b. This also tests zero-length input, which is also invalid.
* As of the writing of this comment, it returns empty output, but is
* allowed to throw a compression error instead. */
- for (int i = 0; i < compressed.length(); ++i) {
+ for (size_t i = 0u; i < compressed.length(); ++i) {
auto newCompressed = compressed.substr(compressed.length() - i);
try {
decompress(method, newCompressed);