Skip to content
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

PGN testing #411

Merged
merged 5 commits into from
Feb 4, 2025
Merged

PGN testing #411

merged 5 commits into from
Feb 4, 2025

Conversation

acmorrow
Copy link
Member

@acmorrow acmorrow commented Feb 4, 2025

  • Run all tests in the workspace and do not fail fast
  • Avoid need to reiterate PGN numbers in the PGN enum macro.

@acmorrow acmorrow requested a review from gvaradarajan February 4, 2025 16:50
@acmorrow acmorrow requested a review from a team as a code owner February 4, 2025 16:50
@@ -126,7 +126,7 @@ pub struct GnssSatsInView {
}

macro_rules! define_pgns {
( $(($pgndef:ident, $pgn:expr)),* ) => {
( $($pgndef:ident),* ) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't push more for this change in #408 because I wasn't completely sure there wasn't a reason it didn't work, but it sure seems to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, ok. Sounds good to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the one thing to check is whether this NmeaMessageBody type actually has any tests? If you want, I'll add one.

Copy link
Member

@gvaradarajan gvaradarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -68,7 +68,7 @@ upload: cargo-ver
cargo +esp espflash flash --package micro-rdk-server --monitor --partition-table micro-rdk-server/esp32/partitions.csv --baud 460800 -f 80mhz --bin micro-rdk-server-esp32 --target=xtensa-esp32-espidf -Zbuild-std=std,panic_abort

test:
cargo test -p micro-rdk --lib --features native,ota
cargo test --workspace --tests --no-fail-fast --features native,ota
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is --no-fail-fast?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It prevents a failing test from stopping the execution of other tests. I'd much prefer to learn in one go all the tests I broke, rather than it stopping on the first failure.

Copy link
Member Author

@acmorrow acmorrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, PTAL. I also fixed some new warnings that popped up with the expanded testing.

Comment on lines +159 to +169
let nmea_message = NmeaMessage::try_from(data);
assert!(nmea_message.is_ok());

let nmea_message = nmea_message.unwrap();
let message = match nmea_message.data {
NmeaMessageBody::GnssSatsInView(val) => Some(val),
_ => None,
};
assert!(message.is_some());
let message = message.unwrap();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gvaradarajan - New since last review, this now ensures that the NmeaMessage enum gets tested at least once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for adding this

);

pub struct NmeaMessage {
metadata: NmeaMessageMetadata,
data: NmeaMessageBody,
pub metadata: NmeaMessageMetadata,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for testing, let me know if you would prefer accessors, but I find them less interesting in a language where immutability is the default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's just for testing, would pub(crate) work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, I think it would. I always forget that that is an option. Too accustomed to C++ having only public/private. If it works I'll make that change before push.

@acmorrow acmorrow requested a review from gvaradarajan February 4, 2025 17:32
Copy link
Member

@gvaradarajan gvaradarajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +159 to +169
let nmea_message = NmeaMessage::try_from(data);
assert!(nmea_message.is_ok());

let nmea_message = nmea_message.unwrap();
let message = match nmea_message.data {
NmeaMessageBody::GnssSatsInView(val) => Some(val),
_ => None,
};
assert!(message.is_some());
let message = message.unwrap();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for adding this

);

pub struct NmeaMessage {
metadata: NmeaMessageMetadata,
data: NmeaMessageBody,
pub metadata: NmeaMessageMetadata,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's just for testing, would pub(crate) work?

@@ -504,6 +504,7 @@ impl LocalRobot {
}

pub fn get_periodic_app_client_tasks(&mut self) -> Vec<Box<dyn PeriodicAppClientTask>> {
#[allow(unused_mut)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yes, finally

@acmorrow acmorrow merged commit 4ab0be2 into viamrobotics:main Feb 4, 2025
6 checks passed
@acmorrow
Copy link
Member Author

acmorrow commented Feb 4, 2025

@gvaradarajan - Oops. I thought I'd committed and pushed the change to pub(crate) but it turns out I'd only staged it. However, having thought about it more, NmeaMessage is pub, but none of its fields are, which means the only thing you can do with it is create it, or serialize it. That feels pretty restrictive. Anyway, happy to make a follow-up commit if you disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants