History

Make tests more robust; fix windows tests (#450)

Sebastian Thiel committed 4 years ago

Commit 1983fbc1 parent 8c686e03 files · +14 −8Browse files

Unified · Split

3 files
  1. git-repository/src/config/snapshot/credential_helpers.rs +9 −6
  2. git-repository/tests/fixtures/make_remote_repos.sh +2 −2
  3. tests/tools/src/lib.rs +3 −0
git-repository/src/config/snapshot/credential_helpers.rs+9−6
@@ -17,7 +17,7 @@ mod error { · 16 unmodified lines
1717 },
1818 }
1919 }
20−use crate::bstr::ByteVec;
20+use crate::bstr::{ByteSlice, ByteVec};
2121 pub use error::Error;
2222
2323 impl Snapshot<'_> {
@@ -45,14 +45,17 @@ impl Snapshot<'_> { · 21 unmodified lines
4545 match section.header().subsection_name() {
4646 Some(_) => {}
4747 None => {
48− for value in section.values("helper") {
48+ for value in section.values("helper").into_iter().filter(|v| !v.trim().is_empty()) {
4949 programs.push(git_credentials::Program::from_custom_definition(value.into_owned()));
5050 }
5151 if let Some(Some(user)) = (!url_had_user_initially).then(|| {
52− section.value("username").and_then(|n| {
53− let n: Vec<_> = Cow::into_owned(n).into();
54− n.into_string().ok()
55− })
52+ section
53+ .value("username")
54+ .filter(|n| !n.trim().is_empty())
55+ .and_then(|n| {
56+ let n: Vec<_> = Cow::into_owned(n).into();
57+ n.into_string().ok()
58+ })
5659 }) {
5760 url.set_user(Some(user));
5861 }
git-repository/tests/fixtures/make_remote_repos.sh+2−2
@@ -199,8 +199,8 @@ git clone --shared base credential-helpers · 198 unmodified lines
199199 } >> baseline.git
200200 }
201201
202− git config credential.helper ''
203− git config credential.helper global
202+ git config credential.helper ""
203+ git config --add credential.helper global
204204 git config credential.https://example.com:8080.helper example-with-port
205205 git config credential.https://example.com:8080/path.helper example-with-port-and-path
206206 git config credential.https://example.com:8080/path.usehttppath 1
tests/tools/src/lib.rs+3−0
@@ -317,6 +317,9 @@ fn scripted_fixture_repo_read_only_with_args_inner( · 316 unmodified lines
317317 .stderr(std::process::Stdio::piped())
318318 .current_dir(&script_result_directory)
319319 .env_remove("GIT_DIR")
320+ .env_remove("GIT_ASKPASS")
321+ .env_remove("SSH_ASKPASS")
322+ .env("GIT_TERMINAL_PROMPT", "false")
320323 .env("GIT_AUTHOR_DATE", "2000-01-01 00:00:00 +0000")
321324 .env("GIT_AUTHOR_EMAIL", "author@example.com")
322325 .env("GIT_AUTHOR_NAME", "author")