Skip to content

Commit

Permalink
Merge pull request libgit2#7025 from libgit2/ethomson/test_updates
Browse files Browse the repository at this point in the history
Test updates
  • Loading branch information
ethomson authored Jan 21, 2025
2 parents 346930e + c48364c commit 99dbff8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions tests/libgit2/config/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ void test_config_global__initialize(void)
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, path.ptr));

cl_git_pass(git_futils_mkdir_r("programdata", 0777));
cl_git_pass(git_fs_path_prettify(&path, "programdata", NULL));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_PROGRAMDATA, path.ptr));

git_str_dispose(&path);
}

Expand Down
21 changes: 17 additions & 4 deletions tests/libgit2/filter/systemattrs.c
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
#include "clar_libgit2.h"
#include "crlf.h"
#include "path.h"
#include "futils.h"

static git_repository *g_repo = NULL;
static git_str orig_system_path = GIT_STR_INIT;
static git_str system_attr_path = GIT_STR_INIT;

void test_filter_systemattrs__initialize(void)
{
git_buf system_path = GIT_BUF_INIT;
git_str new_system_path = GIT_BUF_INIT;

g_repo = cl_git_sandbox_init("crlf");
cl_must_pass(p_unlink("crlf/.gitattributes"));

cl_git_pass(git_libgit2_opts(
GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, &system_path));
GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, &orig_system_path));

cl_git_pass(git_str_joinpath(&new_system_path,
clar_sandbox_path(), "_system_path"));
cl_git_pass(git_futils_mkdir_r(new_system_path.ptr, 0777));
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, new_system_path.ptr));

cl_git_pass(git_str_joinpath(&system_attr_path,
system_path.ptr, "gitattributes"));
new_system_path.ptr, "gitattributes"));

cl_git_mkfile(system_attr_path.ptr,
"*.txt text\n"
"*.bin binary\n"
"*.crlf text eol=crlf\n"
"*.lf text eol=lf\n");

git_buf_dispose(&system_path);
git_str_dispose(&new_system_path);
}

void test_filter_systemattrs__cleanup(void)
{
cl_git_pass(git_libgit2_opts(
GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_SYSTEM, orig_system_path.ptr));

cl_must_pass(p_unlink(system_attr_path.ptr));
git_str_dispose(&system_attr_path);
git_str_dispose(&orig_system_path);

cl_git_sandbox_cleanup();
}
Expand Down

0 comments on commit 99dbff8

Please sign in to comment.