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
5 5
6function baseline() {6function baseline() {
7 {7 {
8 git fetch --refmap= --dry-run -v origin "$@" 2>&1 | tail +28 git fetch --refmap= --dry-run -v origin "$@" 2>&1
9 echo specs: "$@"9 echo specs: "$@"
10 } >> baseline.git10 } >> baseline.git
11}11}
@@ -29,7 +29,7 @@ mkdir base · 17 unmodified lines
29 29
30git clone --shared ./base clone30git clone --shared ./base clone
31(cd clone31(cd clone
32 git ls-remote 2>&1 | tail +2 > remote-refs.list32 git ls-remote 2>&1 > remote-refs.list
33 baseline "refs/heads/main"33 baseline "refs/heads/main"
34 baseline "heads/main"34 baseline "heads/main"
35 baseline "main"35 baseline "main"
git-refspec/tests/matcher/mod.rs+6−0
@@ -43,6 +43,9 @@ mod baseline { · 42 unmodified lines
43 let refs_buf = std::fs::read(dir.join("clone").join("remote-refs.list"))?;43 let refs_buf = std::fs::read(dir.join("clone").join("remote-refs.list"))?;
44 let mut out = Vec::new();44 let mut out = Vec::new();
45 for line in refs_buf.lines() {45 for line in refs_buf.lines() {
46 if line.starts_with(b"From ") {
47 continue;
48 }
46 let mut tokens = line.splitn(2, |b| *b == b'\t');49 let mut tokens = line.splitn(2, |b| *b == b'\t');
47 let target = ObjectId::from_hex(tokens.next().expect("hex-sha"))?;50 let target = ObjectId::from_hex(tokens.next().expect("hex-sha"))?;
48 let name = tokens.next().expect("name");51 let name = tokens.next().expect("name");
@@ -69,6 +72,9 @@ mod baseline { · 20 unmodified lines
69 let mut map = HashMap::new();72 let mut map = HashMap::new();
70 let mut mappings = Vec::new();73 let mut mappings = Vec::new();
71 for line in buf.lines() {74 for line in buf.lines() {
75 if line.starts_with(b"From ") {
76 continue;
77 }
72 match line.strip_prefix(b"specs: ") {78 match line.strip_prefix(b"specs: ") {
73 Some(specs) => {79 Some(specs) => {
74 let key: Vec<_> = specs.split(|b| *b == b' ').map(BString::from).collect();80 let key: Vec<_> = specs.split(|b| *b == b' ').map(BString::from).collect();