From b41dcf3257c67d65c0c1a2083bd2a6ab517c3929 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 22 Feb 2023 12:44:50 -0800 Subject: [PATCH 1/2] test: Skip tests if required plugins are missing --- internal/endtoend/endtoend_test.go | 9 +++++++++ .../testdata/process_plugin_sqlc_gen_json/exec.json | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 internal/endtoend/testdata/process_plugin_sqlc_gen_json/exec.json diff --git a/internal/endtoend/endtoend_test.go b/internal/endtoend/endtoend_test.go index c31d2beb5e..a1d61df80f 100644 --- a/internal/endtoend/endtoend_test.go +++ b/internal/endtoend/endtoend_test.go @@ -5,6 +5,7 @@ import ( "context" "encoding/json" "os" + osexec "os/exec" "path/filepath" "strings" "testing" @@ -102,6 +103,13 @@ func TestReplay(t *testing.T) { args := parseExec(t, path) expected := expectedStderr(t, path) + if args.Process != "" { + _, err := osexec.LookPath(args.Process) + if err != nil { + t.Skipf("executable not found: %s %s", args.Process, err) + } + } + switch args.Command { case "diff": err = cmd.Diff(ctx, cmd.Env{ExperimentalFeatures: true}, path, "", &stderr) @@ -199,6 +207,7 @@ func expectedStderr(t *testing.T, dir string) string { type exec struct { Command string `json:"command"` + Process string `json:"process"` } func parseExec(t *testing.T, dir string) exec { diff --git a/internal/endtoend/testdata/process_plugin_sqlc_gen_json/exec.json b/internal/endtoend/testdata/process_plugin_sqlc_gen_json/exec.json new file mode 100644 index 0000000000..5be7ac8c74 --- /dev/null +++ b/internal/endtoend/testdata/process_plugin_sqlc_gen_json/exec.json @@ -0,0 +1,3 @@ +{ + "process": "sqlc-gen-json" +} From 22b94d3cdc330af39b4de3d86cfaa1df8efdbcc1 Mon Sep 17 00:00:00 2001 From: Kyle Conroy Date: Wed, 22 Feb 2023 12:52:42 -0800 Subject: [PATCH 2/2] Fix failing test --- internal/endtoend/endtoend_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/endtoend/endtoend_test.go b/internal/endtoend/endtoend_test.go index a1d61df80f..beca8d6023 100644 --- a/internal/endtoend/endtoend_test.go +++ b/internal/endtoend/endtoend_test.go @@ -152,6 +152,9 @@ func cmpDirectory(t *testing.T, dir string, actual map[string]string) { if filepath.Base(path) == "sqlc.json" { return nil } + if filepath.Base(path) == "exec.json" { + return nil + } if strings.Contains(path, "/kotlin/build") { return nil }