warn if you fix a random seed (so we dont leave the test de-randomized)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@967080 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2010-07-23 12:47:25 +00:00
parent cec16f399a
commit 2fe80c49e6
2 changed files with 10 additions and 3 deletions

View File

@ -247,7 +247,8 @@ public abstract class LuceneTestCase extends TestCase {
if (seed != null) {
throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test");
}
return newRandom(seedRnd.nextLong());
this.seed = Long.valueOf(seedRnd.nextLong());
return new Random(seed);
}
/**
@ -259,6 +260,7 @@ public abstract class LuceneTestCase extends TestCase {
if (this.seed != null) {
throw new IllegalStateException("please call LuceneTestCase.newRandom only once per test");
}
System.out.println("WARNING: random seed of testcase '" + getName() + "' is fixed to: " + seed);
this.seed = Long.valueOf(seed);
return new Random(seed);
}

View File

@ -323,7 +323,8 @@ public class LuceneTestCaseJ4 {
if (seed != null) {
throw new IllegalStateException("please call LuceneTestCaseJ4.newRandom only once per test");
}
return newRandom(seedRnd.nextLong());
this.seed = Long.valueOf(seedRnd.nextLong());
return new Random(seed);
}
/**
@ -335,6 +336,7 @@ public class LuceneTestCaseJ4 {
if (this.seed != null) {
throw new IllegalStateException("please call LuceneTestCaseJ4.newRandom only once per test");
}
System.out.println("WARNING: random seed of testcase '" + getName() + "' is fixed to: " + seed);
this.seed = Long.valueOf(seed);
return new Random(seed);
}
@ -350,7 +352,9 @@ public class LuceneTestCaseJ4 {
* .
*/
public static Random newStaticRandom(Class<? extends LuceneTestCaseJ4> clazz) {
return newStaticRandom(clazz, seedRnd.nextLong());
Long seed = seedRnd.nextLong();
staticSeeds.put(clazz, seed);
return new Random(seed);
}
/**
@ -361,6 +365,7 @@ public class LuceneTestCaseJ4 {
*/
public static Random newStaticRandom(Class<? extends LuceneTestCaseJ4> clazz, long seed) {
staticSeeds.put(clazz, Long.valueOf(seed));
System.out.println("WARNING: random static seed of testclass '" + clazz + "' is fixed to: " + seed);
return new Random(seed);
}