Skip to content

Commit

Permalink
Merge pull request knurling-rs#786 from knurling-rs/defmt-test-semiho…
Browse files Browse the repository at this point in the history
…sting-exit

`defmt-test`: Exit with semihosting exit
  • Loading branch information
Urhengulas authored Oct 11, 2023
2 parents ae2d0df + 49f0669 commit df760c6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- [#786]: `defmt-test`: Exit with semihosting exit

[#786]: https://github.com/knurling-rs/defmt/pull/786

## defmt-decoder v0.3.9, defmt-print v0.3.10 - 2023-10-04

- [#784]: `defmt-decoder`: Prepare `defmt-decoder v0.3.9` release
Expand Down
2 changes: 1 addition & 1 deletion decoder/src/log/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ pub fn take_until_unbalanced(
index += n;
let mut it = i[index..].chars();
match it.next().unwrap_or_default() {
c if c == '\\' => {
'\\' => {
// Skip the escape char `\`.
index += '\\'.len_utf8();
// Skip also the following char.
Expand Down
2 changes: 1 addition & 1 deletion firmware/defmt-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/knurling-rs/defmt"
version = "0.3.0"

[dependencies]
cortex-m = "0.7"
cortex-m-rt = "0.7"
cortex-m-semihosting = "0.5"
defmt = { version = "0.3", path = "../../defmt" }
defmt-test-macros = { version = "=0.3.0", path = "macros" }
5 changes: 4 additions & 1 deletion firmware/defmt-test/src/export.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use cortex_m_rt as _;
use cortex_m_semihosting::debug;
pub use defmt::info;

use crate::TestOutcome;

/// Terminates the application and makes a semihosting-capable debug tool exit
/// with status code 0.
pub fn exit() -> ! {
loop {
cortex_m::asm::bkpt()
debug::exit(debug::EXIT_SUCCESS);
}
}

Expand Down
4 changes: 2 additions & 2 deletions macros/src/function_like/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ pub(crate) fn expand_parsed(level: Level, args: Args) -> TokenStream2 {

let formatting_exprs = args
.formatting_args
.map(|punctuated| punctuated.into_iter().collect())
.unwrap_or_else(Vec::new);
.map(|punctuated| punctuated.into_iter().collect::<Vec<_>>())
.unwrap_or_default();

let Codegen { patterns, exprs } = Codegen::new(
&fragments,
Expand Down
4 changes: 2 additions & 2 deletions macros/src/function_like/println.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub(crate) fn expand_parsed(args: Args) -> TokenStream2 {

let formatting_exprs = args
.formatting_args
.map(|punctuated| punctuated.into_iter().collect())
.unwrap_or_else(Vec::new);
.map(|punctuated| punctuated.into_iter().collect::<Vec<_>>())
.unwrap_or_default();

let Codegen { patterns, exprs } = Codegen::new(
&fragments,
Expand Down

0 comments on commit df760c6

Please sign in to comment.