Skip to content

Commit

Permalink
moar debug
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Jun 8, 2020
1 parent 6b21f2d commit 445ec56
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/e2e/plugins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"syscall"
"testing"
Expand Down Expand Up @@ -99,8 +100,10 @@ func TestPluginWithoutLookup(t *testing.T) {
knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=false"}

t.Log("list plugin in --plugins-dir")
syscall.Exec("ls", []string{ "-l", pc.knPluginPath}, []string{})
syscall.Exec("ls", []string{ "-l", pc.knPluginPath2}, []string{})
t.Log("ls pluginPath:\n" + execute("ls", "-l", pc.knPluginPath))
t.Log("ls pluginPath2:\n" + execute("ls", "-l", pc.knPluginPath2))
syscall.Exec("ls", []string{"-l", pc.knPluginPath}, []string{})
syscall.Exec("ls", []string{"-l", pc.knPluginPath2}, []string{})
listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{})

t.Log("execute plugin in --plugins-dir")
Expand All @@ -110,6 +113,19 @@ func TestPluginWithoutLookup(t *testing.T) {
listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{pc.knPluginPath2})
}

func execute(command string, args ...string) string {
cmd := exec.Command(command, args...)
r, w, _ := os.Pipe()
cmd.Stdout = w
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Env = os.Environ()
cmd.Run()
w.Close()
ret, _ := ioutil.ReadAll(r)
return string(ret)
}

func TestPluginWithLookup(t *testing.T) {
it, err := test.NewKnTest()
assert.NilError(t, err)
Expand All @@ -123,6 +139,8 @@ func TestPluginWithLookup(t *testing.T) {

knFlags := []string{fmt.Sprintf("--plugins-dir=%s", pc.knPluginsDir), "--lookup-plugins=true"}

t.Log("ls pluginPath:\n" + execute("ls", "-l", pc.knPluginPath))
t.Log("ls pluginPath2:\n" + execute("ls", "-l", pc.knPluginPath2))
t.Log("list plugin in --plugins-dir")
listPlugin(r, knFlags, []string{pc.knPluginPath}, []string{pc.knPluginPath2})

Expand Down

0 comments on commit 445ec56

Please sign in to comment.