github.com/linux4life798/complete@v1.1.2-0.20180410072631-7426158f3bcb/common_test.go (about)

     1  package complete
     2  
     3  import (
     4  	"os"
     5  	"sync"
     6  	"testing"
     7  )
     8  
     9  var once = sync.Once{}
    10  
    11  func initTests() {
    12  	once.Do(func() {
    13  		// Set debug environment variable so logs will be printed
    14  		if testing.Verbose() {
    15  			os.Setenv(envDebug, "1")
    16  			// refresh the logger with environment variable set
    17  			Log = getLogger()
    18  		}
    19  
    20  		// Change to tests directory for testing completion of files and directories
    21  		err := os.Chdir("./tests")
    22  		if err != nil {
    23  			panic(err)
    24  		}
    25  	})
    26  }