From e5cf89b4ebe786cfadabb79c718eb10263201e2a Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 13 Nov 2020 15:42:07 +0100 Subject: [PATCH 1/4] use defmt-test in the test suite --- Cargo.toml | 1 + testsuite/Cargo.toml | 1 + testsuite/tests/test.rs | 15 +++++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5b0eec7..b30dd96 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,4 +54,5 @@ overflow-checks = false # <- # [patch.crates-io] # defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } # defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } +# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } # panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } \ No newline at end of file diff --git a/testsuite/Cargo.toml b/testsuite/Cargo.toml index 4196815..066839c 100644 --- a/testsuite/Cargo.toml +++ b/testsuite/Cargo.toml @@ -16,6 +16,7 @@ cortex-m = "0.6.3" cortex-m-rt = "0.6.12" defmt = "0.1.0" defmt-rtt = "0.1.0" +defmt-test = "0.1.0" panic-probe = { version = "0.1.0", features = ["print-defmt" ] } [features] diff --git a/testsuite/tests/test.rs b/testsuite/tests/test.rs index 2e8ad89..246e681 100644 --- a/testsuite/tests/test.rs +++ b/testsuite/tests/test.rs @@ -4,9 +4,16 @@ use cortex_m_rt::entry; use {{crate_name}} as _; // memory layout + panic handler -#[entry] -fn main() -> ! { - assert!(false, "TODO: Write actual tests"); +// See https://crates.io/crates/defmt-test/0.1.0 for more documentation +#[defmt_test::tests] +mod tests { + #[test] + fn assert_true() { + assert!(true) + } - {{crate_name}}::exit(); + #[test] + fn assert_false() { + assert!(false, "TODO: write actual tests") + } } From fbd9d9313851dc05523d429169fb35ad7233a80b Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 13 Nov 2020 15:45:03 +0100 Subject: [PATCH 2/4] use defmt-test in the test suite --- testsuite/tests/test.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/tests/test.rs b/testsuite/tests/test.rs index 246e681..bcb3275 100644 --- a/testsuite/tests/test.rs +++ b/testsuite/tests/test.rs @@ -4,7 +4,8 @@ use cortex_m_rt::entry; use {{crate_name}} as _; // memory layout + panic handler -// See https://crates.io/crates/defmt-test/0.1.0 for more documentation +// See https://crates.io/crates/defmt-test/0.1.0 for more documentation (e.g. about the 'state' +// feature) #[defmt_test::tests] mod tests { #[test] From 955d99d962588cf966eaeda477658340ec5dbe85 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 13 Nov 2020 15:50:09 +0100 Subject: [PATCH 3/4] update diff in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f8ad2fb..1980379 100644 --- a/README.md +++ b/README.md @@ -158,10 +158,12 @@ In the example output, the supported version is `3db6b41f08a5c866e6d6ed7103d01b0 -# [patch.crates-io] -# defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } -# defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } +-# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } -# panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version reported by `probe-run --version`" } +[patch.crates-io] +defmt = { git = "https://github.com/knurling-rs/defmt", rev = "3db6b41f08a5c866e6d6ed7103d01b0b0fe5a1f4" } +defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "3db6b41f08a5c866e6d6ed7103d01b0b0fe5a1f4" } ++defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "3db6b41f08a5c866e6d6ed7103d01b0b0fe5a1f4" } +panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "3db6b41f08a5c866e6d6ed7103d01b0b0fe5a1f4" } ``` From 6c5aa23717cca80bf78f29e769977ccb7152b250 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Mon, 16 Nov 2020 16:13:45 +0100 Subject: [PATCH 4/4] remove unused import --- testsuite/tests/test.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/testsuite/tests/test.rs b/testsuite/tests/test.rs index bcb3275..d1002ce 100644 --- a/testsuite/tests/test.rs +++ b/testsuite/tests/test.rs @@ -1,7 +1,6 @@ #![no_std] #![no_main] -use cortex_m_rt::entry; use {{crate_name}} as _; // memory layout + panic handler // See https://crates.io/crates/defmt-test/0.1.0 for more documentation (e.g. about the 'state'