mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
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:
@@ -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"
|
||||
|
||||
3
Makefile
3
Makefile
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user