-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#349] Add service name generator to be able to run tests concurrently #472
Changes from all commits
3a8b0ee
80237bc
7f662b9
b43f92c
b3dfa90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,7 @@ | |
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
use iceoryx2_pal_concurrency_sync::iox_atomic::IoxAtomicU64; | ||
use std::{fmt::Display, sync::atomic::Ordering}; | ||
use std::fmt::Display; | ||
|
||
/// Represents the crates version acquired through the internal environment variables set by cargo, | ||
/// ("CARGO_PKG_VERSION_{MAJOR|MINOR|PATCH}"). | ||
|
@@ -63,26 +62,11 @@ impl PackageVersion { | |
|
||
/// Returns the current [`PackageVersion`] | ||
pub fn get() -> PackageVersion { | ||
static PACKAGE_VERSION: IoxAtomicU64 = IoxAtomicU64::new(0); | ||
const MAJOR: u16 = 0; | ||
const MINOR: u16 = 4; | ||
const PATCH: u16 = 1; | ||
|
||
if PACKAGE_VERSION.load(Ordering::Relaxed) == 0 { | ||
let major = option_env!("CARGO_PKG_VERSION_MAJOR") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.unwrap_or(u16::MAX); | ||
let minor = option_env!("CARGO_PKG_VERSION_MINOR") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.unwrap_or(u16::MAX); | ||
let patch = option_env!("CARGO_PKG_VERSION_PATCH") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.unwrap_or(u16::MAX); | ||
|
||
PACKAGE_VERSION.store( | ||
PackageVersion::from_version(major, minor, patch).0, | ||
Ordering::Relaxed, | ||
); | ||
} | ||
|
||
PackageVersion::from_u64(PACKAGE_VERSION.load(Ordering::Relaxed)) | ||
PackageVersion::from_version(MAJOR, MINOR, PATCH) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious, do we have a specific version convention? not sure why we didn't use the semver, which is popular in rust. so in the future we may have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general we try to be very cautious to introduce external crates. For any other project I would agree with you but iceoryx2 shall be certified as ASIL D according to ISO26262 which is the highest safety standard in the automotive world. This requires 100% MC/DC coverage for every line of code. Every test must be covered by a requirement, we need detailed architecture documents and documentation, a safety manual and so on. So, every dependency we introduce must satisfy all of this! No exception. But actually, nearly none of them does it, and it is a challenge to do it. We have a strategy in place how to solve this but one of the key factors is - try to avoid external crates as much as possible. Another answer we need to find is, how to handle or prevent supply chain attacks. So in light of all of this, we try to be very cautious with external dependencies since the more we have the more work we have to do in the near future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
understood, quite a bit different from the normal project. thanks for your explaination:) |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
use iceoryx2_bb_elementary::package_version::PackageVersion; | ||
use iceoryx2_bb_testing::assert_that; | ||
|
||
#[test] | ||
fn package_version_works() { | ||
let major = option_env!("CARGO_PKG_VERSION_MAJOR") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.expect("Contains a valid major version number."); | ||
let minor = option_env!("CARGO_PKG_VERSION_MINOR") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.expect("Contains a valid minor version number."); | ||
let patch = option_env!("CARGO_PKG_VERSION_PATCH") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.expect("Contains a valid patch version number."); | ||
|
||
let sut = PackageVersion::get(); | ||
|
||
assert_that!(sut.major(), eq major); | ||
assert_that!(sut.minor(), eq minor); | ||
assert_that!(sut.patch(), eq patch); | ||
|
||
assert_that!(major == 0 && minor == 0 && patch == 0, eq false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a script taking care of setting the version number in all known locations would be helpful. I'll add it to my todo list :)