Skip to content

Commit 518f90f

Browse files
authored
fix: go regression test fix (#699)
* Go version 1.25 doesn't include unsafe.go anymore, but our go regression tests were checking for it. Since the CICD runs a script to build the latest version of go before the tests, it was pulling and building v1.25, and failing. So I updated the test to check if it's 1.25 and alter the expected packages as a result. This should have no impact on the actual functionality
1 parent 0b2ae32 commit 518f90f

1 file changed

Lines changed: 35 additions & 22 deletions

File tree

test/unit/go-binaries.spec.ts

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,41 @@ function stdlib(
225225
return lib;
226226
}
227227

228-
// We test with three different versions, 1.13, 1.16 and 1.18, because the
229-
// PCLN Tab has different formats for 1.2 - 1.15, 1.16-1.17 and 1.18-<current>.
230-
// We're using 1.13 instead of 1.2 because 1.2 is really old and 1.13 is the
231-
// minimum requirement for most modules (this is when module-support landed).
228+
function redisModule(goVersion: GoVersion): Module {
229+
// Go 1.25 doesn't include internal/unsafe.go in the PCLN table
230+
const baseFiles = ["log.go", "util.go"];
231+
const internalFiles =
232+
goVersion === GoVersion.Go125 ? baseFiles : ["unsafe.go", ...baseFiles];
233+
234+
const packages = new Map([
235+
["", ["error.go", "cluster.go", "options.go"]],
236+
["internal", internalFiles],
237+
["internal/hscan", ["hscan.go"]],
238+
["internal/pool", ["pool.go", "conn.go"]],
239+
["internal/proto", ["writer.go", "reader.go"]],
240+
["internal/rand", ["rand.go"]],
241+
["internal/util", ["strconv.go"]],
242+
]);
243+
244+
return {
245+
name: "github.com/go-redis/redis/v9",
246+
version: "v9.0.0-beta.2",
247+
type: moduleType.External,
248+
packages,
249+
};
250+
}
251+
252+
// We test with multiple Go versions because the PCLN Tab has different formats:
253+
// - 1.2 - 1.15 (we use 1.13)
254+
// - 1.16 - 1.17 (we use 1.16)
255+
// - 1.18 - 1.24 (we use 1.18 and 1.20)
256+
// - 1.25+ (different file inclusion behavior)
232257
enum GoVersion {
233258
Go113,
234259
Go116,
235260
Go118,
236261
Go120,
262+
Go125,
237263
}
238264

239265
function extractGoVersion(fileName: string): GoVersion {
@@ -248,11 +274,13 @@ function extractGoVersion(fileName: string): GoVersion {
248274
return GoVersion.Go118;
249275
case "go1.20":
250276
return GoVersion.Go120;
277+
case "go1.25":
278+
return GoVersion.Go125;
251279
default:
252-
// if the test fails because we're using GoVersion.Go120 here, it means
280+
// if the test fails because we're using GoVersion.Go125 here, it means
253281
// that the binary format has changed and we need to introduce a new
254282
// version + check how to handle that.
255-
return GoVersion.Go120;
283+
return GoVersion.Go125;
256284
}
257285
}
258286

@@ -278,22 +306,7 @@ describe("test from binaries", () => {
278306
const testCase = new TestCase([
279307
stdlib(goVersion, isCGo, isTrimmed),
280308
main(goVersion),
281-
{
282-
name: "github.com/go-redis/redis/v9",
283-
version: "v9.0.0-beta.2",
284-
type: moduleType.External,
285-
packages: new Map([
286-
// exhaustive package list, but non-exhaustive file list in each
287-
// package.
288-
["", ["error.go", "cluster.go", "options.go"]],
289-
["internal", ["unsafe.go", "log.go", "util.go"]],
290-
["internal/hscan", ["hscan.go"]],
291-
["internal/pool", ["pool.go", "conn.go"]],
292-
["internal/proto", ["writer.go", "reader.go"]],
293-
["internal/rand", ["rand.go"]],
294-
["internal/util", ["strconv.go"]],
295-
]),
296-
},
309+
redisModule(goVersion),
297310
{
298311
name: "github.com/ghodss/yaml",
299312
version: "v1.0.0",

0 commit comments

Comments
 (0)