Add alternate hint ('#')#503
Conversation
Also make formatting match core::fmt.
|
I might need a little bit of help/advice getting this through the CI. |
| match hint { | ||
| Some(DisplayHint::NoHint { zero_pad }) => write!(buf, "{:#01$}", x, zero_pad)?, | ||
| Some(DisplayHint::Binary { zero_pad }) => write!(buf, "{:#01$b}", x, zero_pad)?, | ||
| Some(DisplayHint::NoHint { zero_pad }) => write!(buf, "{:01$}", x, zero_pad)?, |
There was a problem hiding this comment.
Note to future: The body of fn format_u128 and fn format_i128 is pretty much the same. Refactor!
There was a problem hiding this comment.
I did play around with doing this, but you would need something that is generic over u128/i128, or you could refactor it into a macro (since the actual language tokens are the same but the types are different).
You can run the ci, by invoking |
|
The snapshot tests fail because it is missing all the -0.000024 INFO hex [0x48, 0x65, 0x7f, 0x6c, 0x6c, 0x6f]
-0.000025 INFO HEX [0x48, 0x65, 0x7F, 0x6C, 0x6C, 0x6F]
-0.000026 INFO binary [0b1001000, 0b1100101, 0b1111111, 0b1101100, 0b1101100, 0b1101111]
+0.000024 INFO hex [48, 65, 7f, 6c, 6c, 6f]
+0.000025 INFO HEX [48, 65, 7F, 6C, 6C, 6F]
+0.000026 INFO binary [1001000, 1100101, 1111111, 1101100, 1101100, 1101111]You can run only the snapshot tests with We should probably duplicate all the failing ones and have one with |
|
Thanks for the review, I'll have another go at getting it working. Is there a way to overwrite the |
Also add the ability to overwrite output files in snapshot test using xtask. It is sometimes quicker to overwrite the output and then compare it, rather than altering it manually.
c5bdc36 to
4c19d20
Compare
|
OK ready for review again. Let me know if you want me to take back out the |
|
Could you let me know how to fix the last CI error? |
I agree that it seems useful, but can you please send it as a separate PR? |
Will check :) |
The failing backwards-compatability check means, that the output changed compared to the decoder version This might mean this change qualifies as breaking, but I will check with the others. |
Since we don't guarantee backwards-compatability this isn't a problem, we just need to update these tests. |
So the solution is to install |
| leading zeros. This matches [`core::fmt` behavior](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b11809759f975e266251f7968e542756). No further | ||
| customization like padding is supported (at the moment). |
There was a problem hiding this comment.
No further customization like padding is supported (at the moment).
Aren't the leading zeroes a kind of padding?
There was a problem hiding this comment.
Hmm good point, would you like me to change this? Maybe to No further customization is supported (at the moment).?
There was a problem hiding this comment.
(I guess this should have changed with your last PR, but good that we caught it now ;D)
|
Can you please apply following change which should make CI pass? diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6956a1f..6cae683 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -124,8 +124,7 @@ jobs:
- name: Run QEMU snapshot tests
run: cargo xtask test-snapshot
- name: install decoder v0.2.0
- working-directory: firmware/qemu
- run: cargo install --debug --git https://github.com/knurling-rs/defmt --rev v0.2.0-with-qemu-run-ignore-version qemu-run
+ run: cargo install --debug --path qemu-run
- name: Backward compatibility check against decoder v0.2.0
env:
CARGO_TARGET_THUMBV7M_NONE_EABI_RUNNER: qemu-run |
Urhengulas
left a comment
There was a problem hiding this comment.
Just the text-nit and then we are good to merge :)
|
bors d+ (now you should be able to merge it via bors yourself) |
|
✌️ derekdreery can now approve this pull request. To approve and merge a pull request, simply reply with |
|
bors r+ |
|
Build succeeded: |
Also make formatting match
core::fmt.This changes the current behavior, so some thought should be given before accepting. I expect it will break some tests: I'm not sure how to run them all locally so I will rely on CI to find them.
Closes #491