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
b63ad958
Unverified
Commit
b63ad958
authored
Nov 28, 2019
by
Patrick Steinhardt
Committed by
GitHub
Nov 28, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5309 from libgit2/ethomson/trace
Improve trace support in tests
parents
0e5243b7
b7f70bc2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+34
-10
CMakeLists.txt
+1
-1
tests/clar_libgit2_trace.c
+33
-9
No files found.
CMakeLists.txt
View file @
b63ad958
...
...
@@ -50,7 +50,7 @@ OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
OPTION
(
BUILD_FUZZERS
"Build the fuzz targets"
OFF
)
OPTION
(
TAGS
"Generate tags"
OFF
)
OPTION
(
PROFILE
"Generate profiling information"
OFF
)
OPTION
(
ENABLE_TRACE
"Enables tracing support"
O
FF
)
OPTION
(
ENABLE_TRACE
"Enables tracing support"
O
N
)
OPTION
(
LIBGIT2_FILENAME
"Name of the produced binary"
OFF
)
OPTION
(
USE_SSH
"Link with libssh2 to enable SSH support"
ON
)
OPTION
(
USE_HTTPS
"Enable HTTPS support. Can be set to a specific backend"
ON
)
...
...
tests/clar_libgit2_trace.c
View file @
b63ad958
...
...
@@ -10,26 +10,42 @@ struct method {
void
(
*
close
)(
void
);
};
static
const
char
*
message_prefix
(
git_trace_level_t
level
)
{
switch
(
level
)
{
case
GIT_TRACE_NONE
:
return
"[NONE]: "
;
case
GIT_TRACE_FATAL
:
return
"[FATAL]: "
;
case
GIT_TRACE_ERROR
:
return
"[ERROR]: "
;
case
GIT_TRACE_WARN
:
return
"[WARN]: "
;
case
GIT_TRACE_INFO
:
return
"[INFO]: "
;
case
GIT_TRACE_DEBUG
:
return
"[DEBUG]: "
;
case
GIT_TRACE_TRACE
:
return
"[TRACE]: "
;
default:
return
"[?????]: "
;
}
}
#if defined(GIT_TRACE)
static
void
_git_trace_cb__printf
(
git_trace_level_t
level
,
const
char
*
msg
)
{
/* TODO Use level to print a per-message prefix. */
GIT_UNUSED
(
level
);
printf
(
"%s
\n
"
,
msg
);
printf
(
"%s%s
\n
"
,
message_prefix
(
level
),
msg
);
}
#if defined(GIT_WIN32)
static
void
_git_trace_cb__debug
(
git_trace_level_t
level
,
const
char
*
msg
)
{
/* TODO Use level to print a per-message prefix. */
GIT_UNUSED
(
level
);
OutputDebugString
(
message_prefix
(
level
));
OutputDebugString
(
msg
);
OutputDebugString
(
"
\n
"
);
printf
(
"%s
\n
"
,
msg
);
printf
(
"%s
%s
\n
"
,
message_prefix
(
level
)
,
msg
);
}
#else
#define _git_trace_cb__debug _git_trace_cb__printf
...
...
@@ -55,7 +71,7 @@ static struct method s_methods[] = {
static
int
s_trace_loaded
=
0
;
static
int
s_trace_level
=
GIT_TRACE_NONE
;
static
struct
method
*
s_trace_method
=
NULL
;
static
int
s_trace_tests
=
0
;
static
int
set_method
(
const
char
*
name
)
{
...
...
@@ -101,6 +117,7 @@ static void _load_trace_params(void)
{
char
*
sz_level
;
char
*
sz_method
;
char
*
sz_tests
;
s_trace_loaded
=
1
;
...
...
@@ -117,6 +134,10 @@ static void _load_trace_params(void)
sz_method
=
cl_getenv
(
"CLAR_TRACE_METHOD"
);
if
(
set_method
(
sz_method
)
<
0
)
set_method
(
NULL
);
sz_tests
=
cl_getenv
(
"CLAR_TRACE_TESTS"
);
if
(
sz_tests
!=
NULL
)
s_trace_tests
=
1
;
}
#define HR "================================================================"
...
...
@@ -139,6 +160,9 @@ void _cl_trace_cb__event_handler(
{
GIT_UNUSED
(
payload
);
if
(
!
s_trace_tests
)
return
;
switch
(
ev
)
{
case
CL_TRACE__SUITE_BEGIN
:
git_trace
(
GIT_TRACE_TRACE
,
"
\n\n
%s
\n
%s: Begin Suite"
,
HR
,
suite_name
);
...
...
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