diff --git a/modules/setting/testenv.go b/modules/setting/testenv.go index c81b51fd71d..681e7fddf90 100644 --- a/modules/setting/testenv.go +++ b/modules/setting/testenv.go @@ -12,6 +12,7 @@ import ( "code.gitea.io/gitea/modules/auth/password/hash" "code.gitea.io/gitea/modules/log" + "code.gitea.io/gitea/modules/util" ) var giteaTestSourceRoot *string @@ -50,7 +51,11 @@ func SetupGiteaTestEnv() { } initGiteaPaths := func() { - StaticRootPath = *giteaTestSourceRoot // need to load assets (options, public) from the source code directory for testing + // need to load assets (options, public) from the source code directory for testing + StaticRootPath = *giteaTestSourceRoot + // during testing, the AppPath must point to the pre-built Gitea binary in the source root + // it needs to be called by git hooks + AppPath = filepath.Join(*giteaTestSourceRoot, "gitea") + util.Iif(IsWindows, ".exe", "") } initGiteaConf := func() string { diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index d0a33fdec8c..60dc7e77a48 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -95,7 +95,7 @@ func testMain(m *testing.M) int { err = unittest.InitFixtures( unittest.FixturesOptions{ - Dir: filepath.Join(filepath.Dir(setting.AppPath), "models/fixtures/"), + Dir: filepath.Join(setting.GetGiteaTestSourceRoot(), "models/fixtures/"), }, ) if err != nil { diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go index 1e1dc7bf142..c1acdb999b1 100644 --- a/tests/integration/migration-test/migration_test.go +++ b/tests/integration/migration-test/migration_test.go @@ -40,7 +40,7 @@ func initMigrationTest(t *testing.T) func() { setting.SetupGiteaTestEnv() assert.NotEmpty(t, setting.RepoRootPath) - assert.NoError(t, unittest.SyncDirs(filepath.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath)) + assert.NoError(t, unittest.SyncDirs(filepath.Join(setting.GetGiteaTestSourceRoot(), "tests/gitea-repositories-meta"), setting.RepoRootPath)) assert.NoError(t, git.InitFull()) setting.LoadDBSetting() setting.InitLoggersForTest() diff --git a/tests/test_utils.go b/tests/test_utils.go index 7ff7dd7b8ab..d5a8008cefb 100644 --- a/tests/test_utils.go +++ b/tests/test_utils.go @@ -156,7 +156,7 @@ func PrepareGitRepoDirectory(t testing.TB) { if !assert.NotEmpty(t, setting.RepoRootPath) { return } - assert.NoError(t, unittest.SyncDirs(filepath.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath)) + assert.NoError(t, unittest.SyncDirs(filepath.Join(setting.GetGiteaTestSourceRoot(), "tests/gitea-repositories-meta"), setting.RepoRootPath)) } func PrepareArtifactsStorage(t testing.TB) {