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
0f65733b
Commit
0f65733b
authored
Apr 02, 2014
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clar: skip tests
parent
ada157b2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
45 deletions
+61
-45
tests/blame/simple.c
+8
-8
tests/clar.c
+30
-23
tests/clar.h
+9
-0
tests/clar/print.h
+8
-2
tests/online/clone.c
+2
-9
tests/online/push.c
+4
-3
No files found.
tests/blame/simple.c
View file @
0f65733b
...
...
@@ -137,14 +137,14 @@ void test_blame_simple__trivial_libgit2(void)
/* If we can't open the libgit2 repo or if it isn't a full repo
* with proper history, just skip this test */
if
(
git_repository_open
(
&
g_repo
,
cl_fixture
(
"../.."
))
<
0
||
git_repository_is_shallow
(
g_repo
)
||
git_revparse_single
(
&
obj
,
g_repo
,
"359fc2d"
)
<
0
)
{
printf
(
"NOT INSIDE VALID LIBGIT2 REPO; skipping blame test
\n
"
);
giterr_clear
();
return
;
}
if
(
git_repository_open
(
&
g_repo
,
cl_fixture
(
"../.."
))
<
0
)
cl_skip
();
if
(
git_repository_is_shallow
(
g_repo
))
cl_skip
(
);
if
(
git_revparse_single
(
&
obj
,
g_repo
,
"359fc2d"
)
<
0
)
cl_skip
();
git_oid_cpy
(
&
opts
.
newest_commit
,
git_object_id
(
obj
));
git_object_free
(
obj
);
...
...
tests/clar.c
View file @
0f65733b
...
...
@@ -109,10 +109,11 @@ static struct {
int
argc
;
char
**
argv
;
enum
cl_test_status
test_status
;
const
char
*
active_test
;
const
char
*
active_suite
;
int
suite_errors
;
int
total_skipped
;
int
total_errors
;
int
tests_ran
;
...
...
@@ -150,7 +151,7 @@ struct clar_suite {
static
void
clar_print_init
(
int
test_count
,
int
suite_count
,
const
char
*
suite_names
);
static
void
clar_print_shutdown
(
int
test_count
,
int
suite_count
,
int
error_count
);
static
void
clar_print_error
(
int
num
,
const
struct
clar_error
*
error
);
static
void
clar_print_ontest
(
const
char
*
test_name
,
int
test_number
,
int
failed
);
static
void
clar_print_ontest
(
const
char
*
test_name
,
int
test_number
,
enum
cl_test_status
failed
);
static
void
clar_print_onsuite
(
const
char
*
suite_name
,
int
suite_index
);
static
void
clar_print_onabort
(
const
char
*
msg
,
...);
...
...
@@ -186,8 +187,7 @@ clar_run_test(
const
struct
clar_func
*
initialize
,
const
struct
clar_func
*
cleanup
)
{
int
error_st
=
_clar
.
suite_errors
;
_clar
.
test_status
=
CL_TEST_OK
;
_clar
.
trampoline_enabled
=
1
;
if
(
setjmp
(
_clar
.
trampoline
)
==
0
)
{
...
...
@@ -211,14 +211,11 @@ clar_run_test(
_clar
.
local_cleanup
=
NULL
;
_clar
.
local_cleanup_payload
=
NULL
;
if
(
_clar
.
report_errors_only
)
if
(
_clar
.
report_errors_only
)
{
clar_report_errors
();
else
clar_print_ontest
(
test
->
name
,
_clar
.
tests_ran
,
(
_clar
.
suite_errors
>
error_st
)
);
}
else
{
clar_print_ontest
(
test
->
name
,
_clar
.
tests_ran
,
_clar
.
test_status
);
}
}
static
void
...
...
@@ -237,7 +234,6 @@ clar_run_suite(const struct clar_suite *suite, const char *filter)
clar_print_onsuite
(
suite
->
name
,
++
_clar
.
suites_ran
);
_clar
.
active_suite
=
suite
->
name
;
_clar
.
suite_errors
=
0
;
if
(
filter
)
{
size_t
suitelen
=
strlen
(
suite
->
name
);
...
...
@@ -413,6 +409,25 @@ clar_test(int argc, char **argv)
return
errors
;
}
static
void
abort_test
(
void
)
{
if
(
!
_clar
.
trampoline_enabled
)
{
clar_print_onabort
(
"Fatal error: a cleanup method raised an exception."
);
clar_report_errors
();
exit
(
-
1
);
}
longjmp
(
_clar
.
trampoline
,
-
1
);
}
void
clar__skip
(
void
)
{
_clar
.
test_status
=
CL_TEST_SKIP
;
_clar
.
total_skipped
++
;
abort_test
();
}
void
clar__fail
(
const
char
*
file
,
int
line
,
...
...
@@ -440,19 +455,11 @@ void clar__fail(
if
(
description
!=
NULL
)
error
->
description
=
strdup
(
description
);
_clar
.
suite_errors
++
;
_clar
.
total_errors
++
;
_clar
.
test_status
=
CL_TEST_FAILURE
;
if
(
should_abort
)
{
if
(
!
_clar
.
trampoline_enabled
)
{
clar_print_onabort
(
"Fatal error: a cleanup method raised an exception."
);
clar_report_errors
();
exit
(
-
1
);
}
longjmp
(
_clar
.
trampoline
,
-
1
);
}
if
(
should_abort
)
abort_test
();
}
void
clar__assert
(
...
...
tests/clar.h
View file @
0f65733b
...
...
@@ -9,6 +9,12 @@
#include <stdlib.h>
enum
cl_test_status
{
CL_TEST_OK
,
CL_TEST_FAILURE
,
CL_TEST_SKIP
};
void
clar_test_init
(
int
argc
,
char
*
argv
[]);
int
clar_test_run
(
void
);
void
clar_test_shutdown
(
void
);
...
...
@@ -60,6 +66,8 @@ void cl_fixture_cleanup(const char *fixture_name);
#define cl_fail(desc) clar__fail(__FILE__, __LINE__, "Test failed.", desc, 1)
#define cl_warning(desc) clar__fail(__FILE__, __LINE__, "Warning during test execution:", desc, 0)
#define cl_skip() clar__skip()
/**
* Typed assertion macros
*/
...
...
@@ -77,6 +85,7 @@ void cl_fixture_cleanup(const char *fixture_name);
#define cl_assert_equal_p(p1,p2) clar__assert_equal(__FILE__,__LINE__,"Pointer mismatch: " #p1 " != " #p2, 1, "%p", (p1), (p2))
void
clar__skip
(
void
);
void
clar__fail
(
const
char
*
file
,
...
...
tests/clar/print.h
View file @
0f65733b
...
...
@@ -35,11 +35,17 @@ static void clar_print_error(int num, const struct clar_error *error)
fflush
(
stdout
);
}
static
void
clar_print_ontest
(
const
char
*
test_name
,
int
test_number
,
int
failed
)
static
void
clar_print_ontest
(
const
char
*
test_name
,
int
test_number
,
enum
cl_test_status
status
)
{
(
void
)
test_name
;
(
void
)
test_number
;
printf
(
"%c"
,
failed
?
'F'
:
'.'
);
switch
(
status
)
{
case
CL_TEST_OK
:
printf
(
"."
);
break
;
case
CL_TEST_FAILURE
:
printf
(
"F"
);
break
;
case
CL_TEST_SKIP
:
printf
(
"S"
);
break
;
}
fflush
(
stdout
);
}
...
...
tests/online/clone.c
View file @
0f65733b
...
...
@@ -200,15 +200,8 @@ void test_online_clone__cred_callback_failure_return_code_is_tunnelled(void)
const
char
*
remote_url
=
cl_getenv
(
"GITTEST_REMOTE_URL"
);
const
char
*
remote_user
=
cl_getenv
(
"GITTEST_REMOTE_USER"
);
if
(
!
remote_url
)
{
printf
(
"GITTEST_REMOTE_URL unset; skipping clone test
\n
"
);
return
;
}
if
(
!
remote_user
)
{
printf
(
"GITTEST_REMOTE_USER unset; skipping clone test
\n
"
);
return
;
}
if
(
!
remote_url
||
!
remote_user
)
clar__skip
();
g_options
.
remote_callbacks
.
credentials
=
cred_failure_cb
;
...
...
tests/online/push.c
View file @
0f65733b
...
...
@@ -315,7 +315,10 @@ void test_online_push__initialize(void)
_remote_default
=
cl_getenv
(
"GITTEST_REMOTE_DEFAULT"
);
_remote
=
NULL
;
if
(
_remote_url
)
{
/* Skip the test if we're missing the remote URL */
if
(
!
_remote_url
)
cl_skip
();
cl_git_pass
(
git_remote_create
(
&
_remote
,
_repo
,
"test"
,
_remote_url
));
record_callbacks_data_clear
(
&
_record_cbs_data
);
...
...
@@ -353,8 +356,6 @@ void test_online_push__initialize(void)
cl_git_pass
(
git_remote_download
(
_remote
));
cl_git_pass
(
git_remote_update_tips
(
_remote
,
NULL
,
NULL
));
git_remote_disconnect
(
_remote
);
}
else
printf
(
"GITTEST_REMOTE_URL unset; skipping push test
\n
"
);
}
void
test_online_push__cleanup
(
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