From e9b1b908ee7c5b0722f6bce51aef4519990fae0b Mon Sep 17 00:00:00 2001
From: Ethan Koenig <ethantkoenig@gmail.com>
Date: Fri, 9 Jun 2017 14:13:46 -0400
Subject: [PATCH 1/2] Fix setting.AppPath for integration tests

---
 integrations/integration_test.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index 88b4614b7..a0271ce6b 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -14,6 +14,7 @@ import (
 	"net/http/cookiejar"
 	"net/url"
 	"os"
+	"path"
 	"strings"
 	"testing"
 
@@ -63,9 +64,11 @@ func initIntegrationTest() {
 		fmt.Println("Environment variable $GITEA_CONF not set")
 		os.Exit(1)
 	}
-	if os.Getenv("GITEA_ROOT") == "" {
+	if giteaRoot := os.Getenv("GITEA_ROOT"); giteaRoot == "" {
 		fmt.Println("Environment variable $GITEA_ROOT not set")
 		os.Exit(1)
+	} else {
+		setting.AppPath = path.Join(giteaRoot, "gitea")
 	}
 
 	setting.NewContext()

From 23d0735f906498ca273b7cac399e9c8f0a0f08e8 Mon Sep 17 00:00:00 2001
From: Ethan Koenig <ethantkoenig@gmail.com>
Date: Fri, 9 Jun 2017 22:27:13 -0400
Subject: [PATCH 2/2] Absolute path for setting.CustomConf

---
 integrations/integration_test.go | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/integrations/integration_test.go b/integrations/integration_test.go
index a0271ce6b..77a5a2b72 100644
--- a/integrations/integration_test.go
+++ b/integrations/integration_test.go
@@ -60,15 +60,21 @@ func TestMain(m *testing.M) {
 }
 
 func initIntegrationTest() {
-	if setting.CustomConf = os.Getenv("GITEA_CONF"); setting.CustomConf == "" {
-		fmt.Println("Environment variable $GITEA_CONF not set")
-		os.Exit(1)
-	}
-	if giteaRoot := os.Getenv("GITEA_ROOT"); giteaRoot == "" {
+	giteaRoot := os.Getenv("GITEA_ROOT")
+	if giteaRoot == "" {
 		fmt.Println("Environment variable $GITEA_ROOT not set")
 		os.Exit(1)
+	}
+	setting.AppPath = path.Join(giteaRoot, "gitea")
+
+	giteaConf := os.Getenv("GITEA_CONF")
+	if giteaConf == "" {
+		fmt.Println("Environment variable $GITEA_CONF not set")
+		os.Exit(1)
+	} else if !path.IsAbs(giteaConf) {
+		setting.CustomConf = path.Join(giteaRoot, giteaConf)
 	} else {
-		setting.AppPath = path.Join(giteaRoot, "gitea")
+		setting.CustomConf = giteaConf
 	}
 
 	setting.NewContext()