Skip to content
Permalink
Browse files

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
  • Loading branch information
mik-dass committed Feb 19, 2020
1 parent 69cc05b commit 265c965cf74f48a4c26b9878cedc83ec8e863d9c
Showing with 8 additions and 2 deletions.
  1. +1 −1 .travis.yml
  2. +3 −0 Makefile
  3. +4 −1 cmd/odo/odo.go
@@ -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"
@@ -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"
@@ -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)
}

0 comments on commit 265c965

Please sign in to comment.
You can’t perform that action at this time.