From 147593d9af3aee24ef438ad87754e1643455181c Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 21 Apr 2024 14:33:38 +0200 Subject: [PATCH] tests/libexpr: Re-enable C api tests that build Fixed in https://github.com/NixOS/nix/pull/10562 Building in unit tests should perhaps be kept to a minimum, but I have to note: * single derivations are pretty fast to build * we need to be able to build in various environment for the functional tests anyway * this was the only way to test that part of the C API * mocking only works if you have exceptionally good interfaces and the mocking code is reviewed over and over, if it works at all For what it's worth, I think we can have an "exceptionally good interface", in the form of https://github.com/NixOS/nix/issues/10579 Until that's been worked out, these cheap builds are fine to run in unit tests. --- tests/unit/libexpr/nix_api_expr.cc | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/unit/libexpr/nix_api_expr.cc b/tests/unit/libexpr/nix_api_expr.cc index 45aa5eb2b95..0818f1cabac 100644 --- a/tests/unit/libexpr/nix_api_expr.cc +++ b/tests/unit/libexpr/nix_api_expr.cc @@ -61,7 +61,6 @@ TEST_F(nix_api_expr_test, nix_expr_eval_drv) nix_state_free(stateResult); } -#if 0 TEST_F(nix_api_expr_test, nix_build_drv) { auto expr = R"(derivation { name = "myname"; @@ -105,7 +104,6 @@ TEST_F(nix_api_expr_test, nix_build_drv) nix_store_path_free(drvStorePath); nix_store_path_free(outStorePath); } -#endif TEST_F(nix_api_expr_test, nix_expr_realise_context_bad_value) { @@ -118,7 +116,6 @@ TEST_F(nix_api_expr_test, nix_expr_realise_context_bad_value) ASSERT_THAT(ctx->last_err, testing::Optional(testing::HasSubstr("cannot coerce"))); } -#if 0 TEST_F(nix_api_expr_test, nix_expr_realise_context_bad_build) { auto expr = R"( @@ -135,9 +132,7 @@ TEST_F(nix_api_expr_test, nix_expr_realise_context_bad_build) ASSERT_EQ(ctx->last_err_code, NIX_ERR_NIX_ERROR); ASSERT_THAT(ctx->last_err, testing::Optional(testing::HasSubstr("failed with exit code 1"))); } -#endif -#if 0 TEST_F(nix_api_expr_test, nix_expr_realise_context) { // TODO (ca-derivations): add a content-addressed derivation output, which produces a placeholder @@ -195,6 +190,5 @@ TEST_F(nix_api_expr_test, nix_expr_realise_context) nix_realised_string_free(r); } -#endif } // namespace nixC