summaryrefslogtreecommitdiff
path: root/tests.go
diff options
context:
space:
mode:
authorEyal Posener <[email protected]>2017-05-06 23:06:58 +0300
committerEyal Posener <[email protected]>2017-05-06 23:07:26 +0300
commitf740f61fbbe06da0381d899376cbf99853630b88 (patch)
tree97ab8ccef7ae63f9edcf295854fb72d1cd5a25f6 /tests.go
parent8d6ebaa18327f3cb65b38ab3d0ba6b4a8dc231ea (diff)
[test] chdir and set logger only once
Diffstat (limited to 'tests.go')
-rw-r--r--tests.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests.go b/tests.go
new file mode 100644
index 0000000..38fe5f1
--- /dev/null
+++ b/tests.go
@@ -0,0 +1,26 @@
+package complete
+
+import (
+ "os"
+ "sync"
+ "testing"
+)
+
+var once = sync.Once{}
+
+func initTests() {
+ once.Do(func() {
+ // Set debug environment variable so logs will be printed
+ if testing.Verbose() {
+ os.Setenv(envDebug, "1")
+ // refresh the logger with environment variable set
+ Log = getLogger()
+ }
+
+ // Change to tests directory for testing completion of files and directories
+ err := os.Chdir("./tests")
+ if err != nil {
+ panic(err)
+ }
+ })
+}