Commit 95340398 by Russell Belfer

Adding new tests for new status command

This is a work in progress.  This adds two new sets of tests,
the issue_592 tests from @nulltoken's pull request #601 and
some new tests for submodules.  The submodule tests still have
issues where the status is not reported correctly.  That needs
to be fixed before merge.
parent a48ea31d
......@@ -31,8 +31,7 @@ GIT_BEGIN_DECL
#define GIT_STATUS_WT_MODIFIED (1 << 4)
#define GIT_STATUS_WT_DELETED (1 << 5)
#define GIT_STATUS_IGNORED (1 << 6)
#define GIT_STATUS_WT_UNTRACKED (1 << 7)
#define GIT_STATUS_IGNORED (1 << 6)
/**
* Gather file statuses and run a callback for each one.
......
......@@ -2,7 +2,7 @@
#include "fileops.h"
#include "ignore.h"
#include "status_data.h"
#include "posix.h"
/**
* Auxiliary methods
......@@ -43,7 +43,6 @@ cb_status__count(const char *p, unsigned int s, void *payload)
return 0;
}
/**
* Initializer
*
......@@ -133,3 +132,87 @@ void test_status_worktree__ignores(void)
);
cl_assert(ignored);
}
static int cb_status__check_592(const char *p, unsigned int s, void *payload)
{
GIT_UNUSED(payload);
if (s != GIT_STATUS_WT_DELETED || (payload != NULL && strcmp(p, (const char *)payload) != 0))
return -1;
return 0;
}
void test_status_worktree__issue_592(void)
{
git_repository *repo;
git_buf path = GIT_BUF_INIT;
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "l.txt"));
cl_git_pass(p_unlink(git_buf_cstr(&path)));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "l.txt"));
git_buf_free(&path);
}
void test_status_worktree__issue_592_2(void)
{
git_repository *repo;
git_buf path = GIT_BUF_INIT;
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "c/a.txt"));
cl_git_pass(p_unlink(git_buf_cstr(&path)));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "c/a.txt"));
git_buf_free(&path);
}
void test_status_worktree__issue_592_3(void)
{
git_repository *repo;
git_buf path = GIT_BUF_INIT;
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "c"));
cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), 1));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "c/a.txt"));
git_buf_free(&path);
}
void test_status_worktree__issue_592_4(void)
{
git_repository *repo;
git_buf path = GIT_BUF_INIT;
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "t/b.txt"));
cl_git_pass(p_unlink(git_buf_cstr(&path)));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, "t/b.txt"));
git_buf_free(&path);
}
void test_status_worktree__issue_592_5(void)
{
git_repository *repo;
git_buf path = GIT_BUF_INIT;
repo = cl_git_sandbox_init("issue_592");
cl_git_pass(git_buf_joinpath(&path, git_repository_workdir(repo), "t"));
cl_git_pass(git_futils_rmdir_r(git_buf_cstr(&path), 1));
cl_git_pass(p_mkdir(git_buf_cstr(&path), 0777));
cl_git_pass(git_status_foreach(repo, cb_status__check_592, NULL));
git_buf_free(&path);
}
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
0000000000000000000000000000000000000000 4d383e87f0371ba8fa353f3912db6862b2625e85 nulltoken <emeric.fermas@gmail.com> 1331989635 +0100 commit (initial): Initial commit
4d383e87f0371ba8fa353f3912db6862b2625e85 e38fcc7a6060f5eb5b876e836b52ae4769363f21 nulltoken <emeric.fermas@gmail.com> 1332227062 +0100 commit (amend): Initial commit
0000000000000000000000000000000000000000 4d383e87f0371ba8fa353f3912db6862b2625e85 nulltoken <emeric.fermas@gmail.com> 1331989635 +0100 commit (initial): Initial commit
4d383e87f0371ba8fa353f3912db6862b2625e85 e38fcc7a6060f5eb5b876e836b52ae4769363f21 nulltoken <emeric.fermas@gmail.com> 1332227062 +0100 commit (amend): Initial commit
e38fcc7a6060f5eb5b876e836b52ae4769363f21
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
Unnamed repository; edit this file 'description' to name the repository.
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
ignored
09176a980273d801a3e37cc45c84af1366501ed9 refs/heads/master
0000000000000000000000000000000000000000 09176a980273d801a3e37cc45c84af1366501ed9 Russell Belfer <arrbee@arrbee.com> 1332365253 -0700 commit (initial): initial commit
0000000000000000000000000000000000000000 09176a980273d801a3e37cc45c84af1366501ed9 Russell Belfer <arrbee@arrbee.com> 1332365253 -0700 commit (initial): initial commit
P pack-b69d04bb39ac274669e2184e45bd90015d02ef5b.pack
# pack-refs with: peeled
09176a980273d801a3e37cc45c84af1366501ed9 refs/heads/master
[submodule "testrepo"]
path = testrepo
url =
\ No newline at end of file
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = /Users/rb/src/libgit2/tests/resources/testrepo.git
[branch "master"]
remote = origin
merge = refs/heads/master
Unnamed repository; edit this file 'description' to name the repository.
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
0000000000000000000000000000000000000000 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Russell Belfer <arrbee@arrbee.com> 1332366307 -0700 clone: from /Users/rb/src/libgit2/tests/resources/testrepo.git
0000000000000000000000000000000000000000 a65fedf39aefe402d3bb6e24df4d4f5fe4547750 Russell Belfer <arrbee@arrbee.com> 1332366307 -0700 clone: from /Users/rb/src/libgit2/tests/resources/testrepo.git
# pack-refs with: peeled
b25fa35b38051e4ae45d4222e795f9df2e43f1d1 refs/tags/test
^e90810b8df3e80c413d903f631643c716887138d
1385f264afb75a56a5bec74243be9b367ba4ca08 refs/tags/point_to_blob
7b4384978d2493e851f9cca7858815fac9b10980 refs/tags/e90810b
^e90810b8df3e80c413d903f631643c716887138d
e90810b8df3e80c413d903f631643c716887138d refs/remotes/origin/test
763d71aadf09a7951596c9746c024e7eece7c7af refs/remotes/origin/subtrees
4a202b346bb0fb0db7eff3cffeb3c70babbd2045 refs/remotes/origin/packed-test
41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9 refs/remotes/origin/packed
a65fedf39aefe402d3bb6e24df4d4f5fe4547750 refs/remotes/origin/master
a4a7dce85cf63874e984719f4fdd239f5145052f refs/remotes/origin/br2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment