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
600d8dbf
Commit
600d8dbf
authored
Jan 03, 2013
by
Ben Straub
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move test cleanup into cleanup functions
parent
bffbeebb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
75 additions
and
42 deletions
+75
-42
tests-clar/config/read.c
+5
-1
tests-clar/core/env.c
+19
-13
tests-clar/index/tests.c
+5
-1
tests-clar/network/fetchlocal.c
+5
-1
tests-clar/pack/packbuilder.c
+29
-20
tests-clar/stash/save.c
+1
-1
tests-clar/status/worktree.c
+11
-5
No files found.
tests-clar/config/read.c
View file @
600d8dbf
#include "clar_libgit2.h"
void
test_config_read__cleanup
(
void
)
{
cl_fixture_cleanup
(
"./empty"
);
}
void
test_config_read__simple_read
(
void
)
{
git_config
*
cfg
;
...
...
@@ -441,7 +446,6 @@ void test_config_read__can_load_and_parse_an_empty_config_file(void)
cl_assert_equal_i
(
GIT_ENOTFOUND
,
git_config_get_int32
(
&
i
,
cfg
,
"nope.neither"
));
git_config_free
(
cfg
);
cl_fixture_cleanup
(
"./empty"
);
}
void
test_config_read__cannot_load_a_non_existing_config_file
(
void
)
...
...
tests-clar/core/env.c
View file @
600d8dbf
...
...
@@ -14,6 +14,18 @@ static const char *env_vars[NUM_VARS] = { "HOME" };
static
char
*
env_save
[
NUM_VARS
];
static
char
*
home_values
[]
=
{
"fake_home"
,
"fáke_hõme"
,
/* all in latin-1 supplement */
"fĀke_Ĥome"
,
/* latin extended */
"fακε_hοmέ"
,
/* having fun with greek */
"faงe_นome"
,
/* now I have no idea, but thai characters */
"f
\xe1\x9c
x80ke_
\xe1\x9c\x91
ome"
,
/* tagalog characters */
"
\xe1\xb8\x9f
Ảke_hoṁe"
,
/* latin extended additional */
"
\xf0\x9f\x98\x98\xf0\x9f\x98\x82
"
,
/* emoticons */
NULL
};
void
test_core_env__initialize
(
void
)
{
int
i
;
...
...
@@ -24,6 +36,8 @@ void test_core_env__initialize(void)
void
test_core_env__cleanup
(
void
)
{
int
i
;
char
**
val
;
for
(
i
=
0
;
i
<
NUM_VARS
;
++
i
)
{
cl_setenv
(
env_vars
[
i
],
env_save
[
i
]);
#ifdef GIT_WIN32
...
...
@@ -31,11 +45,16 @@ void test_core_env__cleanup(void)
#endif
env_save
[
i
]
=
NULL
;
}
for
(
val
=
home_values
;
*
val
!=
NULL
;
val
++
)
{
cl_fixture_cleanup
(
*
val
);
}
}
static
void
setenv_and_check
(
const
char
*
name
,
const
char
*
value
)
{
char
*
check
;
cl_git_pass
(
cl_setenv
(
name
,
value
));
check
=
cl_getenv
(
name
);
cl_assert_equal_s
(
value
,
check
);
...
...
@@ -46,17 +65,6 @@ static void setenv_and_check(const char *name, const char *value)
void
test_core_env__0
(
void
)
{
static
char
*
home_values
[]
=
{
"fake_home"
,
"fáke_hõme"
,
/* all in latin-1 supplement */
"fĀke_Ĥome"
,
/* latin extended */
"fακε_hοmέ"
,
/* having fun with greek */
"faงe_นome"
,
/* now I have no idea, but thai characters */
"f
\xe1\x9c
x80ke_
\xe1\x9c\x91
ome"
,
/* tagalog characters */
"
\xe1\xb8\x9f
Ảke_hoṁe"
,
/* latin extended additional */
"
\xf0\x9f\x98\x98\xf0\x9f\x98\x82
"
,
/* emoticons */
NULL
};
git_buf
path
=
GIT_BUF_INIT
,
found
=
GIT_BUF_INIT
;
char
testfile
[
16
],
tidx
=
'0'
;
char
**
val
;
...
...
@@ -122,8 +130,6 @@ void test_core_env__0(void)
}
}
#endif
cl_fixture_cleanup
(
*
val
);
}
git_buf_free
(
&
path
);
...
...
tests-clar/index/tests.c
View file @
600d8dbf
...
...
@@ -24,6 +24,7 @@ static struct test_entry test_entries[] = {
{
48
,
"src/revobject.h"
,
1448
,
0x4C3F7FE2
}
};
static
char
*
path_to_cleanup
=
NULL
;
// Helpers
static
void
copy_file
(
const
char
*
src
,
const
char
*
dst
)
...
...
@@ -74,6 +75,9 @@ void test_index_tests__initialize(void)
void
test_index_tests__cleanup
(
void
)
{
if
(
path_to_cleanup
)
cl_fixture_cleanup
(
path_to_cleanup
);
path_to_cleanup
=
NULL
;
}
...
...
@@ -246,7 +250,7 @@ void test_index_tests__add(void)
git_index_free
(
index
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"myrepo"
)
;
path_to_cleanup
=
"myrepo"
;
}
void
test_index_tests__add_from_workdir_to_a_bare_repository_returns_EBAREPO
(
void
)
...
...
tests-clar/network/fetchlocal.c
View file @
600d8dbf
...
...
@@ -11,6 +11,11 @@ static void transfer_cb(const git_transfer_progress *stats, void *payload)
(
*
callcount
)
++
;
}
void
test_network_fetchlocal__cleanup
(
void
)
{
cl_fixture_cleanup
(
"foo"
);
}
void
test_network_fetchlocal__complete
(
void
)
{
git_repository
*
repo
;
...
...
@@ -33,7 +38,6 @@ void test_network_fetchlocal__complete(void)
git_strarray_free
(
&
refnames
);
git_remote_free
(
origin
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"foo"
);
}
void
test_network_fetchlocal__partial
(
void
)
...
...
tests-clar/pack/packbuilder.c
View file @
600d8dbf
...
...
@@ -9,6 +9,26 @@ static git_packbuilder *_packbuilder;
static
git_indexer
*
_indexer
;
static
git_vector
_commits
;
static
int
_commits_is_initialized
;
static
char
*
path_to_cleanup
=
NULL
;
static
git_oid
oid_to_cleanup
=
{{
0
}};
static
void
cleanup_pack
(
const
git_oid
*
oid
)
{
char
*
hash
,
path
[
1024
]
=
{
0
};
if
(
git_oid_iszero
(
&
oid_to_cleanup
))
return
;
hash
=
git_oid_allocfmt
(
oid
);
sprintf
(
path
,
"pack-%s.idx"
,
hash
);
p_unlink
(
path
);
sprintf
(
path
,
"pack-%s.pack"
,
hash
);
p_unlink
(
path
);
git__free
(
hash
);
git_oid_fromstrn
(
&
oid_to_cleanup
,
""
,
0
);
}
void
test_pack_packbuilder__initialize
(
void
)
{
...
...
@@ -43,6 +63,12 @@ void test_pack_packbuilder__cleanup(void)
git_repository_free
(
_repo
);
_repo
=
NULL
;
if
(
path_to_cleanup
)
cl_fixture_cleanup
(
path_to_cleanup
);
path_to_cleanup
=
NULL
;
cleanup_pack
(
&
oid_to_cleanup
);
}
static
void
seed_packbuilder
(
void
)
...
...
@@ -73,24 +99,10 @@ static void seed_packbuilder(void)
}
}
static
void
cleanup_pack
(
const
git_oid
*
oid
)
{
char
*
hash
,
path
[
1024
]
=
{
0
};
hash
=
git_oid_allocfmt
(
oid
);
sprintf
(
path
,
"pack-%s.idx"
,
hash
);
p_unlink
(
path
);
sprintf
(
path
,
"pack-%s.pack"
,
hash
);
p_unlink
(
path
);
git__free
(
hash
);
}
void
test_pack_packbuilder__create_pack
(
void
)
{
git_transfer_progress
stats
;
path_to_cleanup
=
"testpack.pack"
;
seed_packbuilder
();
cl_git_pass
(
git_packbuilder_write
(
_packbuilder
,
"testpack.pack"
));
...
...
@@ -98,9 +110,8 @@ void test_pack_packbuilder__create_pack(void)
cl_git_pass
(
git_indexer_new
(
&
_indexer
,
"testpack.pack"
));
cl_git_pass
(
git_indexer_run
(
_indexer
,
&
stats
));
cl_git_pass
(
git_indexer_write
(
_indexer
));
git_oid_cpy
(
&
oid_to_cleanup
,
git_indexer_hash
(
_indexer
));
cl_fixture_cleanup
(
"testpack.pack"
);
cleanup_pack
(
git_indexer_hash
(
_indexer
));
}
static
git_transfer_progress
stats
;
...
...
@@ -116,13 +127,11 @@ static int foreach_cb(void *buf, size_t len, void *payload)
void
test_pack_packbuilder__foreach
(
void
)
{
git_indexer_stream
*
idx
;
git_oid
oid
;
seed_packbuilder
();
cl_git_pass
(
git_indexer_stream_new
(
&
idx
,
"."
,
NULL
,
NULL
));
cl_git_pass
(
git_packbuilder_foreach
(
_packbuilder
,
foreach_cb
,
idx
));
cl_git_pass
(
git_indexer_stream_finalize
(
idx
,
&
stats
));
git_oid_cpy
(
&
oid
,
git_indexer_stream_hash
(
idx
));
git_oid_cpy
(
&
oid
_to_cleanup
,
git_indexer_stream_hash
(
idx
));
git_indexer_stream_free
(
idx
);
cleanup_pack
(
&
oid
);
}
tests-clar/stash/save.c
View file @
600d8dbf
...
...
@@ -32,6 +32,7 @@ void test_stash_save__cleanup(void)
repo
=
NULL
;
cl_git_pass
(
git_futils_rmdir_r
(
"stash"
,
NULL
,
GIT_RMDIR_REMOVE_FILES
));
cl_fixture_cleanup
(
"sorry-it-is-a-non-bare-only-party"
);
}
static
void
assert_object_oid
(
const
char
*
revision
,
const
char
*
expected_oid
,
git_otype
type
)
...
...
@@ -211,7 +212,6 @@ void test_stash_save__cannot_stash_against_a_bare_repository(void)
git_stash_save
(
&
stash_tip_oid
,
local
,
signature
,
NULL
,
GIT_STASH_DEFAULT
));
git_repository_free
(
local
);
cl_fixture_cleanup
(
"sorry-it-is-a-non-bare-only-party"
);
}
void
test_stash_save__can_stash_against_a_detached_head
(
void
)
...
...
tests-clar/status/worktree.c
View file @
600d8dbf
...
...
@@ -6,6 +6,8 @@
#include "util.h"
#include "path.h"
static
char
*
path_to_cleanup
=
NULL
;
/**
* Initializer
*
...
...
@@ -25,6 +27,10 @@ void test_status_worktree__initialize(void)
void
test_status_worktree__cleanup
(
void
)
{
cl_git_sandbox_cleanup
();
if
(
path_to_cleanup
)
cl_fixture_cleanup
(
path_to_cleanup
);
path_to_cleanup
=
NULL
;
}
/**
...
...
@@ -446,7 +452,7 @@ void test_status_worktree__first_commit_in_progress(void)
git_index_free
(
index
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"getting_started"
)
;
path_to_cleanup
=
"getting_started"
;
}
...
...
@@ -596,7 +602,7 @@ void test_status_worktree__bracket_in_filename(void)
git_index_free
(
index
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"with_bracket"
)
;
path_to_cleanup
=
"with_bracket"
;
}
void
test_status_worktree__space_in_filename
(
void
)
...
...
@@ -661,7 +667,7 @@ void test_status_worktree__space_in_filename(void)
git_index_free
(
index
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"with_space"
)
;
path_to_cleanup
=
"with_space"
;
}
static
const
char
*
filemode_paths
[]
=
{
...
...
@@ -772,7 +778,7 @@ void test_status_worktree__disable_pathspec_match(void)
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"pathspec"
)
;
path_to_cleanup
=
"pathspec"
;
}
...
...
@@ -825,7 +831,7 @@ void test_status_worktree__new_staged_file_must_handle_crlf(void)
git_config_free
(
config
);
git_index_free
(
index
);
git_repository_free
(
repo
);
cl_fixture_cleanup
(
"getting_started"
)
;
path_to_cleanup
=
"getting_started"
;
}
void
test_status_worktree__line_endings_dont_count_as_changes_with_autocrlf
(
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