File: deterministic-test-files.patch

package info (click to toggle)
golang-github-kr-binarydist 0.0~git20120828.0.9955b0a-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 156 kB
  • ctags: 61
  • sloc: makefile: 13
file content (57 lines) | stat: -rw-r--r-- 1,672 bytes parent folder | download
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Description: Deterministic test files
 Make the files written during tests deterministic to make this package build
 reproducible.
Author: Eduard Sanou <dhole@openmailbox.org>
Forwarded: no

--- golang-github-kr-binarydist-0.0~git20120828.0.9955b0a.orig/common_test.go
+++ golang-github-kr-binarydist-0.0~git20120828.0.9955b0a/common_test.go
@@ -1,10 +1,10 @@
 package binarydist
 
 import (
-	"crypto/rand"
 	"io"
 	"io/ioutil"
+	"math/rand"
 	"os"
 )
 
 func mustOpen(path string) *os.File {
@@ -67,8 +67,9 @@ func fileCmp(a, b *os.File) int64 {
 	return -1
 }
 
-func mustWriteRandFile(path string, size int) *os.File {
+func mustWriteRandFile(path string, size int, seed int64) *os.File {
 	p := make([]byte, size)
+	rand.Seed(seed)
 	_, err := rand.Read(p)
 	if err != nil {
 		panic(err)
--- golang-github-kr-binarydist-0.0~git20120828.0.9955b0a.orig/diff_test.go
+++ golang-github-kr-binarydist-0.0~git20120828.0.9955b0a/diff_test.go
@@ -13,8 +13,8 @@ var diffT = []struct {
 	new *os.File
 }{
 	{
-		old: mustWriteRandFile("test.old", 1e3),
-		new: mustWriteRandFile("test.new", 1e3),
+		old: mustWriteRandFile("test.old", 1e3, 1),
+		new: mustWriteRandFile("test.new", 1e3, 2),
 	},
 	{
 		old: mustOpen("testdata/sample.old"),
--- golang-github-kr-binarydist-0.0~git20120828.0.9955b0a.orig/patch_test.go
+++ golang-github-kr-binarydist-0.0~git20120828.0.9955b0a/patch_test.go
@@ -8,8 +8,8 @@ import (
 )
 
 func TestPatch(t *testing.T) {
-	mustWriteRandFile("test.old", 1e3)
-	mustWriteRandFile("test.new", 1e3)
+	mustWriteRandFile("test.old", 1e3, 1)
+	mustWriteRandFile("test.new", 1e3, 2)
 
 	got, err := ioutil.TempFile("/tmp", "bspatch.")
 	if err != nil {