Skip to content

Commit 649829f

Browse files
authored
Provide version major/minor/patch macros (#2014)
1 parent 4dff60a commit 649829f

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Increment the:
3333
* Fix Prometheus server crash on listening to already used port [#1986](https://github.com/open-telemetry/opentelemetry-cpp/pull/1986)
3434
* [EXPORTER] Boolean environment variables not parsed per the spec
3535
[#1982](https://github.com/open-telemetry/opentelemetry-cpp/pull/1982)
36+
* Provide version major/minor/patch macros
37+
[#2014](https://github.com/open-telemetry/opentelemetry-cpp/pull/2014)
3638

3739
## [1.8.2] 2023-01-31
3840

api/include/opentelemetry/version.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
#define OPENTELEMETRY_ABI_VERSION_NO 1
1010
#define OPENTELEMETRY_VERSION "1.8.2"
11+
#define OPENTELEMETRY_VERSION_MAJOR 1
12+
#define OPENTELEMETRY_VERSION_MINOR 8
13+
#define OPENTELEMETRY_VERSION_PATCH 2
14+
1115
#define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO)
1216

1317
// clang-format off

api/test/core/BUILD

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,18 @@ cc_test(
1515
"@com_google_googletest//:gtest_main",
1616
],
1717
)
18+
19+
cc_test(
20+
name = "version_test",
21+
srcs = [
22+
"version_test.cc",
23+
],
24+
tags = [
25+
"api",
26+
"test",
27+
],
28+
deps = [
29+
"//api",
30+
"@com_google_googletest//:gtest_main",
31+
],
32+
)

api/test/core/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ gtest_add_tests(
1010
TARGET timestamp_test
1111
TEST_PREFIX trace.
1212
TEST_LIST timestamp_test)
13+
14+
add_executable(version_test version_test.cc)
15+
target_link_libraries(version_test ${GTEST_BOTH_LIBRARIES}
16+
${CMAKE_THREAD_LIBS_INIT} opentelemetry_api)
17+
gtest_add_tests(
18+
TARGET version_test
19+
TEST_PREFIX version.
20+
TEST_LIST version_test)

api/test/core/version_test.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
#include "opentelemetry/version.h"
5+
6+
#include <gtest/gtest.h>
7+
8+
TEST(VersionTest, Consistency)
9+
{
10+
char expected[10];
11+
snprintf(expected, sizeof(expected), "%d.%d.%d", OPENTELEMETRY_VERSION_MAJOR,
12+
OPENTELEMETRY_VERSION_MINOR, OPENTELEMETRY_VERSION_PATCH);
13+
14+
std::string actual = OPENTELEMETRY_VERSION;
15+
EXPECT_EQ(actual, expected);
16+
}

0 commit comments

Comments
 (0)