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
c2779061
Commit
c2779061
authored
Jul 09, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow disabling of individual unit tests
parent
40baa6b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
10 deletions
+29
-10
libcaf_test/caf/test/unit_test.hpp
libcaf_test/caf/test/unit_test.hpp
+17
-7
libcaf_test/caf/test/unit_test_impl.hpp
libcaf_test/caf/test/unit_test_impl.hpp
+12
-3
No files found.
libcaf_test/caf/test/unit_test.hpp
View file @
c2779061
...
@@ -228,7 +228,7 @@ int main(int argc, char** argv);
...
@@ -228,7 +228,7 @@ int main(int argc, char** argv);
/// A sequence of *checks*.
/// A sequence of *checks*.
class
test
{
class
test
{
public:
public:
test
(
std
::
string
test_name
);
test
(
std
::
string
test_name
,
bool
disabled_by_default
);
virtual
~
test
();
virtual
~
test
();
...
@@ -248,6 +248,10 @@ public:
...
@@ -248,6 +248,10 @@ public:
return
bad_
;
return
bad_
;
}
}
inline
bool
disabled
()
const
noexcept
{
return
disabled_
;
}
virtual
void
run
()
=
0
;
virtual
void
run
()
=
0
;
private:
private:
...
@@ -255,6 +259,7 @@ private:
...
@@ -255,6 +259,7 @@ private:
std
::
string
name_
;
std
::
string
name_
;
size_t
good_
;
size_t
good_
;
size_t
bad_
;
size_t
bad_
;
bool
disabled_
;
};
};
struct
dummy_fixture
{
};
struct
dummy_fixture
{
};
...
@@ -262,7 +267,8 @@ struct dummy_fixture { };
...
@@ -262,7 +267,8 @@ struct dummy_fixture { };
template
<
class
T
>
template
<
class
T
>
class
test_impl
:
public
test
{
class
test_impl
:
public
test
{
public:
public:
test_impl
(
std
::
string
test_name
)
:
test
(
std
::
move
(
test_name
))
{
test_impl
(
std
::
string
test_name
,
bool
disabled_by_default
)
:
test
(
std
::
move
(
test_name
),
disabled_by_default
)
{
// nop
// nop
}
}
...
@@ -456,8 +462,8 @@ namespace detail {
...
@@ -456,8 +462,8 @@ namespace detail {
template
<
class
T
>
template
<
class
T
>
struct
adder
{
struct
adder
{
adder
(
const
char
*
suite_name
,
const
char
*
test_name
)
{
adder
(
const
char
*
suite_name
,
const
char
*
test_name
,
bool
disabled
)
{
engine
::
add
(
suite_name
,
std
::
unique_ptr
<
T
>
{
new
T
(
test_name
)});
engine
::
add
(
suite_name
,
std
::
unique_ptr
<
T
>
{
new
T
(
test_name
,
disabled
)});
}
}
};
};
...
@@ -594,16 +600,20 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
...
@@ -594,16 +600,20 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
::caf::test::engine::last_check_line(__LINE__); \
::caf::test::engine::last_check_line(__LINE__); \
} while (false)
} while (false)
#define CAF_TEST
(name)
\
#define CAF_TEST
_IMPL(name, disabled_by_default)
\
namespace { \
namespace { \
struct CAF_UNIQUE(test) : caf_test_case_auto_fixture { \
struct CAF_UNIQUE(test) : caf_test_case_auto_fixture { \
void run(); \
void run(); \
}; \
}; \
::caf::test::detail::adder<
::caf::test::test_impl<CAF_UNIQUE(test)>>
\
::caf::test::detail::adder<
::caf::test::test_impl<CAF_UNIQUE(test)>>
\
CAF_UNIQUE(a) {CAF_XSTR(CAF_SUITE), CAF_XSTR(name)};
\
CAF_UNIQUE(a){CAF_XSTR(CAF_SUITE), CAF_XSTR(name), disabled_by_default};
\
}
/* namespace <anonymous> */
\
}
/* namespace <anonymous> */
\
void CAF_UNIQUE(test)::run()
void CAF_UNIQUE(test)::run()
#define CAF_TEST(name) CAF_TEST_IMPL(name, false)
#define CAF_TEST_DISABLED(name) CAF_TEST_IMPL(name, true)
#define CAF_TEST_FIXTURE_SCOPE(scope_name, fixture_name) \
#define CAF_TEST_FIXTURE_SCOPE(scope_name, fixture_name) \
namespace scope_name { using caf_test_case_auto_fixture = fixture_name ;
namespace scope_name { using caf_test_case_auto_fixture = fixture_name ;
...
...
libcaf_test/caf/test/unit_test_impl.hpp
View file @
c2779061
...
@@ -91,11 +91,12 @@ void watchdog::stop() {
...
@@ -91,11 +91,12 @@ void watchdog::stop() {
delete
s_watchdog
;
delete
s_watchdog
;
}
}
test
::
test
(
std
::
string
test_name
)
test
::
test
(
std
::
string
test_name
,
bool
disabled_by_default
)
:
expected_failures_
(
0
),
:
expected_failures_
(
0
),
name_
(
std
::
move
(
test_name
)),
name_
(
std
::
move
(
test_name
)),
good_
(
0
),
good_
(
0
),
bad_
(
0
)
{
bad_
(
0
),
disabled_
(
disabled_by_default
)
{
// nop
// nop
}
}
...
@@ -334,6 +335,14 @@ bool engine::run(bool colorize,
...
@@ -334,6 +335,14 @@ bool engine::run(bool colorize,
&&
!
std
::
regex_search
(
x
,
blacklist
);
&&
!
std
::
regex_search
(
x
,
blacklist
);
};
};
# endif
# endif
auto
test_enabled
=
[
&
](
const
std
::
regex
&
whitelist
,
const
std
::
regex
&
blacklist
,
const
test
&
x
)
{
// Disabled tests run iff explicitly requested by the user, i.e.,
// tests_str is not the ".*" catch-all default.
return
(
!
x
.
disabled
()
||
tests_str
!=
".*"
)
&&
enabled
(
whitelist
,
blacklist
,
x
.
name
());
};
std
::
vector
<
std
::
string
>
failed_tests
;
std
::
vector
<
std
::
string
>
failed_tests
;
for
(
auto
&
p
:
instance
().
suites_
)
{
for
(
auto
&
p
:
instance
().
suites_
)
{
if
(
!
enabled
(
suites
,
not_suites
,
p
.
first
))
if
(
!
enabled
(
suites
,
not_suites
,
p
.
first
))
...
@@ -343,7 +352,7 @@ bool engine::run(bool colorize,
...
@@ -343,7 +352,7 @@ bool engine::run(bool colorize,
bool
displayed_header
=
false
;
bool
displayed_header
=
false
;
size_t
tests_ran
=
0
;
size_t
tests_ran
=
0
;
for
(
auto
&
t
:
p
.
second
)
{
for
(
auto
&
t
:
p
.
second
)
{
if
(
!
enabled
(
tests
,
not_tests
,
t
->
name
()
))
if
(
!
test_enabled
(
tests
,
not_tests
,
*
t
))
continue
;
continue
;
instance
().
current_test_
=
t
.
get
();
instance
().
current_test_
=
t
.
get
();
++
tests_ran
;
++
tests_ran
;
...
...
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