mirror of
https://github.com/NixOS/nix
synced 2025-06-28 05:21:16 +02:00
Add nix-flake-c, nix_flake_init_global, nix_flake_settings_new
This commit is contained in:
parent
f06f611ff3
commit
4eecf3c20a
15 changed files with 307 additions and 0 deletions
|
@ -19,6 +19,7 @@ subdir('build-utils-meson/deps-lists')
|
|||
deps_private_maybe_subproject = [
|
||||
dependency('nix-expr-test-support'),
|
||||
dependency('nix-flake'),
|
||||
dependency('nix-flake-c'),
|
||||
]
|
||||
deps_public_maybe_subproject = [
|
||||
]
|
||||
|
@ -46,6 +47,7 @@ subdir('build-utils-meson/common')
|
|||
|
||||
sources = files(
|
||||
'flakeref.cc',
|
||||
'nix_api_flake.cc',
|
||||
'url-name.cc',
|
||||
)
|
||||
|
||||
|
@ -68,6 +70,7 @@ test(
|
|||
this_exe,
|
||||
env : {
|
||||
'_NIX_TEST_UNIT_DATA': meson.current_source_dir() / 'data',
|
||||
'NIX_CONFIG': 'extra-experimental-features = flakes',
|
||||
},
|
||||
protocol : 'gtest',
|
||||
)
|
||||
|
|
51
src/libflake-tests/nix_api_flake.cc
Normal file
51
src/libflake-tests/nix_api_flake.cc
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include "nix_api_store.h"
|
||||
#include "nix_api_store_internal.h"
|
||||
#include "nix_api_util.h"
|
||||
#include "nix_api_util_internal.h"
|
||||
#include "nix_api_expr.h"
|
||||
#include "nix_api_value.h"
|
||||
#include "nix_api_flake.h"
|
||||
|
||||
#include "tests/nix_api_expr.hh"
|
||||
#include "tests/string_callback.hh"
|
||||
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace nixC {
|
||||
|
||||
TEST_F(nix_api_store_test, nix_api_init_global_getFlake_exists)
|
||||
{
|
||||
nix_libstore_init(ctx);
|
||||
assert_ctx_ok();
|
||||
nix_libexpr_init(ctx);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto settings = nix_flake_settings_new(ctx);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, settings);
|
||||
|
||||
nix_flake_init_global(ctx, settings);
|
||||
assert_ctx_ok();
|
||||
|
||||
nix_eval_state_builder * builder = nix_eval_state_builder_new(ctx, store);
|
||||
ASSERT_NE(nullptr, builder);
|
||||
assert_ctx_ok();
|
||||
|
||||
auto state = nix_eval_state_build(ctx, builder);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, state);
|
||||
|
||||
nix_eval_state_builder_free(builder);
|
||||
|
||||
auto value = nix_alloc_value(ctx, state);
|
||||
assert_ctx_ok();
|
||||
ASSERT_NE(nullptr, value);
|
||||
|
||||
nix_err err = nix_expr_eval_from_string(ctx, state, "builtins.getFlake", ".", value);
|
||||
assert_ctx_ok();
|
||||
ASSERT_EQ(NIX_OK, err);
|
||||
ASSERT_EQ(NIX_TYPE_FUNCTION, nix_get_type(ctx, value));
|
||||
}
|
||||
|
||||
} // namespace nixC
|
|
@ -4,6 +4,7 @@
|
|||
, mkMesonExecutable
|
||||
|
||||
, nix-flake
|
||||
, nix-flake-c
|
||||
, nix-expr-test-support
|
||||
|
||||
, rapidcheck
|
||||
|
@ -38,6 +39,7 @@ mkMesonExecutable (finalAttrs: {
|
|||
|
||||
buildInputs = [
|
||||
nix-flake
|
||||
nix-flake-c
|
||||
nix-expr-test-support
|
||||
rapidcheck
|
||||
gtest
|
||||
|
@ -67,6 +69,7 @@ mkMesonExecutable (finalAttrs: {
|
|||
mkdir -p "$HOME"
|
||||
'' + ''
|
||||
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
|
||||
export NIX_CONFIG="extra-experimental-features = flakes"
|
||||
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
|
||||
touch $out
|
||||
'');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue