From a7a317c2843efe3547ce85780b4646a3c1d7c839 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 6 Jan 2015 23:03:35 +0100 Subject: [PATCH] The predictableRandom test can only run once successfully (fixes #1184) --- cmd/syncthing/random_test.go | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/syncthing/random_test.go b/cmd/syncthing/random_test.go index 5cff1ed8c..71b9ab3a5 100644 --- a/cmd/syncthing/random_test.go +++ b/cmd/syncthing/random_test.go @@ -15,14 +15,21 @@ package main -import "testing" +import ( + "sync" + "testing" +) + +var predictableRandomTest sync.Once func TestPredictableRandom(t *testing.T) { - // predictable random sequence is predictable - e := 3440579354231278675 - if v := predictableRandom.Int(); v != e { - t.Errorf("Unexpected random value %d != %d", v, e) - } + predictableRandomTest.Do(func() { + // predictable random sequence is predictable + e := 3440579354231278675 + if v := predictableRandom.Int(); v != e { + t.Errorf("Unexpected random value %d != %d", v, e) + } + }) } func TestSeedFromBytes(t *testing.T) {