From 273058c3baa5e2e9b1ab660383eff9668001a377 Mon Sep 17 00:00:00 2001 From: pancho horrillo Date: Wed, 9 Oct 2019 16:15:52 +0200 Subject: [PATCH 1/2] Add testutils/jaillover to assist testing process spawning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto Abdelkader Martínez Pérez --- testutils/jaillover/main.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 testutils/jaillover/main.go diff --git a/testutils/jaillover/main.go b/testutils/jaillover/main.go new file mode 100644 index 0000000..6810778 --- /dev/null +++ b/testutils/jaillover/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "encoding/json" + "fmt" + "log" + "os" + "strings" +) + +type Output struct { + Cmdline []string `json:"cmdline"` + Env map[string]string `json:"env"` +} + +func getEnvMap() map[string]string { + env := make(map[string]string) + for _, e := range os.Environ() { + s := strings.SplitN(e, "=", 2) + env[s[0]] = s[1] + } + return env +} + +func main() { + o := Output{ + Cmdline: os.Args, + Env: getEnvMap(), + } + res, err := json.Marshal(o) + if err != nil { + log.Fatalf("JSON marshal failed %+v", err) + } + fmt.Println(string(res)) +} From fa8cc271dc2e2e09494198bf8303d817e9c0c99f Mon Sep 17 00:00:00 2001 From: pancho horrillo Date: Wed, 9 Oct 2019 16:25:04 +0200 Subject: [PATCH 2/2] Build jaillover via Makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto Abdelkader Martínez Pérez --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 895e7a5..32baa1d 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: lint build test race coverage install acceptance deps +.PHONY: lint build test jaillover race coverage install acceptance deps GOCMD=go GOBUILD=$(GOCMD) build @@ -6,6 +6,7 @@ GOGET=$(GOCMD) get GOTEST=$(GOCMD) test GOTOOL=$(GOCMD) tool GOLANGLINT=golangci-lint +PROJECTREPO=github.com/BBVA/kapow BUILD_DIR=./build OUTPUT_DIR=./output @@ -22,9 +23,12 @@ build: deps mkdir -p $(BUILD_DIR) CGO_ENABLED=0 $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v -test: build +test: build jaillover $(GOTEST) -v -coverprofile=$(TMP_DIR)/c.out ./... +jaillover: + $(GOGET) $(PROJECTREPO)/testutils/$@ + race: build $(GOTEST) -race -v ./...