mirror of
https://github.com/walles/moar.git
synced 2024-11-23 05:53:18 +03:00
Use the same waiting code in all places
This commit is contained in:
parent
9f3f62d6ee
commit
2e1dd0ec82
@ -267,9 +267,7 @@ func TestFindFirstHitSimple(t *testing.T) {
|
||||
pager := NewPager(reader)
|
||||
pager.screen = twin.NewFakeScreen(40, 10)
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, pager.reader._wait())
|
||||
|
||||
pager.searchPattern = toPattern("AB")
|
||||
|
||||
@ -283,9 +281,7 @@ func TestFindFirstHitAnsi(t *testing.T) {
|
||||
pager := NewPager(reader)
|
||||
pager.screen = twin.NewFakeScreen(40, 10)
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, pager.reader._wait())
|
||||
|
||||
pager.searchPattern = toPattern("AB")
|
||||
|
||||
@ -299,9 +295,7 @@ func TestFindFirstHitNoMatch(t *testing.T) {
|
||||
pager := NewPager(reader)
|
||||
pager.screen = twin.NewFakeScreen(40, 10)
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, pager.reader._wait())
|
||||
|
||||
pager.searchPattern = toPattern("this pattern should not be found")
|
||||
|
||||
@ -314,9 +308,7 @@ func TestFindFirstHitNoMatchBackwards(t *testing.T) {
|
||||
pager := NewPager(reader)
|
||||
pager.screen = twin.NewFakeScreen(40, 10)
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, pager.reader._wait())
|
||||
|
||||
pager.searchPattern = toPattern("this pattern should not be found")
|
||||
theEnd := *linenumbers.LineNumberFromLength(reader.GetLineCount())
|
||||
@ -347,9 +339,7 @@ func TestScrollToBottomWrapNextToLastLine(t *testing.T) {
|
||||
pager.ShowLineNumbers = false
|
||||
pager.screen = screen
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, pager.reader._wait())
|
||||
|
||||
// This is what we're testing really
|
||||
pager.scrollToEnd()
|
||||
@ -511,8 +501,7 @@ func TestPageSamples(t *testing.T) {
|
||||
}()
|
||||
|
||||
myReader := NewReaderFromStream(fileName, file, chroma.Style{}, nil, nil)
|
||||
for !myReader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, myReader._wait())
|
||||
|
||||
pager := NewPager(myReader)
|
||||
pager.WrapLongLines = false
|
||||
|
@ -15,9 +15,7 @@ func TestNotFoundFindPrevious(t *testing.T) {
|
||||
pager := NewPager(reader)
|
||||
pager.screen = twin.NewFakeScreen(40, 2)
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, reader._wait())
|
||||
|
||||
// Look for a hit on the second line
|
||||
pager.searchPattern = toPattern("bepa")
|
||||
@ -36,9 +34,7 @@ func TestWrapSearchBackwards(t *testing.T) {
|
||||
pager := NewPager(reader)
|
||||
pager.screen = twin.NewFakeScreen(40, 3)
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, reader._wait())
|
||||
|
||||
// Looking for this should take us to the last line
|
||||
pager.searchPattern = toPattern("gold")
|
||||
|
@ -368,10 +368,7 @@ func BenchmarkReaderDone(b *testing.B) {
|
||||
readMe, err := NewReaderFromFilename(filename, *styles.Get("native"), formatters.TTY16m, nil)
|
||||
assert.NilError(b, err)
|
||||
|
||||
// Wait for the reader to finish
|
||||
//revive:disable-next-line:empty-block
|
||||
for !readMe.done.Load() {
|
||||
}
|
||||
assert.NilError(b, readMe._wait())
|
||||
assert.NilError(b, readMe.err)
|
||||
}
|
||||
}
|
||||
@ -406,9 +403,7 @@ func BenchmarkReadLargeFile(b *testing.B) {
|
||||
readMe, err := NewReaderFromFilename(largeFileName, *styles.Get("native"), formatters.TTY16m, nil)
|
||||
assert.NilError(b, err)
|
||||
|
||||
// Wait for the reader to finish
|
||||
for !readMe.done.Load() {
|
||||
}
|
||||
assert.NilError(b, readMe._wait())
|
||||
assert.NilError(b, readMe.err)
|
||||
}
|
||||
}
|
||||
|
@ -152,9 +152,7 @@ func TestWrapping(t *testing.T) {
|
||||
pager.WrapLongLines = true
|
||||
pager.ShowLineNumbers = false
|
||||
|
||||
// Wait for reader to finish reading
|
||||
for !reader.done.Load() {
|
||||
}
|
||||
assert.NilError(t, reader._wait())
|
||||
|
||||
// This is what we're testing really
|
||||
pager.scrollToEnd()
|
||||
|
Loading…
Reference in New Issue
Block a user