Skip to content

PGN testing#411

Merged
acmorrow merged 5 commits intoviamrobotics:mainfrom
acmorrow:pgn-testing
Feb 4, 2025
Merged

PGN testing#411
acmorrow merged 5 commits intoviamrobotics:mainfrom
acmorrow:pgn-testing

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

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
Contributor

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
Contributor

@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


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

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
Contributor

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
Contributor

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
Contributor

@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
Contributor

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
Contributor

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?

}

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

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