Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
e9522e10
Unverified
Commit
e9522e10
authored
Jul 27, 2023
by
Shariar Azad Riday
Committed by
GitHub
Jul 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement max-runtime or the new test runner
parent
a74f7f05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
libcaf_test/caf/test/runner.cpp
libcaf_test/caf/test/runner.cpp
+49
-0
No files found.
libcaf_test/caf/test/runner.cpp
View file @
e9522e10
...
...
@@ -13,16 +13,64 @@
#include "caf/config_option_adder.hpp"
#include "caf/config_option_set.hpp"
#include "caf/detail/log_level.hpp"
#include "caf/detail/set_thread_name.hpp"
#include <condition_variable>
#include <iostream>
#include <mutex>
#include <optional>
#include <regex>
#include <string>
#include <thread>
namespace
caf
::
test
{
namespace
{
class
watchdog
{
public:
explicit
watchdog
(
int
secs
)
{
if
(
secs
>
0
)
run
(
secs
);
}
~
watchdog
()
{
if
(
!
thread_
.
joinable
())
return
;
{
std
::
lock_guard
<
std
::
mutex
>
guard
{
mtx_
};
canceled_
=
true
;
cv_
.
notify_all
();
}
thread_
.
join
();
}
private:
void
run
(
int
secs
)
{
using
detail
::
format_to
;
thread_
=
std
::
thread
{[
=
]
{
caf
::
detail
::
set_thread_name
(
"test.watchdog"
);
auto
tp
=
std
::
chrono
::
high_resolution_clock
::
now
()
+
std
::
chrono
::
seconds
(
secs
);
std
::
unique_lock
<
std
::
mutex
>
guard
{
mtx_
};
while
(
!
canceled_
&&
cv_
.
wait_until
(
guard
,
tp
)
!=
std
::
cv_status
::
timeout
)
{
}
if
(
!
canceled_
)
{
auto
err_out
=
[]
{
return
std
::
ostream_iterator
<
char
>
{
std
::
cerr
};
};
format_to
(
err_out
(),
"WATCHDOG: unit test did not finish within {} seconds
\n
"
,
secs
);
abort
();
}
}};
}
bool
canceled_
=
false
;
std
::
mutex
mtx_
;
std
::
condition_variable
cv_
;
std
::
thread
thread_
;
};
config_option_set
make_option_set
()
{
config_option_set
result
;
config_option_adder
{
result
,
"global"
}
...
...
@@ -100,6 +148,7 @@ int runner::run(int argc, char** argv) {
return
std
::
regex_search
(
search_string
.
begin
(),
search_string
.
end
(),
selected
);
};
watchdog
runtime_guard
{
get_or
(
cfg_
,
"max-runtime"
,
0
)};
for
(
auto
&
[
suite_name
,
suite
]
:
suites_
)
{
if
(
!
enabled
(
*
suite_regex
,
suite_name
))
continue
;
...
...
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