You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tl;dr: some tests still fail for users that had old git clone and didn't cargo update after git pull, even though the lib works as intended.
But since the lib can handle control chars of either width 0 or 1, should I mod the currently failing tests to handle both width 0 or 1 ? and should I do it without introducing a build.rs ? or just do nothing and thus allow tests to catch when width is != 1 in the future ?
I cherry-picked the last commit (just removed the \0 width test, so we're not tied to unicode-width 1.1.13)
in other words, you wanted it to work with either 0.1.12 or 0.1.13 (but also for tests to not fail as well), as you've mentioned here also:
The crash should now be fixed with the latest commit, which ignores \0 (when using unicode-width < 0.1.13), or replaces it with � (when using unicode-width >= 0.1.13).
however, with unicode-width 0.1.12, all control chars have width 0 (I've just tested) therefore this whole test(which already covers \0 as well) will fail:
let unicode_escape = format!("\\u{{{:04X}}}", c.chars().last().unwrap()asu32);
assert_eq!(
width,1,
"Width of control character {} is not 1",
unicode_escape
);
}
}
so not just the test for \0 that got removed in the aforementioned commit.
I'm not sure(unless add build.rs1) how to conditionally make the test depend on 0.1.12 and check for width 0, and also if >=0.1.13 check for width 1, but the initial intent was that if the assumed width changes in a future unicode-width update, we should have tests fail, else we wouldn't know that bugs creep in due to width being different now (such as: sizes and shadows being off), even though the lib can current handle both widths: 0 or 1. Maybe given this, can mod the test for width being < 2 but there's the test below which might need some tweaking too(if build.rs introduction isn't wanted).
Alternatively, maybe it doesn't matter in this case that the cargo test will fail for users which just git pull-ed new changes(due to them having their own Cargo.lock locally, because it's in .gitignore), because, while this test fails, the lib does work as expected, and the user is in fact expected to cargo update anyway.
Additionally this test will fail too, for those users that didn't cargo update to get unicode-width 0.1.13: $ cargo test --example select_test -- --nocapture, in particular tests::control_chars_become_replacement_char and tests::nuls_become_replacement_char.
But again, all the mentioned tests only fail for users that didn't cargo update, not for anyone who did a fresh git clone for example. And we kinda want these tests to fail to catch future width changes, I'd think.
Cursive version (from crates.io, from git, ...)
latest commit which currently is: 332a6a4
Additional context
nits: I forgot to mention that in commit in code comments, it's unicode-width instead of unicode-segmentation(which is at 1.11.0 and has no effect on width, from what I can tell)
Footnotes
without introducing a build.rs(which would set an expected width(based on unicode-width version, so it would be either 0 or 1) in a new .rs that we'd include!() and thus can use that in the test). I'd be happy to do it, if you'd just let me know that you want this. ↩
The text was updated successfully, but these errors were encountered:
I'll make a proof-of-concept PR that shows how it would look like if the tests supported both widths (0 and 1) because the lib already does, and without needing a build.rs; it doesn't have to be merged, but it can be if this version of handling the issue is chosen.
Describe the bug
tl;dr: some tests still fail for users that had old
git clone
and didn'tcargo update
aftergit pull
, even though the lib works as intended.But since the lib can handle control chars of either width 0 or 1, should I mod the currently failing tests to handle both width
0
or1
? and should I do it without introducing abuild.rs
? or just do nothing and thus allow tests to catch when width is!= 1
in the future ?In this commit:
af7c3d7
I see the intention was as you've mentioned:
in other words, you wanted it to work with either 0.1.12 or 0.1.13 (but also for tests to not fail as well), as you've mentioned here also:
however, with unicode-width 0.1.12, all control chars have width 0 (I've just tested) therefore this whole test(which already covers
\0
as well) will fail:cursive/cursive-core/src/utils/lines/spans/tests.rs
Lines 32 to 61 in 332a6a4
so not just the test for
\0
that got removed in the aforementioned commit.I'm not sure(unless add
build.rs
1) how to conditionally make the test depend on 0.1.12 and check for width 0, and also if >=0.1.13 check for width 1, but the initial intent was that if the assumedwidth
changes in a futureunicode-width
update, we should have tests fail, else we wouldn't know that bugs creep in due to width being different now (such as: sizes and shadows being off), even though the lib can current handle both widths: 0 or 1. Maybe given this, can mod the test forwidth
being< 2
but there's the test below which might need some tweaking too(ifbuild.rs
introduction isn't wanted).Alternatively, maybe it doesn't matter in this case that the
cargo test
will fail for users which justgit pull
-ed new changes(due to them having their ownCargo.lock
locally, because it's in.gitignore
), because, while this test fails, the lib does work as expected, and the user is in fact expected tocargo update
anyway.Additionally this test will fail too, for those users that didn't
cargo update
to get unicode-width 0.1.13:$ cargo test --example select_test -- --nocapture
, in particulartests::control_chars_become_replacement_char
andtests::nuls_become_replacement_char
.But again, all the mentioned tests only fail for users that didn't
cargo update
, not for anyone who did a freshgit clone
for example. And we kinda want these tests to fail to catch futurewidth
changes, I'd think.To Reproduce
git clone
unicode-width
0.1.12cargo update
cargo test test_control_chars_have_width_1 -- --nocapture
cargo test --example select_test -- --nocapture
Expected behavior
for users with stale
Cargo.lock
, tests wouldn't fail.Screenshots
N/A
Environment
locale
in a terminal)latest commit which currently is: 332a6a4
Additional context
nits: I forgot to mention that in commit in code comments, it's
unicode-width
instead ofunicode-segmentation
(which is at1.11.0
and has no effect on width, from what I can tell)Footnotes
without introducing a
build.rs
(which would set an expectedwidth
(based on unicode-width version, so it would be either0
or1
) in a new.rs
that we'dinclude!()
and thus can use that in the test). I'd be happy to do it, if you'd just let me know that you want this. ↩The text was updated successfully, but these errors were encountered: