File: 0003-avoid-failures-on-flaky-test.patch

package info (click to toggle)
golang-github-gin-gonic-gin 1.8.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,276 kB
  • sloc: makefile: 75
file content (30 lines) | stat: -rw-r--r-- 998 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: Cyril Brulebois <cyril@debamax.com>
Date: Sun, 10 Jan 2021 06:12:46 +0000
Subject: Avoid failures on flaky test

The TestPathCleanMallocs test fails sometimes (and could also be an
incentive for using -short), but Shengjing Zhu agrees we shouldn't
abort when that happens.

Replace the assert with a warning message if the results don't match
expectations, so that we still have access to this information if we
need it.

Suggested-by: Shengjing Zhu <zhsj@debian.org>
Signed-off-by: Cyril Brulebois <cyril@debamax.com>
diff --git a/path_test.go b/path_test.go
index caefd63..107b7a7 100644
--- a/path_test.go
+++ b/path_test.go
@@ -82,7 +82,10 @@ func TestPathCleanMallocs(t *testing.T) {
 
 	for _, test := range cleanTests {
 		allocs := testing.AllocsPerRun(100, func() { cleanPath(test.result) })
-		assert.EqualValues(t, allocs, 0)
+		// Test seems flaky, display a warning instead of erroring out via assert
+		if allocs != 0 {
+			t.Logf("got allocs %f, want 0", allocs)
+		}
 	}
 }