diff options
author | Sören Tempel <soeren+git@soeren-tempel.net> | 2020-05-10 23:46:26 +0200 |
---|---|---|
committer | Sören Tempel <soeren+git@soeren-tempel.net> | 2020-05-11 16:14:25 +0200 |
commit | 04c5f3dae84c8df515cc1996e12263db0b6011d3 (patch) | |
tree | 5848d5fe70b4eace91d1d41eba5cb029401492d2 /community/gitea/0001-Slight-performance-changes-to-integrations-git_test..patch | |
parent | 7c5757768dc4f8c7b37e51db17d8685495cc2fc2 (diff) | |
download | aports-04c5f3dae84c8df515cc1996e12263db0b6011d3.tar.bz2 aports-04c5f3dae84c8df515cc1996e12263db0b6011d3.tar.xz |
community/gitea: attempt to fix check() on armhf
Diffstat (limited to 'community/gitea/0001-Slight-performance-changes-to-integrations-git_test..patch')
-rw-r--r-- | community/gitea/0001-Slight-performance-changes-to-integrations-git_test..patch | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/community/gitea/0001-Slight-performance-changes-to-integrations-git_test..patch b/community/gitea/0001-Slight-performance-changes-to-integrations-git_test..patch new file mode 100644 index 0000000000..fb2ba228c2 --- /dev/null +++ b/community/gitea/0001-Slight-performance-changes-to-integrations-git_test..patch @@ -0,0 +1,132 @@ +From d26aee38307b84d6e3001fd7e531a0d67a804267 Mon Sep 17 00:00:00 2001 +From: zeripath <art27@cantab.net> +Date: Mon, 27 Apr 2020 12:20:09 +0100 +Subject: [PATCH] Slight performance changes to integrations/git_test.go + (#11227) + +* switch to use pseudorandom generator and stop cloning in pushcreate + +Signed-off-by: Andrew Thornton <art27@cantab.net> + +* Add some logging of BranchProtectPRMerge + +Signed-off-by: Andrew Thornton <art27@cantab.net> + +* Stop running prepareTestEnv so often for TestAPIGetBranch + +Signed-off-by: Andrew Thornton <art27@cantab.net> +--- + integrations/api_branch_test.go | 3 +-- + integrations/git_test.go | 35 ++++++++++++++++++++++++--------- + 2 files changed, 27 insertions(+), 11 deletions(-) + +diff --git a/integrations/api_branch_test.go b/integrations/api_branch_test.go +index 8417ab36c..acf7525f8 100644 +--- a/integrations/api_branch_test.go ++++ b/integrations/api_branch_test.go +@@ -14,8 +14,6 @@ import ( + ) + + func testAPIGetBranch(t *testing.T, branchName string, exists bool) { +- defer prepareTestEnv(t)() +- + session := loginUser(t, "user2") + token := getTokenForLoggedInUser(t, session) + req := NewRequestf(t, "GET", "/api/v1/repos/user2/repo1/branches/%s?token=%s", branchName, token) +@@ -88,6 +86,7 @@ func testAPIDeleteBranch(t *testing.T, branchName string, expectedHTTPStatus int + } + + func TestAPIGetBranch(t *testing.T) { ++ defer prepareTestEnv(t)() + for _, test := range []struct { + BranchName string + Exists bool +diff --git a/integrations/git_test.go b/integrations/git_test.go +index 8813f34be..69253d397 100644 +--- a/integrations/git_test.go ++++ b/integrations/git_test.go +@@ -5,9 +5,9 @@ + package integrations + + import ( +- "crypto/rand" + "fmt" + "io/ioutil" ++ "math/rand" + "net/http" + "net/url" + "os" +@@ -70,6 +70,7 @@ func testGit(t *testing.T, u *url.URL) { + + t.Run("BranchProtectMerge", doBranchProtectPRMerge(&httpContext, dstPath)) + t.Run("MergeFork", func(t *testing.T) { ++ defer PrintCurrentTest(t)() + t.Run("CreatePRAndMerge", doMergeFork(httpContext, forkedUserCtx, "master", httpContext.Username+":master")) + rawTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) + mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) +@@ -109,6 +110,7 @@ func testGit(t *testing.T, u *url.URL) { + + t.Run("BranchProtectMerge", doBranchProtectPRMerge(&sshContext, dstPath)) + t.Run("MergeFork", func(t *testing.T) { ++ defer PrintCurrentTest(t)() + t.Run("CreatePRAndMerge", doMergeFork(sshContext, forkedUserCtx, "master", sshContext.Username+":master")) + rawTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) + mediaTest(t, &forkedUserCtx, little, big, littleLFS, bigLFS) +@@ -291,17 +293,34 @@ func doCommitAndPush(t *testing.T, size int, repoPath, prefix string) string { + + func generateCommitWithNewData(size int, repoPath, email, fullName, prefix string) (string, error) { + //Generate random file +- data := make([]byte, size) +- _, err := rand.Read(data) +- if err != nil { +- return "", err ++ bufSize := 4 * 1024 ++ if bufSize > size { ++ bufSize = size + } ++ ++ buffer := make([]byte, bufSize) ++ + tmpFile, err := ioutil.TempFile(repoPath, prefix) + if err != nil { + return "", err + } + defer tmpFile.Close() +- _, err = tmpFile.Write(data) ++ written := 0 ++ for written < size { ++ n := size - written ++ if n > bufSize { ++ n = bufSize ++ } ++ _, err := rand.Read(buffer[:n]) ++ if err != nil { ++ return "", err ++ } ++ n, err = tmpFile.Write(buffer[:n]) ++ if err != nil { ++ return "", err ++ } ++ written += n ++ } + if err != nil { + return "", err + } +@@ -411,6 +430,7 @@ func doProtectBranch(ctx APITestContext, branch string, userToWhitelist string) + + func doMergeFork(ctx, baseCtx APITestContext, baseBranch, headBranch string) func(t *testing.T) { + return func(t *testing.T) { ++ defer PrintCurrentTest(t)() + var pr api.PullRequest + var err error + t.Run("CreatePullRequest", func(t *testing.T) { +@@ -485,9 +505,6 @@ func doPushCreate(ctx APITestContext, u *url.URL) func(t *testing.T) { + tmpDir, err := ioutil.TempDir("", ctx.Reponame) + assert.NoError(t, err) + +- _, err = git.NewCommand("clone", u.String()).RunInDir(tmpDir) +- assert.Error(t, err) +- + err = git.InitRepository(tmpDir, false) + assert.NoError(t, err) + |