mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 06:42:16 +00:00
* libs/common: TrapSignal accepts logger as a first parameter and does not block anymore * previously it was dumping "captured ..." msg to os.Stdout * TrapSignal should not be responsible for blocking thread of execution Refs #3238 * exit with zero (0) code upon receiving SIGTERM/SIGINT Refs #3238 * fix formatting in docs/app-dev/abci-cli.md Co-Authored-By: melekes <anton.kalyaev@gmail.com> * fix formatting in docs/app-dev/abci-cli.md Co-Authored-By: melekes <anton.kalyaev@gmail.com>
47 lines
904 B
Go
47 lines
904 B
Go
package common
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestOSGoPath(t *testing.T) {
|
|
// restore original gopath upon exit
|
|
path := os.Getenv("GOPATH")
|
|
defer func() {
|
|
_ = os.Setenv("GOPATH", path)
|
|
}()
|
|
|
|
err := os.Setenv("GOPATH", "~/testgopath")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
path = GoPath()
|
|
if path != "~/testgopath" {
|
|
t.Fatalf("should get GOPATH env var value, got %v", path)
|
|
}
|
|
os.Unsetenv("GOPATH")
|
|
|
|
path = GoPath()
|
|
if path != "~/testgopath" {
|
|
t.Fatalf("subsequent calls should return the same value, got %v", path)
|
|
}
|
|
}
|
|
|
|
func TestOSGoPathWithoutEnvVar(t *testing.T) {
|
|
// restore original gopath upon exit
|
|
path := os.Getenv("GOPATH")
|
|
defer func() {
|
|
_ = os.Setenv("GOPATH", path)
|
|
}()
|
|
|
|
os.Unsetenv("GOPATH")
|
|
// reset cache
|
|
gopath = ""
|
|
|
|
path = GoPath()
|
|
if path == "" || path == "~/testgopath" {
|
|
t.Fatalf("should get nonempty result of calling go env GOPATH, got %v", path)
|
|
}
|
|
}
|