Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6991f16

Browse files
committed
tests: update Catch2 to v3.12.0
Catch2 v3 requires C++14. Because Babeltrace 2 requires C++17 now, we can update it. The main benefit of Catch2 v3 is that it's built as a static library, making the build time of our test sources significantly faster (and the compiler less memory hungry). Signed-off-by: Philippe Proulx <[email protected]> Change-Id: Ib24e9d71e8a4bb69295c21677870307bd3fca12f
1 parent f1ecc81 commit 6991f16

311 files changed

Lines changed: 29268 additions & 18040 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ According with:
4848
LICENSES/GPL-2.0
4949

5050

51+
The Catch2 C++ test framework is provided under the terms of the Boost
52+
Software License 1.0:
53+
54+
SPDX-License-Identifier: BSL-1.0
55+
56+
According with:
57+
58+
LICENSES/BSL-1.0
59+
60+
It's only used when running the tests in the source tree. This applies to:
61+
62+
tests/utils/catch2/*
63+
64+
5165
The library documentation is provided under the terms of the Creative Commons
5266
Attribution Share Alike 4.0 International:
5367

tests/Makefile.am

Lines changed: 299 additions & 2 deletions
Large diffs are not rendered by default.

tests/bitfield/test-bitfield.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
#include "compat/bitfield.h"
1515

16-
#define CATCH_CONFIG_MAIN
17-
#include "catch.hpp"
16+
#include "catch2/catch_test_macros.hpp"
1817

1918
unsigned int glob;
2019

tests/conftest.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ def __init__(
243243
self._catch2_test_name = catch2_test_name
244244
self._build_root_dir = build_root_dir
245245

246+
# Catch2 test name with special test spec characters escaped.
247+
@property
248+
def _escaped_catch2_test_name(self) -> str:
249+
return re.sub(r"([\\,\[*~])", r"\\\1", self._catch2_test_name)
250+
246251
def runtest(self) -> None:
247252
_logger.info(
248253
"Running Catch2 test case `{}` in `{}`".format(
@@ -252,7 +257,7 @@ def runtest(self) -> None:
252257
result = btu.run(
253258
self._build_root_dir,
254259
self._test_binary,
255-
[self._catch2_test_name],
260+
[self._escaped_catch2_test_name],
256261
)
257262

258263
if result.returncode != 0:
@@ -316,16 +321,12 @@ def collect(self) -> List[_Catch2TestItem]:
316321
assert os.access(test_binary, os.X_OK)
317322

318323
# List test names from Catch2.
319-
#
320-
# With the `--list-test-names-only` option, Catch2 uses the
321-
# number of test cases as its exit status. Therefore ignore the
322-
# exit status here.
323324
_logger.info("Listing Catch2 test case names from `{}`".format(test_binary))
324325
build_root_dir = _config_build_root_dir(self.config)
325326
result = btu.run(
326327
build_root_dir,
327328
test_binary,
328-
["--list-test-names-only"],
329+
["--list-tests", "-v", "quiet", "--order", "decl"],
329330
)
330331
_logger.debug(result.stdout)
331332

tests/cpp-common/test-c-string-view.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
#include "cpp-common/bt2c/c-string-view.hpp"
1010

11-
#define CATCH_CONFIG_MAIN
12-
13-
#include "catch.hpp"
11+
#include "catch2/catch_test_macros.hpp"
1412

1513
namespace {
1614

tests/cpp-common/test-unicode-conv.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
#include "cpp-common/bt2c/unicode-conv.hpp"
1010

11-
#define CATCH_CONFIG_MAIN
12-
13-
#include "catch.hpp"
11+
#include "catch2/catch_test_macros.hpp"
1412

1513
namespace {
1614

tests/cpp-common/test-uuid.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#include "cpp-common/bt2c/uuid.hpp"
88
#include "cpp-common/vendor/fmt/format.h"
99

10-
#define CATCH_CONFIG_MAIN
11-
12-
#include "catch.hpp"
10+
#include "catch2/catch_test_macros.hpp"
1311

1412
namespace {
1513

tests/ctf-writer/test-ctf-writer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#include <babeltrace2-ctf-writer/trace.h>
1515
#include <babeltrace2-ctf-writer/writer.h>
1616
#include <fcntl.h>
17+
#include <float.h>
1718
#include <glib.h>
19+
#include <math.h>
1820
#include <stdio.h>
1921
#include <string.h>
2022
#include <unistd.h>
@@ -23,11 +25,8 @@
2325

2426
#include "common/uuid.h"
2527
#include "compat/limits.h"
26-
#define CATCH_CONFIG_MAIN
27-
#include <float.h>
28-
#include <math.h>
2928

30-
#include "catch.hpp"
29+
#include "catch2/catch_test_macros.hpp"
3130

3231
extern "C" {
3332

tests/lib/test-bt-values.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
#include "cpp-common/bt2/value.hpp"
1313

14-
#define CATCH_CONFIG_MAIN
15-
16-
#include "catch.hpp"
14+
#include "catch2/catch_test_macros.hpp"
1715

1816
TEST_CASE("Null value")
1917
{

tests/lib/test-fields.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
#include <functional>
88

9+
#include "catch2/catch_test_macros.hpp"
910
#include "utils/run-in.hpp"
1011

11-
#define CATCH_CONFIG_MAIN
12-
13-
#include "catch.hpp"
14-
1512
namespace {
1613

1714
class StringFieldRunIn final : public RunIn

0 commit comments

Comments
 (0)