Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
d0921127
Commit
d0921127
authored
Jun 29, 2018
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add a helper to build sandbox subpaths quickly
parent
83c35f7e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
20 deletions
+39
-20
tests/clar_libgit2.c
+29
-0
tests/clar_libgit2.h
+7
-0
tests/worktree/open.c
+3
-20
No files found.
tests/clar_libgit2.c
View file @
d0921127
...
...
@@ -319,6 +319,35 @@ const char* cl_git_path_url(const char *path)
return
url
;
}
const
char
*
cl_git_sandbox_path
(
int
is_dir
,
...)
{
const
char
*
path
=
NULL
;
static
char
_temp
[
GIT_PATH_MAX
];
git_buf
buf
=
GIT_BUF_INIT
;
va_list
arg
;
cl_git_pass
(
git_buf_sets
(
&
buf
,
clar_sandbox_path
()));
va_start
(
arg
,
is_dir
);
while
((
path
=
va_arg
(
arg
,
const
char
*
))
!=
NULL
)
{
cl_git_pass
(
git_buf_joinpath
(
&
buf
,
buf
.
ptr
,
path
));
}
va_end
(
arg
);
cl_git_pass
(
git_path_prettify
(
&
buf
,
buf
.
ptr
,
NULL
));
if
(
is_dir
)
git_path_to_dir
(
&
buf
);
/* make sure we won't truncate */
cl_assert
(
git_buf_len
(
&
buf
)
<
sizeof
(
_temp
));
git_buf_copy_cstr
(
_temp
,
sizeof
(
_temp
),
&
buf
);
git_buf_dispose
(
&
buf
);
return
_temp
;
}
typedef
struct
{
const
char
*
filename
;
size_t
filename_len
;
...
...
tests/clar_libgit2.h
View file @
d0921127
...
...
@@ -181,6 +181,13 @@ git_repository *cl_git_sandbox_init_new(const char *name);
void
cl_git_sandbox_cleanup
(
void
);
git_repository
*
cl_git_sandbox_reopen
(
void
);
/*
* build a sandbox-relative from path segments
* is_dir will add a trailing slash
* vararg must be a NULL-terminated char * list
*/
const
char
*
cl_git_sandbox_path
(
int
is_dir
,
...);
/* Local-repo url helpers */
const
char
*
cl_git_fixture_url
(
const
char
*
fixturename
);
const
char
*
cl_git_path_url
(
const
char
*
path
);
...
...
tests/worktree/open.c
View file @
d0921127
...
...
@@ -11,28 +11,11 @@ static worktree_fixture fixture =
static
void
assert_worktree_valid
(
git_repository
*
wt
,
const
char
*
parentdir
,
const
char
*
wtdir
)
{
git_buf
path
=
GIT_BUF_INIT
;
cl_assert
(
wt
->
is_worktree
);
cl_git_pass
(
git_buf_joinpath
(
&
path
,
clar_sandbox_path
(),
wtdir
));
cl_git_pass
(
git_path_prettify
(
&
path
,
path
.
ptr
,
NULL
));
cl_git_pass
(
git_path_to_dir
(
&
path
));
cl_assert_equal_s
(
wt
->
workdir
,
path
.
ptr
);
cl_git_pass
(
git_buf_joinpath
(
&
path
,
path
.
ptr
,
".git"
));
cl_git_pass
(
git_path_prettify
(
&
path
,
path
.
ptr
,
NULL
));
cl_assert_equal_s
(
wt
->
gitlink
,
path
.
ptr
);
cl_git_pass
(
git_buf_joinpath
(
&
path
,
clar_sandbox_path
(),
parentdir
));
cl_git_pass
(
git_buf_joinpath
(
&
path
,
path
.
ptr
,
".git"
));
cl_git_pass
(
git_buf_joinpath
(
&
path
,
path
.
ptr
,
"worktrees"
));
cl_git_pass
(
git_buf_joinpath
(
&
path
,
path
.
ptr
,
wtdir
));
cl_git_pass
(
git_path_prettify
(
&
path
,
path
.
ptr
,
NULL
));
cl_git_pass
(
git_path_to_dir
(
&
path
));
cl_assert_equal_s
(
wt
->
gitdir
,
path
.
ptr
);
git_buf_dispose
(
&
path
);
cl_assert_equal_s
(
wt
->
workdir
,
cl_git_sandbox_path
(
1
,
wtdir
,
NULL
));
cl_assert_equal_s
(
wt
->
gitlink
,
cl_git_sandbox_path
(
0
,
wtdir
,
".git"
,
NULL
));
cl_assert_equal_s
(
wt
->
gitdir
,
cl_git_sandbox_path
(
1
,
parentdir
,
".git"
,
"worktrees"
,
wtdir
,
NULL
));
}
void
test_worktree_open__initialize
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment