Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
CoMISo
Base
Commits
99ba8e2b
Commit
99ba8e2b
authored
3 years ago
by
Martin Marinov
Committed by
GitHub Enterprise
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
MTBR-915 Improve baseline records for unexpected ourcomes (#76)
parent
74af306b
Branches
Branches containing commit
No related tags found
1 merge request
!14
Merge latest changes to Base from ReForm
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Debug/DebTime.hh
+1
-2
1 addition, 2 deletions
Debug/DebTime.hh
Test/TestOutcome.cc
+21
-10
21 additions, 10 deletions
Test/TestOutcome.cc
with
22 additions
and
12 deletions
Debug/DebTime.hh
+
1
−
2
View file @
99ba8e2b
...
@@ -28,9 +28,8 @@ public:
...
@@ -28,9 +28,8 @@ public:
~
StopWatchSessionT
()
NOEXCEPT
(
false
)
~
StopWatchSessionT
()
NOEXCEPT
(
false
)
{
{
const
auto
dvsr
=
std
::
max
(
ONE
,
dvsr_
);
// TODO: implement "prettier" DEB out if seconds turn into minutes/hours/etc
// TODO: implement "prettier" DEB out if seconds turn into minutes/hours/etc
DEB_line_if
(
dvsr_
=
=
ONE
,
deb_lvl_
,
DEB_line_if
(
dvsr_
<
=
ONE
,
deb_lvl_
,
sssn_name_
<<
" took "
<<
sw_
.
stop
()
/
1000.0
<<
" s."
);
sssn_name_
<<
" took "
<<
sw_
.
stop
()
/
1000.0
<<
" s."
);
DEB_line_if
(
dvsr_
>
ONE
,
deb_lvl_
,
DEB_line_if
(
dvsr_
>
ONE
,
deb_lvl_
,
dvsr_
<<
" x "
<<
sssn_name_
<<
" took "
<<
sw_
.
stop
()
/
1000.0
/
dvsr_
dvsr_
<<
" x "
<<
sssn_name_
<<
" took "
<<
sw_
.
stop
()
/
1000.0
/
dvsr_
...
...
This diff is collapsed.
Click to expand it.
Test/TestOutcome.cc
+
21
−
10
View file @
99ba8e2b
...
@@ -20,17 +20,26 @@ namespace Test
...
@@ -20,17 +20,26 @@ namespace Test
namespace
namespace
{
{
void
record_and_handle_unexpected
(
void
record_and_handle_unexpected
(
const
char
*
const
_call
,
const
Outcome
&
_oc
,
const
char
*
const
_call
,
const
Outcome
&
_oc
,
const
bool
_un
exp
e
ct
e
d
)
const
bool
_unexpected
,
const
char
*
const
_
expctd
_what
)
{
{
TEST
(
outcome
,
record
(
_call
,
_oc
.
ok
(),
_oc
.
error_description
().
c_str
()));
if
(
_unexpected
)
if
(
_unexpected
)
{
Base
::
OStringStream
strm
;
strm
<<
"Unexpected outcome: Expected "
<<
_expctd_what
<<
" but got "
<<
_oc
.
error_description
().
c_str
()
<<
" instead!"
;
TEST
(
outcome
,
record
(
_call
,
_oc
.
ok
(),
strm
.
str
.
c_str
()));
_oc
.
unexpected_handler
();
_oc
.
unexpected_handler
();
}
}
else
TEST
(
outcome
,
record
(
_call
,
_oc
.
ok
(),
_oc
.
error_description
().
c_str
()));
}
}
// namespace
}
// namespace
Outcome
::
Outcome
()
:
ok_
(
true
),
error_code_
(
"0"
),
error_message_
(
"Success"
)
{}
const
char
SUCCESS
[]
=
"Success"
;
const
Outcome
FAILURE
(
false
,
"FAILURE"
,
"Failure"
);
Outcome
::
Outcome
()
:
ok_
(
true
),
error_code_
(
SUCCESS
),
error_message_
(
SUCCESS
)
{}
Outcome
::
Outcome
(
Outcome
::
Outcome
(
bool
_ok
,
const
std
::
string
&
_error_code
,
const
std
::
string
&
_error_message
)
bool
_ok
,
const
std
::
string
&
_error_code
,
const
std
::
string
&
_error_message
)
...
@@ -58,21 +67,22 @@ Outcome::UnexpectedHandler Outcome::unexpected_handler = []
...
@@ -58,21 +67,22 @@ Outcome::UnexpectedHandler Outcome::unexpected_handler = []
const
Outcome
&
record_outcome
(
const
char
*
const
_call
,
const
Outcome
&
_oc
)
const
Outcome
&
record_outcome
(
const
char
*
const
_call
,
const
Outcome
&
_oc
)
{
{
// Never call unexpected-outcome handler
// Never call unexpected-outcome handler
record_and_handle_unexpected
(
_call
,
_oc
,
false
);
record_and_handle_unexpected
(
_call
,
_oc
,
false
,
nullptr
);
return
_oc
;
return
_oc
;
}
}
void
expect_success
(
const
char
*
const
_call
,
const
Outcome
&
_oc
)
void
expect_success
(
const
char
*
const
_call
,
const
Outcome
&
_oc
)
{
{
// Call unexpected-outcome handler if the call *failed*
// Call unexpected-outcome handler if the call *failed*
record_and_handle_unexpected
(
_call
,
_oc
,
!
_oc
.
ok
());
record_and_handle_unexpected
(
_call
,
_oc
,
!
_oc
.
ok
()
,
SUCCESS
);
}
}
void
expect_outcome
(
void
expect_outcome
(
const
char
*
const
_call
,
const
Outcome
&
_oc
,
const
char
*
const
_error_code
)
const
char
*
const
_call
,
const
Outcome
&
_oc
,
const
char
*
const
_error_code
)
{
{
// Call unexpected-outcome handler if the error code is not correct
// Call unexpected-outcome handler if the error code is not correct
record_and_handle_unexpected
(
_call
,
_oc
,
_oc
.
error_code
()
!=
_error_code
);
record_and_handle_unexpected
(
_call
,
_oc
,
_oc
.
error_code
()
!=
_error_code
,
_error_code
);
}
}
void
expect_outcome
(
void
expect_outcome
(
...
@@ -84,10 +94,11 @@ void expect_outcome(
...
@@ -84,10 +94,11 @@ void expect_outcome(
void
expect_failure
(
const
char
*
const
_call
,
const
Outcome
&
_oc
)
void
expect_failure
(
const
char
*
const
_call
,
const
Outcome
&
_oc
)
{
{
// If _oc represents a failure, replace it with a generic failure outcome
// If _oc represents a failure, replace it with a generic failure outcome
auto
oc
=
_oc
.
ok
()
?
_oc
:
Outcome
(
_oc
.
ok
(),
"FAILURE"
,
"Failure"
)
;
auto
oc
=
_oc
.
ok
()
?
_oc
:
FAILURE
;
// Call unexpected-outcome handler if the call *succeeds*
// Call unexpected-outcome handler if the call *succeeds*
record_and_handle_unexpected
(
_call
,
oc
,
oc
.
ok
());
record_and_handle_unexpected
(
_call
,
oc
,
oc
.
ok
(),
FAILURE
.
error_code
().
c_str
());
}
}
void
ignore_outcome
(
const
char
*
const
_call
,
const
char
*
const
_reason
)
void
ignore_outcome
(
const
char
*
const
_call
,
const
char
*
const
_reason
)
...
...
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