Skip to content
Snippets Groups Projects
Verified Commit 447e4747 authored by Justus Winter's avatar Justus Winter
Browse files

tests: Normalize underlines.

  - GnuPG emits a header with underlines in key listings that changes
    with the length of GNUPGHOME.  Now, since the state directories
    are created within TMPDIR, the length of both GNUPGHOME and the
    underline changes.  Previously, we normalized GNUPGHOME, but we
    failed to normalize the underline.

  - Fixes #8.
parent 3cd2e991
No related branches found
No related tags found
1 merge request!54tests: Normalize underlines.
Pipeline #772338412 passed
......@@ -243,12 +243,24 @@ impl Output {
}
/// Canonicalizes the paths in the output.
///
/// This replaces `homedir` with `"/HOMEDIR"` and `experiment`
/// with `"/EXPERIMENT"` in stdout and stderr, and normalizes the
/// underline decorating `homedir` in key listings in stdout.
fn canonicalize(mut self, homedir: &Path, experiment: &Path) -> Self {
const DASHES: &str =
"\n------------------------------------------------------------";
let d = regex::bytes::Regex::new(
&DASHES[..DASHES.len().min(homedir.to_str().unwrap().len() + 1)])
.unwrap();
let h = regex::bytes::Regex::new(homedir.to_str().unwrap()).unwrap();
let e = regex::bytes::Regex::new(experiment.to_str().unwrap()).unwrap();
self.stdout =
e.replace_all(&h.replace_all(&self.stdout, &b"/HOMEDIR"[..]),
&b"/EXPERIMENT"[..])
e.replace_all(
&h.replace_all(
&d.replace_all(&self.stdout, &b"\n--------"[..]),
&b"/HOMEDIR"[..]),
&b"/EXPERIMENT"[..])
.into();
self.stderr =
e.replace_all(&h.replace_all(&self.stderr, &b"/HOMEDIR"[..]),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment