Skip to content
Myr

reader_test.go

This file

Path

src/reader_test.go

64 lines · 1.3 KiB · Go

Last changed by

Add --with-shell for shelling out with different command and flags (#3746)Junegunn Choibefore adoptiona4391ae

History of this file

Take it

The walk stopped after 200 commits: lines older than d75bb5c point at it.

Deploying to master from @ junegunn/fzf@2671259fdb3094a5eac528f291c1fdadbcf9eda9 🚀junegunnbefore adoptiond75bb5c

lines 1–12why, one step back
1package fzf
23import (4 "testing"5 "time"67 "github.com/junegunn/fzf/src/util"8)910func TestReadFromCommand(t *testing.T) {11 strs := []string{}12 eb := util.NewEventBox()

Add --with-shell for shelling out with different command and flags (#3746)Junegunn Choibefore adoptiona4391ae

line 13why, one step back
13 exec := util.NewExecutor("")

Deploying to master from @ junegunn/fzf@2671259fdb3094a5eac528f291c1fdadbcf9eda9 🚀junegunnbefore adoptiond75bb5c

lines 14–15why, one step back
14 reader := NewReader(
15 func(s []byte) bool { strs = append(strs, string(s)); return true },

Add --with-shell for shelling out with different command and flags (#3746)Junegunn Choibefore adoptiona4391ae

line 16why, one step back
16 eb, exec, false, true)

Deploying to master from @ junegunn/fzf@2671259fdb3094a5eac528f291c1fdadbcf9eda9 🚀junegunnbefore adoptiond75bb5c

lines 17–25why, one step back
17
18 reader.startEventPoller()1920 // Check EventBox21 if eb.Peek(EvtReadNew) {22 t.Error("EvtReadNew should not be set yet")23 }2425 // Normal command

Fix unit testsJunegunn Choibefore adoptionca747a2

line 26why, one step back
26 reader.fin(reader.readFromCommand(`echo abc&&echo def`, nil))

Deploying to master from @ junegunn/fzf@2671259fdb3094a5eac528f291c1fdadbcf9eda9 🚀junegunnbefore adoptiond75bb5c

lines 27–50why, one step back
27 if len(strs) != 2 || strs[0] != "abc" || strs[1] != "def" {
28 t.Errorf("%s", strs)29 }3031 // Check EventBox again32 eb.WaitFor(EvtReadFin)3334 // Wait should return immediately35 eb.Wait(func(events *util.Events) {36 events.Clear()37 })3839 // EventBox is cleared40 if eb.Peek(EvtReadNew) {41 t.Error("EvtReadNew should not be set yet")42 }4344 // Make sure that event poller is finished45 time.Sleep(readerPollIntervalMax)4647 // Restart event poller48 reader.startEventPoller()4950 // Failing command

Fix unit testsJunegunn Choibefore adoptionca747a2

line 51why, one step back
51 reader.fin(reader.readFromCommand(`no-such-command`, nil))

Deploying to master from @ junegunn/fzf@2671259fdb3094a5eac528f291c1fdadbcf9eda9 🚀junegunnbefore adoptiond75bb5c

lines 52–64why, one step back
52 strs = []string{}
53 if len(strs) > 0 {54 t.Errorf("%s", strs)55 }5657 // Check EventBox again58 if eb.Peek(EvtReadNew) {59 t.Error("Command failed. EvtReadNew should not be set")60 }61 if !eb.Peek(EvtReadFin) {62 t.Error("EvtReadFin should be set")63 }64}