diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-02-05 11:06:01 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-02-05 11:59:03 -0500 |
commit | 865baaf928bd29274c753d85db59a324d4bd8b82 (patch) | |
tree | add5c4929f8152ddc2a7f52034ba67d1021e59c9 /tests/repo | |
parent | 9bf5bd7cd89502826cc0223ec43aba15ad30fac7 (diff) | |
download | libgit2-865baaf928bd29274c753d85db59a324d4bd8b82.tar.gz |
repo: ensure we can create repo at filesystem root
Test to ensure that we can create a repository at the filesystem
root. Introduces a new test environment variable,
`GITTEST_INVASIVE_FILESYSTEM` for tests that do terrible things like
escaping the clar sandbox and writing to the root directory. It is
expected that the CI builds will enable this but that normal people
would not want this.
Diffstat (limited to 'tests/repo')
-rw-r--r-- | tests/repo/init.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/repo/init.c b/tests/repo/init.c index ed86f6e4f..91747c9f5 100644 --- a/tests/repo/init.c +++ b/tests/repo/init.c @@ -714,3 +714,29 @@ void test_repo_init__init_with_initial_commit(void) git_index_free(index); } + +void test_repo_init__at_filesystem_root(void) +{ + git_repository *repo; + const char *sandbox = clar_sandbox_path(); + git_buf root = GIT_BUF_INIT; + int root_len; + + if (!cl_getenv("GITTEST_INVASIVE_FILESYSTEM")) + cl_skip(); + + root_len = git_path_root(sandbox); + cl_assert(root_len >= 0); + + git_buf_put(&root, sandbox, root_len+1); + git_buf_joinpath(&root, root.ptr, "libgit2_test_dir"); + + cl_assert(!git_path_exists(root.ptr)); + + cl_git_pass(git_repository_init(&repo, root.ptr, 0)); + cl_assert(git_path_isdir(root.ptr)); + cl_git_pass(git_futils_rmdir_r(root.ptr, NULL, GIT_RMDIR_REMOVE_FILES)); + + git_buf_free(&root); + git_repository_free(repo); +} |