diff options
Diffstat (limited to 'tests')
7 files changed, 76 insertions, 32 deletions
diff --git a/tests/functional/repl_characterization/data/no_nested_debuggers.nix b/tests/functional/repl_characterization/data/no_nested_debuggers.nix new file mode 100644 index 000000000..bf3ad7f0a --- /dev/null +++ b/tests/functional/repl_characterization/data/no_nested_debuggers.nix @@ -0,0 +1 @@ +builtins.break {} diff --git a/tests/functional/repl_characterization/data/no_nested_debuggers.test b/tests/functional/repl_characterization/data/no_nested_debuggers.test new file mode 100644 index 000000000..5e834a68a --- /dev/null +++ b/tests/functional/repl_characterization/data/no_nested_debuggers.test @@ -0,0 +1,39 @@ +we enter a debugger via builtins.break in the input file. + + info: breakpoint reached + +causing another debugger even should not nest, but simply +print the error, skip the breakpoint, etc as appropriate. + + nix-repl> "values show" + "values show" + + nix-repl> builtins.break 2 + 2 + + nix-repl> builtins.throw "foo" + error: + … while calling the 'throw' builtin + at «string»:1:1: + 1| builtins.throw "foo" + | ^ + + error: foo + + nix-repl> assert false; 2 + error: assertion 'false' failed + at «string»:1:1: + 1| assert false; 2 + | ^ + +exiting the debug frame should allow another to open. + + nix-repl> :c + + nix-repl> builtins.throw "bar" + error: bar + +and once again, more breakpoints are ignored. + + nix-repl> builtins.break 3 + 3 diff --git a/tests/functional/repl_characterization/repl_characterization.cc b/tests/functional/repl_characterization/repl_characterization.cc index d0c3b0a71..d46f09553 100644 --- a/tests/functional/repl_characterization/repl_characterization.cc +++ b/tests/functional/repl_characterization/repl_characterization.cc @@ -126,5 +126,6 @@ DEBUGGER_TEST(regression_9918); DEBUGGER_TEST(regression_9917); DEBUGGER_TEST(regression_l145); DEBUGGER_TEST(stack_vars); +DEBUGGER_TEST(no_nested_debuggers); }; diff --git a/tests/unit/libstore-support/tests/path.cc b/tests/unit/libstore-support/tests/path.cc index 8bf501ab6..ffc4fc607 100644 --- a/tests/unit/libstore-support/tests/path.cc +++ b/tests/unit/libstore-support/tests/path.cc @@ -32,13 +32,13 @@ Gen<StorePathName> Arbitrary<StorePathName>::arbitrary() for (size_t c = 0; c < len; ++c) { switch (auto i = *gen::inRange<uint8_t>(0, 10 + 2 * 26 + 6)) { case 0 ... 9: - pre += '0' + i; + pre += static_cast<uint8_t>('0' + i); break; case 10 ... 35: - pre += 'A' + (i - 10); + pre += static_cast<uint8_t>('A' + (i - 10)); break; case 36 ... 61: - pre += 'a' + (i - 36); + pre += static_cast<uint8_t>('a' + (i - 36)); break; case 62: pre += '+'; diff --git a/tests/unit/libstore/outputs-spec.cc b/tests/unit/libstore/outputs-spec.cc index 63cde681b..72a7da974 100644 --- a/tests/unit/libstore/outputs-spec.cc +++ b/tests/unit/libstore/outputs-spec.cc @@ -170,20 +170,22 @@ TEST(ExtendedOutputsSpec, many_carrot) { } -#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, \ + /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \ + ((nlohmann::json) TYPE { VAL })); \ + } \ + \ + TEST(TYPE, NAME ## _from_json) { \ + using nlohmann::literals::operator "" _json; \ + ASSERT_EQ( \ + /* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \ + TYPE { VAL }, \ + (STR ## _json).get<TYPE>()); \ } TEST_JSON(OutputsSpec, all, R"(["*"])", OutputsSpec::All { }) diff --git a/tests/unit/libutil-support/tests/terminal-code-eater.cc b/tests/unit/libutil-support/tests/terminal-code-eater.cc index ad05ed1f6..6e108009a 100644 --- a/tests/unit/libutil-support/tests/terminal-code-eater.cc +++ b/tests/unit/libutil-support/tests/terminal-code-eater.cc @@ -26,6 +26,7 @@ void TerminalCodeEater::feed(char c, std::function<void(char)> on_char) // Just eat \r, since it is part of clearing a line case '\r': return; + default: break; } if constexpr (DEBUG_EATER) { std::cerr << "eater uneat" << MaybeHexEscapedChar{c} << "\n"; diff --git a/tests/unit/libutil/pool.cc b/tests/unit/libutil/pool.cc index 127e42dda..3ad4ed3aa 100644 --- a/tests/unit/libutil/pool.cc +++ b/tests/unit/libutil/pool.cc @@ -65,21 +65,6 @@ namespace nix { ASSERT_EQ(pool.capacity(), 0); } - TEST(Pool, flushBadDropsOutOfScopeResources) { - auto isGood = [](const ref<TestResource> & r) { return false; }; - auto createResource = []() { return make_ref<TestResource>(); }; - - Pool<TestResource> pool = Pool<TestResource>((size_t)1, createResource, isGood); - - { - auto _r = pool.get(); - ASSERT_EQ(pool.count(), 1); - } - - pool.flushBad(); - ASSERT_EQ(pool.count(), 0); - } - // Test that the resources we allocate are being reused when they are still good. TEST(Pool, reuseResource) { auto isGood = [](const ref<TestResource> & r) { return true; }; @@ -124,4 +109,19 @@ namespace nix { ASSERT_NE(h->num, counter); } } + + TEST(Pool, throwingOperationDropsResource) + { + auto createResource = []() { return make_ref<TestResource>(); }; + + Pool<TestResource> pool = Pool<TestResource>((size_t)1, createResource); + + ASSERT_THROW({ + auto _r = pool.get(); + ASSERT_EQ(pool.count(), 1); + throw 1; + }, int); + + ASSERT_EQ(pool.count(), 0); + } } |