You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2020/06/24 18:12:17 UTC

[lucenenet] 23/26: Lucene.Net.TestFramework: Removed SeedAttribute

This is an automated email from the ASF dual-hosted git repository.

nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git

commit d45d363c329d8df05958cffe733b8283ec29e986
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Wed Jun 24 20:24:51 2020 +0700

    Lucene.Net.TestFramework: Removed SeedAttribute
---
 .../Support/TestFramework/SeedAttribute.cs         | 54 ----------------------
 src/Lucene.Net.Tests/Util/Fst/TestBytesStore.cs    |  1 -
 src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs          |  1 -
 src/Lucene.Net.Tests/Util/Packed/TestPackedInts.cs |  1 -
 src/Lucene.Net.Tests/Util/TestIdentityHashSet.cs   |  1 -
 src/Lucene.Net.Tests/Util/TestNumericUtils.cs      |  1 -
 src/Lucene.Net.Tests/Util/TestPagedBytes.cs        |  1 -
 src/Lucene.Net.Tests/Util/TestWAH8DocIdSet.cs      |  2 -
 8 files changed, 62 deletions(-)

diff --git a/src/Lucene.Net.TestFramework/Support/TestFramework/SeedAttribute.cs b/src/Lucene.Net.TestFramework/Support/TestFramework/SeedAttribute.cs
deleted file mode 100644
index 5cdea8a..0000000
--- a/src/Lucene.Net.TestFramework/Support/TestFramework/SeedAttribute.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using System.Reflection;
-using NUnit.Framework.Interfaces;
-using NUnit.Framework.Internal;
-using NUnit.Framework.Internal.Commands;
-
-[AttributeUsage(AttributeTargets.Method)]
-public sealed class SeedAttribute : Attribute, IWrapSetUpTearDown
-{
-    public SeedAttribute(int randomSeed)
-    {
-        RandomSeed = randomSeed;
-    }
-
-    public int RandomSeed { get; }
-
-    public TestCommand Wrap(TestCommand command)
-    {
-        return new SeedCommand(command, RandomSeed);
-    }
-
-    private sealed class SeedCommand : DelegatingTestCommand
-    {
-        private readonly int randomSeed;
-
-        public SeedCommand(TestCommand innerCommand, int randomSeed) : base(innerCommand)
-        {
-            this.randomSeed = randomSeed;
-        }
-
-        public override TestResult Execute(TestExecutionContext context)
-        {
-            ResetRandomSeed(context, randomSeed);
-            try
-            {
-                return innerCommand.Execute(context);
-            }
-            finally
-            {
-                if (context.CurrentTest.Seed != randomSeed)
-                    throw new InvalidOperationException($"{nameof(SeedAttribute)} cannot be used together with an attribute or test that changes the seed.");
-            }
-        }
-    }
-
-    private static void ResetRandomSeed(TestExecutionContext context, int seed)
-    {
-        context.CurrentTest.Seed = seed;
-
-        typeof(TestExecutionContext)
-            .GetField("_randomGenerator", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)
-            .SetValue(context, null);
-    }
-}
\ No newline at end of file
diff --git a/src/Lucene.Net.Tests/Util/Fst/TestBytesStore.cs b/src/Lucene.Net.Tests/Util/Fst/TestBytesStore.cs
index 3c54f7c..7b07911 100644
--- a/src/Lucene.Net.Tests/Util/Fst/TestBytesStore.cs
+++ b/src/Lucene.Net.Tests/Util/Fst/TestBytesStore.cs
@@ -35,7 +35,6 @@ namespace Lucene.Net.Util.Fst
     {
 
         [Test, LongRunningTest]
-        [Seed(1249648971)]
         public virtual void TestRandom()
         {
 
diff --git a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
index 2868051..c7bc993 100644
--- a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
+++ b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
@@ -273,7 +273,6 @@ namespace Lucene.Net.Util.Fst
 
 
         [Test, LongRunningTest] // Can take up to 15 minutes
-        [Seed(1249648971)]
         public virtual void TestRandomWords()
         {
             // LUCENENET specific: NUnit will crash with an OOM if we do the full test
diff --git a/src/Lucene.Net.Tests/Util/Packed/TestPackedInts.cs b/src/Lucene.Net.Tests/Util/Packed/TestPackedInts.cs
index 5975a0b..d0de157 100644
--- a/src/Lucene.Net.Tests/Util/Packed/TestPackedInts.cs
+++ b/src/Lucene.Net.Tests/Util/Packed/TestPackedInts.cs
@@ -1128,7 +1128,6 @@ namespace Lucene.Net.Util.Packed
 
 
         [Test, LongRunningTest]
-        [Seed(1249648971)]
         public virtual void TestAppendingLongBuffer()
         {
 
diff --git a/src/Lucene.Net.Tests/Util/TestIdentityHashSet.cs b/src/Lucene.Net.Tests/Util/TestIdentityHashSet.cs
index 6bccb73..b27c6f2 100644
--- a/src/Lucene.Net.Tests/Util/TestIdentityHashSet.cs
+++ b/src/Lucene.Net.Tests/Util/TestIdentityHashSet.cs
@@ -29,7 +29,6 @@ namespace Lucene.Net.Util
     {
 
         [Test]
-        [Seed(1249648971)]
         public virtual void TestCheck()
         {
             Random rnd = Random;
diff --git a/src/Lucene.Net.Tests/Util/TestNumericUtils.cs b/src/Lucene.Net.Tests/Util/TestNumericUtils.cs
index 0995959..7f83222 100644
--- a/src/Lucene.Net.Tests/Util/TestNumericUtils.cs
+++ b/src/Lucene.Net.Tests/Util/TestNumericUtils.cs
@@ -360,7 +360,6 @@ namespace Lucene.Net.Util
             AssertLongRangeSplit(long.MinValue, long.MinValue + 0x10L, 4, true, new long[] { 0x0000000000000010L, 0x0000000000000010L, 0x000000000000000L, 0x000000000000000L }, new int[] { 0, 4 });
         }
         [Test, LongRunningTest]
-        [Seed(1249648971)]
         public virtual void TestRandomSplit()
         {
             long num = (long)AtLeast(10);
diff --git a/src/Lucene.Net.Tests/Util/TestPagedBytes.cs b/src/Lucene.Net.Tests/Util/TestPagedBytes.cs
index 1c6e307..e6f5fbe 100644
--- a/src/Lucene.Net.Tests/Util/TestPagedBytes.cs
+++ b/src/Lucene.Net.Tests/Util/TestPagedBytes.cs
@@ -42,7 +42,6 @@ namespace Lucene.Net.Util
         // copies into PagedBytes and verifies with
         // PagedBytes.Reader:
         [Test, LongRunningTest]
-        [Seed(1249648971)]
         public virtual void TestDataInputOutput()
         {
             Random random = Random;
diff --git a/src/Lucene.Net.Tests/Util/TestWAH8DocIdSet.cs b/src/Lucene.Net.Tests/Util/TestWAH8DocIdSet.cs
index 24f036e..fccef80 100644
--- a/src/Lucene.Net.Tests/Util/TestWAH8DocIdSet.cs
+++ b/src/Lucene.Net.Tests/Util/TestWAH8DocIdSet.cs
@@ -44,7 +44,6 @@ namespace Lucene.Net.Util
         }
 
         [Test]
-        [Seed(1249648971)]
         public virtual void TestUnion()
         {
             int numBits = TestUtil.NextInt32(Random, 100, 1 << 20);
@@ -73,7 +72,6 @@ namespace Lucene.Net.Util
         }
 
         [Test]
-        [Seed(1249648971)]
         public virtual void TestIntersection()
         {
             int numBits = TestUtil.NextInt32(Random, 100, 1 << 20);