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

defmt-test: Fix #[ignore] attribute #731

Open
liam-b opened this issue Feb 1, 2023 · 3 comments
Open

defmt-test: Fix #[ignore] attribute #731

liam-b opened this issue Feb 1, 2023 · 3 comments
Labels
difficulty: medium Somewhat difficult to solve good first issue Good for newcomers priority: medium Medium priority for the Knurling team type: bug Something isn't working

Comments

@liam-b
Copy link

liam-b commented Feb 1, 2023

It seems to know that the test should be ignored but runs it anyway. I have a minimal reproducible example repo based on the app template modified for the Pixhawk 6C (running an STM32H743).

I did have to move defmt-rtt to version 0.3 because of #713 and I couldn't get flip-link working yet so it is disabled.

Running cargo test --test integration gives me:

   Compiling defmt-test-ignore-bug v0.1.0 (/Users/liam/src/tmp/defmt-test-ignore-bug)
    Finished test [optimized + debuginfo] target(s) in 0.71s
     Running tests/integration.rs (target/thumbv7em-none-eabihf/debug/deps/integration-7afe1656c338520d)
(HOST) INFO  flashing program (8 pages / 8.00 KiB)
(HOST) INFO  success!
────────────────────────────────────────────────────────────────────────────────
(1/2) running `it_works`...
└─ integration::tests::__defmt_test_entry @ tests/integration.rs:13
(2/2) ignoring `it_does_not_work`...
└─ integration::tests::__defmt_test_entry @ tests/integration.rs:19
ERROR panicked at 'should be ignored'
└─ integration::tests::it_does_not_work @ tests/integration.rs:20
────────────────────────────────────────────────────────────────────────────────
(HOST) WARN  no RAM region appears to contain the stack; probe-run can't determine if this was a stack overflow
stack backtrace:
   0: HardFaultTrampoline
      <exception entry>
   1: lib::inline::__udf
        at ./asm/inline.rs:181:5
   2: __udf
        at ./asm/lib.rs:51:17
   3: cortex_m::asm::udf
        at /Users/liam/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.7.7/src/asm.rs:43:5
   4: _defmt_panic
        at src/lib.rs:14:5
   5: main
   6: Reset
(HOST) ERROR the program panicked
error: test failed, to rerun pass `--test integration`

Caused by:
  process didn't exit successfully: `probe-run --chip STM32H743VIHx /Users/liam/src/tmp/defmt-test-ignore-bug/target/thumbv7em-none-eabihf/debug/deps/integration-7afe1656c338520d` (exit status: 6)
@Urhengulas
Copy link
Member

Urhengulas commented Feb 3, 2023

Hi @liam-b, defmt-test doesn't support a #[ignore] attribute at the moment. See https://crates.io/crates/defmt-test regarding what defmt-test can and cannot do.

If you implement it, I am happy to review and merge.

@Urhengulas Urhengulas changed the title defmt-test is not ignoring tests correctly defmt-test: add #[ignore] attribute Feb 3, 2023
@Urhengulas Urhengulas added type: enhancement Enhancement or feature request good first issue Good for newcomers difficulty: easy Pretty easy to solve labels Feb 3, 2023
@jonas-schievink
Copy link
Contributor

#618 implemented support for #[ignore], but has a bug where the function will be run regardless: #618 (comment)

@Urhengulas Urhengulas added type: bug Something isn't working priority: medium Medium priority for the Knurling team difficulty: medium Somewhat difficult to solve and removed type: enhancement Enhancement or feature request difficulty: easy Pretty easy to solve good first issue Good for newcomers labels Mar 28, 2023
@Urhengulas Urhengulas changed the title defmt-test: add #[ignore] attribute defmt-test: Fix #[ignore] attribute Jul 26, 2023
@Urhengulas
Copy link
Member

Urhengulas commented Dec 2, 2024

A call to the ignored function is currently added here:

if ignore {
unit_test_calls.push(quote!(let _ = #call;));

Instead there should be no call, but we should print that the test is ignored.

You can print with quote!{ defmt::println!(...) }.

@Urhengulas Urhengulas added the good first issue Good for newcomers label Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium Somewhat difficult to solve good first issue Good for newcomers priority: medium Medium priority for the Knurling team type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants