Skip to content

Commit

Permalink
Provide version major/minor/patch macros (#2014)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalff authored Mar 4, 2023
1 parent 4dff60a commit 649829f
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Increment the:
* Fix Prometheus server crash on listening to already used port [#1986](https://github.com/open-telemetry/opentelemetry-cpp/pull/1986)
* [EXPORTER] Boolean environment variables not parsed per the spec
[#1982](https://github.com/open-telemetry/opentelemetry-cpp/pull/1982)
* Provide version major/minor/patch macros
[#2014](https://github.com/open-telemetry/opentelemetry-cpp/pull/2014)

## [1.8.2] 2023-01-31

Expand Down
4 changes: 4 additions & 0 deletions api/include/opentelemetry/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

#define OPENTELEMETRY_ABI_VERSION_NO 1
#define OPENTELEMETRY_VERSION "1.8.2"
#define OPENTELEMETRY_VERSION_MAJOR 1
#define OPENTELEMETRY_VERSION_MINOR 8
#define OPENTELEMETRY_VERSION_PATCH 2

#define OPENTELEMETRY_ABI_VERSION OPENTELEMETRY_STRINGIFY(OPENTELEMETRY_ABI_VERSION_NO)

// clang-format off
Expand Down
15 changes: 15 additions & 0 deletions api/test/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,18 @@ cc_test(
"@com_google_googletest//:gtest_main",
],
)

cc_test(
name = "version_test",
srcs = [
"version_test.cc",
],
tags = [
"api",
"test",
],
deps = [
"//api",
"@com_google_googletest//:gtest_main",
],
)
8 changes: 8 additions & 0 deletions api/test/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ gtest_add_tests(
TARGET timestamp_test
TEST_PREFIX trace.
TEST_LIST timestamp_test)

add_executable(version_test version_test.cc)
target_link_libraries(version_test ${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT} opentelemetry_api)
gtest_add_tests(
TARGET version_test
TEST_PREFIX version.
TEST_LIST version_test)
16 changes: 16 additions & 0 deletions api/test/core/version_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include "opentelemetry/version.h"

#include <gtest/gtest.h>

TEST(VersionTest, Consistency)
{
char expected[10];
snprintf(expected, sizeof(expected), "%d.%d.%d", OPENTELEMETRY_VERSION_MAJOR,
OPENTELEMETRY_VERSION_MINOR, OPENTELEMETRY_VERSION_PATCH);

std::string actual = OPENTELEMETRY_VERSION;
EXPECT_EQ(actual, expected);
}

0 comments on commit 649829f

Please sign in to comment.