Skip to content

defmt-test: Modify attributes in place and handle #[cfg]#383

Merged
bors[bot] merged 2 commits intoknurling-rs:mainfrom
jonas-schievink:test-attrs
Feb 10, 2021
Merged

defmt-test: Modify attributes in place and handle #[cfg]#383
bors[bot] merged 2 commits intoknurling-rs:mainfrom
jonas-schievink:test-attrs

Conversation

@jonas-schievink
Copy link
Copy Markdown
Contributor

Closes (?) #381 (but doesn't add #[ignore] support)

This changes the defmt-test macro to retain the ItemFns and selectively delete defmt-test-specific attributes from them. The result is that the code is now simpler and arbitrary Rust attributes can be attached to tests. Doing so with #[ignore] gives the expected "unused attribute" warning.

@jonas-schievink jonas-schievink added the pr waits on: review Pull Request is waiting on review label Feb 10, 2021
@jonas-schievink jonas-schievink changed the title Modify attributes in place and handle #[cfg] defmt-test: Modify attributes in place and handle #[cfg] Feb 10, 2021
Comment thread firmware/defmt-test/macros/src/lib.rs Outdated
format!(
"({}/{}) running `{}`...",
i + 1,
tests.len(),
Copy link
Copy Markdown
Member

@japaric japaric Feb 10, 2021

Choose a reason for hiding this comment

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

the number of tests that will run is not known in this context because cfg are evaluated after expansion

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I changed it so it gets computed at runtime (or in a const) in adce0f3

Comment thread firmware/qemu/src/bin/defmt-test.rs
Copy link
Copy Markdown
Member

@japaric japaric left a comment

Choose a reason for hiding this comment

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

The overall approach looks good to me but the log messages that report which test is run next should also be cfg-ed

@japaric
Copy link
Copy Markdown
Member

japaric commented Feb 10, 2021

bors r+

@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Feb 10, 2021

Build succeeded:

@bors bors Bot merged commit 1081084 into knurling-rs:main Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr waits on: review Pull Request is waiting on review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants