Exports ODO_LOG_LEVEL env variable in integration tests (#2595)

* Exports ODO_LOG_LEVEL env variable in integration tests

* Turns off ODO_LOG_LEVEL if a valid json flag is passed
This commit is contained in:
Mrinal Das
2020-02-19 07:50:49 +05:30
committed by GitHub
parent 69cc05baaf
commit 265c965cf7
3 changed files with 8 additions and 2 deletions

View File

@@ -32,7 +32,7 @@ jobs:
- &osx-test
stage: Test
name: "Unit test on OSX"
os:
os:
- osx
go_import_path: github.com/openshift/odo
go: "1.13.1"

View File

@@ -26,6 +26,9 @@ SLOW_SPEC_THRESHOLD := 120
# To enable verbosity export or set env GINKGO_TEST_ARGS like "GINKGO_TEST_ARGS=-v"
GINKGO_TEST_ARGS ?=
# ODO_LOG_LEVEL sets the verbose log level for the make tests
export ODO_LOG_LEVEL ?= 4
# Env variable UNIT_TEST_ARGS is used to get control over enabling test flags along with go test.
# For example:
# To enable verbosity export or set env GINKGO_TEST_ARGS like "GINKGO_TEST_ARGS=-v"

View File

@@ -3,6 +3,7 @@ package main
import (
"flag"
"os"
"strings"
"github.com/golang/glog"
"github.com/openshift/odo/pkg/log"
@@ -46,7 +47,9 @@ func main() {
// Override the logging level by the value (if set) by the ODO_LOG_LEVEL env
// The "-v" flag set on command line will take precedence over ODO_LOG_LEVEL env
v := flag.CommandLine.Lookup("v").Value.String()
if level, ok := os.LookupEnv("ODO_LOG_LEVEL"); ok && v == "0" {
// if the json flag is passed and is valid, we don't turn on ODO_LOG_LEVEL
jsonFlagValue := flag.CommandLine.Lookup("o").Value.String()
if level, ok := os.LookupEnv("ODO_LOG_LEVEL"); ok && v == "0" && strings.ToLower(jsonFlagValue) != "json" {
_ = flag.CommandLine.Set("v", level)
}