Skip to content

Commit

Permalink
Rollup merge of rust-lang#114377 - Enselic:test_get_dbpath_for_term-u…
Browse files Browse the repository at this point in the history
…tf-8, r=thomcc

test_get_dbpath_for_term(): handle non-utf8 paths (fix FIXME)

Removes a FIXME for rust-lang#9639

Part of rust-lang#44366 which is E-help-wanted

The remaining two FIXMEs for rust-lang#9639 are considerably more complicated, so I will create separate PRs for them.
  • Loading branch information
matthiaskrgr committed Aug 9, 2023
2 parents 7d78885 + d194091 commit 128cc06
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions library/test/src/term/terminfo/searcher/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ fn test_get_dbpath_for_term() {
// woefully inadequate test coverage
// note: current tests won't work with non-standard terminfo hierarchies (e.g., macOS's)
use std::env;
// FIXME (#9639): This needs to handle non-utf8 paths
fn x(t: &str) -> String {
let p = get_dbpath_for_term(t).expect("no terminfo entry found");
p.to_str().unwrap().to_string()
fn x(t: &str) -> PathBuf {
get_dbpath_for_term(t).expect(&format!("no terminfo entry found for {t:?}"))
}
assert!(x("screen") == "/usr/share/terminfo/s/screen");
assert!(get_dbpath_for_term("") == None);
assert_eq!(x("screen"), PathBuf::from("/usr/share/terminfo/s/screen"));
assert_eq!(get_dbpath_for_term(""), None);
env::set_var("TERMINFO_DIRS", ":");
assert!(x("screen") == "/usr/share/terminfo/s/screen");
assert_eq!(x("screen"), PathBuf::from("/usr/share/terminfo/s/screen"));
env::remove_var("TERMINFO_DIRS");
}

0 comments on commit 128cc06

Please sign in to comment.