Skip to content

Commit

Permalink
canonicalize on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanmorley committed Apr 13, 2022
1 parent 099e422 commit 54cf69e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/aws/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ foo"#
Caused by:
3:3 expecting \"[Some('='), Some(':')]\" but found EOF.",
tempfile.path()
normalize(tempfile.path())
)
);

Expand Down Expand Up @@ -289,7 +289,7 @@ aws_secret_access_key=SECRET_ACCESS_KEY2"#
Caused by:
Key \"foo\\n\\n[example2]\\naws_access_key_id\" in Section Some(\"example\") must not contain '\\n'",
tempfile.path()
normalize(tempfile.path())
)
);

Expand Down Expand Up @@ -353,4 +353,22 @@ foo=bar"#

Ok(())
}

/// For some reason, windows paths go through some canonicalization step
/// when used in errors.
///
/// This is to emulate this behaviour during testing
fn normalize<P: AsRef<Path>>(p: P) -> String {
let path = p.as_ref();

#[cfg(target_os = "windows")]
{
format!(r"\\?\{}", path.to_string_lossy())
}

#[cfg(not(target_os = "windows"))]
{
path.to_string_lossy().into_owned()
}
}
}

0 comments on commit 54cf69e

Please sign in to comment.