reader_test.go
This file
Path
src/reader_test.go
63 lines · 1.3 KiB · Go
Last changed by
Merge branch 'devel'Junegunn Choibefore adoptionb471042
History of this fileTake it
The walk stopped after 200 commits: lines older than 8cf45a5 point at it.
[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 1–12why, one step back1package fzf23import (4 "testing"5 "time"67 "github.com/junegunn/fzf/src/util"8)910func TestReadFromCommand(t *testing.T) {11 strs := []string{}12 eb := util.NewEventBox()Merge branch 'devel'Junegunn Choibefore adoptionb471042
lines 13–15why, one step back13 reader := NewReader(14 func(s []byte) bool { strs = append(strs, string(s)); return true },15 eb, false, true)[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 16–24why, one step back1617 reader.startEventPoller()1819 // Check EventBox20 if eb.Peek(EvtReadNew) {21 t.Error("EvtReadNew should not be set yet")22 }2324 // Normal commandMerge branch 'devel'Junegunn Choibefore adoptionb471042
line 25why, one step back25 reader.fin(reader.readFromCommand(nil, `echo abc && echo def`))[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 26–49why, one step back26 if len(strs) != 2 || strs[0] != "abc" || strs[1] != "def" {27 t.Errorf("%s", strs)28 }2930 // Check EventBox again31 eb.WaitFor(EvtReadFin)3233 // Wait should return immediately34 eb.Wait(func(events *util.Events) {35 events.Clear()36 })3738 // EventBox is cleared39 if eb.Peek(EvtReadNew) {40 t.Error("EvtReadNew should not be set yet")41 }4243 // Make sure that event poller is finished44 time.Sleep(readerPollIntervalMax)4546 // Restart event poller47 reader.startEventPoller()4849 // Failing commandMerge branch 'devel'Junegunn Choibefore adoptionb471042
line 50why, one step back50 reader.fin(reader.readFromCommand(nil, `no-such-command`))[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 51–63why, one step back51 strs = []string{}52 if len(strs) > 0 {53 t.Errorf("%s", strs)54 }5556 // Check EventBox again57 if eb.Peek(EvtReadNew) {58 t.Error("Command failed. EvtReadNew should not be set")59 }60 if !eb.Peek(EvtReadFin) {61 t.Error("EvtReadFin should be set")62 }63}