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
ab7941b5
Commit
ab7941b5
authored
Jun 28, 2011
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: Properly show error messages
parent
5cf1f909
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
5 deletions
+20
-5
include/git2/errors.h
+5
-0
src/errors.c
+7
-0
src/fileops.c
+3
-4
tests/test_lib.c
+4
-1
tests/test_lib.h
+1
-0
No files found.
include/git2/errors.h
View file @
ab7941b5
...
...
@@ -146,6 +146,11 @@ GIT_EXTERN(const char *) git_lasterror(void);
*/
GIT_EXTERN
(
const
char
*
)
git_strerror
(
int
num
);
/**
* Clear the latest library error
*/
GIT_EXTERN
(
void
)
git_clearerror
(
void
);
/** @} */
GIT_END_DECL
#endif
src/errors.c
View file @
ab7941b5
...
...
@@ -108,6 +108,13 @@ int git__throw(int error, const char *msg, ...)
const
char
*
git_lasterror
(
void
)
{
if
(
!
g_last_error
[
0
])
return
NULL
;
return
g_last_error
;
}
void
git_clearerror
(
void
)
{
g_last_error
[
0
]
=
'\0'
;
}
src/fileops.c
View file @
ab7941b5
...
...
@@ -123,8 +123,7 @@ int gitfo_isdir(const char *path)
struct
stat
st
;
int
len
,
stat_error
;
if
(
!
path
)
return
git__throw
(
GIT_ENOTFOUND
,
"No path given to gitfo_isdir"
);
assert
(
path
);
len
=
strlen
(
path
);
...
...
@@ -140,10 +139,10 @@ int gitfo_isdir(const char *path)
}
if
(
stat_error
<
GIT_SUCCESS
)
return
git__throw
(
GIT_ENOTFOUND
,
"%s does not exist"
,
path
)
;
return
GIT_ERROR
;
if
(
!
S_ISDIR
(
st
.
st_mode
))
return
git__throw
(
GIT_ENOTFOUND
,
"%s is not a directory"
,
path
)
;
return
GIT_ERROR
;
return
GIT_SUCCESS
;
}
...
...
tests/test_lib.c
View file @
ab7941b5
...
...
@@ -77,13 +77,16 @@ void git_test__init(git_test *t, const char *name, const char *description)
static
void
fail_test
(
git_test
*
tc
,
const
char
*
file
,
int
line
,
const
char
*
message
)
{
char
buf
[
1024
];
const
char
*
last_error
=
git_lasterror
();
snprintf
(
buf
,
1024
,
"%s:%d"
,
file
,
line
);
tc
->
failed
=
1
;
tc
->
message
=
strdup
(
message
);
tc
->
failed_pos
=
strdup
(
buf
);
tc
->
error_message
=
strdup
(
git_lasterror
());
if
(
last_error
)
tc
->
error_message
=
strdup
(
last_error
);
if
(
tc
->
jump
!=
0
)
longjmp
(
*
(
tc
->
jump
),
0
);
...
...
tests/test_lib.h
View file @
ab7941b5
...
...
@@ -26,6 +26,7 @@
#define BEGIN_TEST(TNAME, DESC) \
static void _gittest__##TNAME(git_test *_gittest) { \
git_test__init(_gittest, #TNAME, DESC); \
git_clearerror();\
{\
#define END_TEST }}
...
...
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