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
f7250cc3
Commit
f7250cc3
authored
Jun 04, 2020
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clar: add tap output
parent
691315e6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
3 deletions
+99
-3
tests/clar.c
+6
-1
tests/clar.h
+1
-0
tests/clar/print.h
+92
-2
No files found.
tests/clar.c
View file @
f7250cc3
...
@@ -363,6 +363,7 @@ clar_usage(const char *arg)
...
@@ -363,6 +363,7 @@ clar_usage(const char *arg)
printf
(
" -v Increase verbosity (show suite names)
\n
"
);
printf
(
" -v Increase verbosity (show suite names)
\n
"
);
printf
(
" -q Only report tests that had an error
\n
"
);
printf
(
" -q Only report tests that had an error
\n
"
);
printf
(
" -Q Quit as soon as a test fails
\n
"
);
printf
(
" -Q Quit as soon as a test fails
\n
"
);
printf
(
" -t Display results in tap format
\n
"
);
printf
(
" -l Print suite names
\n
"
);
printf
(
" -l Print suite names
\n
"
);
printf
(
" -r[filename] Write summary file (to the optional filename)
\n
"
);
printf
(
" -r[filename] Write summary file (to the optional filename)
\n
"
);
exit
(
-
1
);
exit
(
-
1
);
...
@@ -378,7 +379,7 @@ clar_parse_args(int argc, char **argv)
...
@@ -378,7 +379,7 @@ clar_parse_args(int argc, char **argv)
char
*
argument
=
argv
[
i
];
char
*
argument
=
argv
[
i
];
if
(
argument
[
0
]
!=
'-'
||
argument
[
1
]
==
'\0'
if
(
argument
[
0
]
!=
'-'
||
argument
[
1
]
==
'\0'
||
strchr
(
"sixvqQlr"
,
argument
[
1
])
==
NULL
)
{
||
strchr
(
"sixvqQ
t
lr"
,
argument
[
1
])
==
NULL
)
{
clar_usage
(
argv
[
0
]);
clar_usage
(
argv
[
0
]);
}
}
}
}
...
@@ -461,6 +462,10 @@ clar_parse_args(int argc, char **argv)
...
@@ -461,6 +462,10 @@ clar_parse_args(int argc, char **argv)
_clar
.
exit_on_error
=
1
;
_clar
.
exit_on_error
=
1
;
break
;
break
;
case
't'
:
_clar
.
output_format
=
CL_OUTPUT_TAP
;
break
;
case
'l'
:
{
case
'l'
:
{
size_t
j
;
size_t
j
;
printf
(
"Test suites (use -s<name> to run just one):
\n
"
);
printf
(
"Test suites (use -s<name> to run just one):
\n
"
);
...
...
tests/clar.h
View file @
f7250cc3
...
@@ -18,6 +18,7 @@ enum cl_test_status {
...
@@ -18,6 +18,7 @@ enum cl_test_status {
enum
cl_output_format
{
enum
cl_output_format
{
CL_OUTPUT_CLAP
,
CL_OUTPUT_CLAP
,
CL_OUTPUT_TAP
,
};
};
/** Setup clar environment */
/** Setup clar environment */
...
...
tests/clar/print.h
View file @
f7250cc3
...
@@ -64,12 +64,102 @@ static void clar_print_clap_onabort(const char *fmt, va_list arg)
...
@@ -64,12 +64,102 @@ static void clar_print_clap_onabort(const char *fmt, va_list arg)
vfprintf
(
stderr
,
fmt
,
arg
);
vfprintf
(
stderr
,
fmt
,
arg
);
}
}
/* tap: test anywhere protocol format */
static
void
clar_print_tap_init
(
int
test_count
,
int
suite_count
,
const
char
*
suite_names
)
{
(
void
)
test_count
;
(
void
)
suite_count
;
(
void
)
suite_names
;
printf
(
"TAP version 13
\n
"
);
}
static
void
clar_print_tap_shutdown
(
int
test_count
,
int
suite_count
,
int
error_count
)
{
(
void
)
suite_count
;
(
void
)
error_count
;
printf
(
"1..%d
\n
"
,
test_count
);
}
static
void
clar_print_tap_error
(
int
num
,
const
struct
clar_report
*
report
,
const
struct
clar_error
*
error
)
{
(
void
)
num
;
(
void
)
report
;
(
void
)
error
;
}
static
void
print_escaped
(
const
char
*
str
)
{
char
*
c
;
while
((
c
=
strchr
(
str
,
'\''
))
!=
NULL
)
{
printf
(
"%.*s"
,
(
int
)(
c
-
str
),
str
);
printf
(
"''"
);
str
=
c
+
1
;
}
printf
(
"%s"
,
str
);
}
static
void
clar_print_tap_ontest
(
const
char
*
test_name
,
int
test_number
,
enum
cl_test_status
status
)
{
const
struct
clar_error
*
error
=
_clar
.
last_report
->
errors
;
(
void
)
test_name
;
(
void
)
test_number
;
switch
(
status
)
{
case
CL_TEST_OK
:
printf
(
"ok %d - %s::%s
\n
"
,
test_number
,
_clar
.
active_suite
,
test_name
);
break
;
case
CL_TEST_FAILURE
:
printf
(
"not ok %d - %s::%s
\n
"
,
test_number
,
_clar
.
active_suite
,
test_name
);
printf
(
" ---
\n
"
);
printf
(
" reason: |
\n
"
);
printf
(
" %s
\n
"
,
error
->
error_msg
);
if
(
error
->
description
)
printf
(
" %s
\n
"
,
error
->
description
);
printf
(
" at:
\n
"
);
printf
(
" file: '"
);
print_escaped
(
error
->
file
);
printf
(
"'
\n
"
);
printf
(
" line: %"
PRIuZ
"
\n
"
,
error
->
line_number
);
printf
(
" function: '%s::%s'
\n
"
,
_clar
.
active_suite
,
test_name
);
printf
(
" ---
\n
"
);
break
;
case
CL_TEST_SKIP
:
case
CL_TEST_NOTRUN
:
printf
(
"ok %d - # SKIP %s::%s
\n
"
,
test_number
,
_clar
.
active_suite
,
test_name
);
break
;
}
fflush
(
stdout
);
}
static
void
clar_print_tap_onsuite
(
const
char
*
suite_name
,
int
suite_index
)
{
printf
(
"# start of suite %d: %s
\n
"
,
suite_index
,
suite_name
);
}
static
void
clar_print_tap_onabort
(
const
char
*
fmt
,
va_list
arg
)
{
printf
(
"Bail out! "
);
vprintf
(
fmt
,
arg
);
fflush
(
stdout
);
}
/* indirection between protocol output selection */
/* indirection between protocol output selection */
#define PRINT(FN,
args
...) do { \
#define PRINT(FN, ...) do { \
switch (_clar.output_format) { \
switch (_clar.output_format) { \
case CL_OUTPUT_CLAP: \
case CL_OUTPUT_CLAP: \
clar_print_clap_##FN (args); \
clar_print_clap_##FN (__VA_ARGS__); \
break; \
case CL_OUTPUT_TAP: \
clar_print_tap_##FN (__VA_ARGS__); \
break; \
break; \
default: \
default: \
abort(); \
abort(); \
...
...
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