Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
2a005f75
Commit
2a005f75
authored
7 months ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
test: friendlier reports from internal unit tests
parent
ab4b7d1c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1254
fix: fault-tolerant governor raft operations via compare-and-swap
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cli/test.rs
+41
-16
41 additions, 16 deletions
src/cli/test.rs
with
41 additions
and
16 deletions
src/cli/test.rs
+
41
−
16
View file @
2a005f75
...
...
@@ -2,6 +2,7 @@ use crate::cli::args;
use
crate
::
ipc
;
use
::
tarantool
::
test
::
TestCase
;
use
nix
::
unistd
::{
self
,
fork
,
ForkResult
};
use
std
::
io
::
Write
;
macro_rules!
color
{
(
@
priv
red
)
=>
{
"
\x1b
[0;31m"
};
...
...
@@ -26,7 +27,7 @@ pub fn main(args: args::Test) -> ! {
const
PASSED
:
&
str
=
color!
[
green
"ok"
clear
];
const
FAILED
:
&
str
=
color!
[
red
"FAILED"
clear
];
let
mut
cnt_passed
=
0u32
;
let
mut
cnt_
failed
=
0u32
;
let
mut
failed
=
vec!
[]
;
let
mut
cnt_skipped
=
0u32
;
let
now
=
std
::
time
::
Instant
::
now
();
...
...
@@ -88,29 +89,43 @@ pub fn main(args: args::Test) -> ! {
cnt_passed
+=
1
;
}
else
{
println!
(
"{FAILED}"
);
cnt_failed
+=
1
;
let
log
=
if
args
.nocapture
{
None
}
else
{
Some
(
log
)
};
failed
.push
((
t
.name
(),
log
));
}
}
};
}
if
args
.nocapture
{
continue
;
}
let
ok
=
failed
.is_empty
();
use
std
::
io
::
Write
;
println!
();
std
::
io
::
stderr
()
.write_all
(
&
log
)
.map_err
(|
e
|
println!
(
"error writing stderr: {e}"
))
.ok
();
println!
();
let
(
_
,
mut
screen_width
)
=
terminal_size
();
if
screen_width
==
0
{
screen_width
=
80
;
}
if
!
ok
{
println!
();
println!
(
"failed tests:"
);
for
(
test
,
log
)
in
&
failed
{
if
let
Some
(
log
)
=
log
{
println!
(
"{}"
,
"="
.repeat
(
screen_width
));
println!
(
"test {test} output:"
);
println!
(
"{}"
,
"-"
.repeat
(
screen_width
));
let
res
=
std
::
io
::
stdout
()
.write_all
(
log
);
if
let
Err
(
e
)
=
res
{
eprintln!
(
"failed writing stdout: {e}"
)
}
println!
();
}
else
{
println!
(
"
\x1b
[31m {test}
\x1b
[0m"
);
}
};
}
println!
();
}
let
ok
=
cnt_failed
==
0
;
println!
();
print!
(
"test result: {}."
,
if
ok
{
PASSED
}
else
{
FAILED
});
print!
(
" {cnt_passed} passed;"
);
print!
(
" {
cnt_
failed
}
failed
;"
);
print!
(
" {
}
failed
;"
,
failed
.len
()
);
print!
(
" {cnt_skipped} skipped;"
);
println!
(
" finished in {:.2}s"
,
now
.elapsed
()
.as_secs_f32
());
println!
();
...
...
@@ -118,6 +133,16 @@ pub fn main(args: args::Test) -> ! {
std
::
process
::
exit
(
!
ok
as
_
);
}
/// Returns a pair (rows, columns).
fn
terminal_size
()
->
(
usize
,
usize
)
{
// Safety: always safe
unsafe
{
let
mut
screen_size
:
libc
::
winsize
=
std
::
mem
::
zeroed
();
libc
::
ioctl
(
libc
::
STDIN_FILENO
,
libc
::
TIOCGWINSZ
,
&
mut
screen_size
);
(
screen_size
.ws_row
as
_
,
screen_size
.ws_col
as
_
)
}
}
fn
test_one
(
test
:
&
TestCase
)
{
use
crate
::
tarantool
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment