History

more robust baseline tests on windows (#450)

Turns out that `tail +2` or channel redirection may reorder lines, or the timing is very different to cause certain output to end up at the end of the stream. Maibe `tail +2` just works differently.

Sebastian Thiel committed 4 years ago

Commit 54ca2671 parent 0c176812 files · +8 −2Browse files

Unified · Split

2 files
  1. git-refspec/tests/fixtures/match_baseline.sh +2 −2
  2. git-refspec/tests/matcher/mod.rs +6 −0
git-refspec/tests/fixtures/match_baseline.sh+2−2
@@ -5,7 +5,7 @@ git init; · 4 unmodified lines
55
66 function baseline() {
77 {
8− git fetch --refmap= --dry-run -v origin "$@" 2>&1 | tail +2
8+ git fetch --refmap= --dry-run -v origin "$@" 2>&1
99 echo specs: "$@"
1010 } >> baseline.git
1111 }
@@ -29,7 +29,7 @@ mkdir base · 17 unmodified lines
2929
3030 git clone --shared ./base clone
3131 (cd clone
32− git ls-remote 2>&1 | tail +2 > remote-refs.list
32+ git ls-remote 2>&1 > remote-refs.list
3333 baseline "refs/heads/main"
3434 baseline "heads/main"
3535 baseline "main"
git-refspec/tests/matcher/mod.rs+6−0
@@ -43,6 +43,9 @@ mod baseline { · 42 unmodified lines
4343 let refs_buf = std::fs::read(dir.join("clone").join("remote-refs.list"))?;
4444 let mut out = Vec::new();
4545 for line in refs_buf.lines() {
46+ if line.starts_with(b"From ") {
47+ continue;
48+ }
4649 let mut tokens = line.splitn(2, |b| *b == b'\t');
4750 let target = ObjectId::from_hex(tokens.next().expect("hex-sha"))?;
4851 let name = tokens.next().expect("name");
@@ -69,6 +72,9 @@ mod baseline { · 20 unmodified lines
6972 let mut map = HashMap::new();
7073 let mut mappings = Vec::new();
7174 for line in buf.lines() {
75+ if line.starts_with(b"From ") {
76+ continue;
77+ }
7278 match line.strip_prefix(b"specs: ") {
7379 Some(specs) => {
7480 let key: Vec<_> = specs.split(|b| *b == b' ').map(BString::from).collect();