You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by conniey <gi...@git.apache.org> on 2016/08/04 18:46:17 UTC

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

GitHub user conniey opened a pull request:

    https://github.com/apache/lucenenet/pull/177

    Limiting uses of static variables and methods in Testcases

    This is an improvement from PR #172.  The difference is that all the existing constructors are maintained with some additions. 
    
    This PR would allow an easier transition to using xUnit. xUnit by default, runs its tests in parallel and asynchronously. The current use of mutable static fields limits in test cases the ability to utilise this.
    
    * Changing existing static variables to static readonly so we are explicit that these variables are set once and do not change.
    * Change OLD_FORMAT_IMPERSONATION_IS_ACTIVE to non-static field since other tests share and use this variable
    * Change ClassEnvRule to non-static since every test class generates its own rule during test
    * Change dependent static methods in LuceneTestCase to non-static because their state depended on the state of these non-static variables

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/conniey/lucenenet notRemovingCtors

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucenenet/pull/177.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #177
    
----
commit 93acfd936b64d602e3e59d56c9d4b53e2820214b
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-11T23:33:47Z

    Changing static variables to static readonly

commit 655fa1a02f325551936c7b0388963b05204d296a
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-12T12:26:26Z

    Changing OLD_FORMAT_IMPERSONATION_IS_ACTIVE to non-static property

commit ae41663fd508e45deac3682104f1c8dabf3d6973
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T19:17:21Z

    Changing ClassEnvRule to non-static

commit 4b52ddfdefed3c7cf91c6d9c7b5aad18014732dd
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-15T16:20:45Z

    Fixing test errors with teardown/setup

commit d7e15dc8adcf33f59133243f4b6022ebf6d8d46f
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-20T19:14:08Z

    Adding a static LuceneTestCase.NewIndexWriterConfig method

commit ab57fd17da92fdb5469c9495fb6654a9db1dff4c
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-20T19:14:19Z

    Modifying RandomIndexWriter ctors to take Similarity and Timezone

commit 6f3e8079447bd9ac4f38119b1bdaebfa7690214a
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T16:31:02Z

    Fixing build errors from adding extra params to RandomIndexWriter

commit 6614015b207044b13d3a46a77f17c5d89010aedf
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T19:29:50Z

    Making one LuceneTestCase.NewIndexWriterConfig non-static

commit 8be2a5433039c6daa114a1632ae2056bd8de148e
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T19:30:36Z

    Adding parameters to static NewSearcher

commit c499981985b086d31699bde5438ff0bc410d7e37
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T19:31:18Z

    Making LuceneTestCase.NewField/NewTextField non-static

commit ef7f1dd17feda9fbb1a2cc02d5f764268d7e7354
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T19:33:30Z

    Adding another overload for LuceneTestCase.NewSearcher

commit 9591b70d96a9ee08d23421e70c41c6363967b37a
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T22:06:31Z

    Fixing RandomIndexWriter build errors in BaseTokenStreamTestCase

commit 72840c6544d310155d7e1849283d9ec38bab79c3
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T22:07:12Z

    Fixing NewField build errors in ThreadingIndexingAndSearching

commit 9067582a3bf68430a789e641670e3a96fe688d95
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T22:07:46Z

    Fixing NewSearcher errors in QueryUtils

commit 659d95221eb57e05d47f1292efa47ef2266b6bf3
Author: Connie Yau <co...@microsoft.com>
Date:   2016-07-22T22:08:20Z

    Fixing RandomIndexWriter ctor error in SearchEquivalentTestBase

commit 95bd05b76fbde14a852e789dc4c445dc93cb7d6e
Author: Connie Yau <co...@microsoft.com>
Date:   2016-08-01T05:50:16Z

    Fixing non-static calls from private classes using OuterInstance

commit 3930ae4a014c336e73ed4bc24a867e18be4b008f
Author: Connie Yau <co...@microsoft.com>
Date:   2016-08-01T05:51:02Z

    Exposing external getters for ClassEnvRule.TimeZone and Similarity

commit c15ab48b5d3f4b75672ef06c90c7ae645f9cd3e9
Author: Connie Yau <co...@microsoft.com>
Date:   2016-08-01T05:53:24Z

    Changing methods that do not have to be static to non-static. (ie. TestFixture TearDown/Setup)

commit b9bb484d00225721081efc02782ce9191be8a83a
Author: Connie Yau <co...@microsoft.com>
Date:   2016-08-01T05:54:23Z

    Adding TestWriterMethods so that it does not rely on external static call

commit f772f19daecf8b7b139b38a9662dc19d110c8432
Author: Connie Yau <co...@microsoft.com>
Date:   2016-08-01T06:29:27Z

    Injecting OLD_FORMAT_IMPERSONATION_IS_ACTIVE into Codecs so that they do not reference static value

commit c8e1eae628e07b06ae2f31512c9955d66d4b81ca
Author: Connie Yau <co...@microsoft.com>
Date:   2016-08-01T06:30:36Z

    Passing Similarity and TimeZone into RandomIndexWriter ctors.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/lucenenet/pull/177


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/177#discussion_r73790017
  
    --- Diff: src/Lucene.Net.Tests/core/Search/TestPhraseQuery.cs ---
    @@ -255,7 +255,7 @@ public virtual void TestPhraseQueryWithStopAnalyzer()
                 query.Add(new Term("field", "words"));
                 ScoreDoc[] hits = searcher.Search(query, null, 1000).ScoreDocs;
                 Assert.AreEqual(1, hits.Length);
    -            QueryUtils.Check(Random(), query, searcher);
    +            QueryUtils.Check(Random(), Query, Searcher, Similarity);
    --- End diff --
    
    `query, searcher`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet issue #177: Limiting uses of static variables and methods in Testc...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on the issue:

    https://github.com/apache/lucenenet/pull/177
  
    Awesome work, thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/177#discussion_r73790003
  
    --- Diff: src/Lucene.Net.Tests/core/Search/TestFilteredQuery.cs ---
    @@ -280,7 +280,7 @@ private void TBooleanMUST(bool useRandomAccess)
                 bq.Add(query, BooleanClause.Occur.MUST);
                 ScoreDoc[] hits = Searcher.Search(bq, null, 1000).ScoreDocs;
                 Assert.AreEqual(0, hits.Length);
    -            QueryUtils.Check(Random(), query, Searcher);
    +            QueryUtils.Check(Random(), Query, Searcher, Similarity);
    --- End diff --
    
    `query`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet issue #177: Limiting uses of static variables and methods in Testc...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on the issue:

    https://github.com/apache/lucenenet/pull/177
  
    Looks great! Added a few comments
    
    (1) might have found a bug - you didn't change local vars in some occasions so I had commented in some of them, (2) please document all test API changes that diverge from the Java code in the appropriate places, so we don't chase after them in the future or override them by mistake.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet issue #177: Limiting uses of static variables and methods in Testc...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on the issue:

    https://github.com/apache/lucenenet/pull/177
  
    \U0001f44d
    
    lots of files to review :) will be on it asap. Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/177#discussion_r73789929
  
    --- Diff: src/Lucene.Net.Tests/core/Index/TestIndexWriterCommit.cs ---
    @@ -732,5 +736,21 @@ public virtual void TestCommitUserData()
     
                 dir.Dispose();
             }
    +
    +        private void AddDoc(IndexWriter writer)
    --- End diff --
    
    please put a comment on the original methods so if they change we know to reach back here to update accordingly


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/177#discussion_r73789830
  
    --- Diff: src/Lucene.Net.Tests/core/Codecs/Lucene3x/TestLucene3xStoredFieldsFormat.cs ---
    @@ -35,7 +35,8 @@ protected override Codec Codec
             {
                 get
                 {
    -                return new PreFlexRWCodec();
    +                Assert.IsTrue(OLD_FORMAT_IMPERSONATION_IS_ACTIVE, "This should have been set up in the test fixture");
    --- End diff --
    
    why are you assuming this to be true here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet issue #177: Limiting uses of static variables and methods in Testc...

Posted by conniey <gi...@git.apache.org>.
Github user conniey commented on the issue:

    https://github.com/apache/lucenenet/pull/177
  
    @synhershko Thank you for looking over the PR!
    
    >(1) might have found a bug
    I went through those classes again and fixed all the instances that I found where `query` and `searcher` were incorrectly referenced
    
    >(2) please document all test API changes
    I've added `LUCENENET specific` and a reason to all of the APIs that have changed.
    
    Is there anything else that needs to be modified?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] lucenenet pull request #177: Limiting uses of static variables and methods i...

Posted by synhershko <gi...@git.apache.org>.
Github user synhershko commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/177#discussion_r73789759
  
    --- Diff: src/Lucene.Net.TestFramework/Index/RandomIndexWriter.cs ---
    @@ -85,22 +86,22 @@ public static IndexWriter MockIndexWriter(Directory dir, IndexWriterConfig conf,
     
             /// <summary>
             /// create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT and MockAnalyzer </summary>
    -        public RandomIndexWriter(Random r, Directory dir)
    -            : this(r, dir, LuceneTestCase.NewIndexWriterConfig(r, LuceneTestCase.TEST_VERSION_CURRENT, new MockAnalyzer(r)))
    +        public RandomIndexWriter(Random r, Directory dir, Similarity similarity, TimeZone timezone)
    +            : this(r, dir, LuceneTestCase.NewIndexWriterConfig(r, LuceneTestCase.TEST_VERSION_CURRENT, new MockAnalyzer(r), similarity, timezone))
             {
             }
     
             /// <summary>
             /// create a RandomIndexWriter with a random config: Uses TEST_VERSION_CURRENT </summary>
    -        public RandomIndexWriter(Random r, Directory dir, Analyzer a)
    -            : this(r, dir, LuceneTestCase.NewIndexWriterConfig(r, LuceneTestCase.TEST_VERSION_CURRENT, a))
    +        public RandomIndexWriter(Random r, Directory dir, Analyzer a, Similarity similarity, TimeZone timezone)
    +            : this(r, dir, LuceneTestCase.NewIndexWriterConfig(r, LuceneTestCase.TEST_VERSION_CURRENT, a, similarity, timezone))
             {
             }
     
             /// <summary>
             /// create a RandomIndexWriter with a random config </summary>
    -        public RandomIndexWriter(Random r, Directory dir, LuceneVersion v, Analyzer a)
    -            : this(r, dir, LuceneTestCase.NewIndexWriterConfig(r, v, a))
    +        public RandomIndexWriter(Random r, Directory dir, LuceneVersion v, Analyzer a, Similarity similarity, TimeZone timezone)
    +            : this(r, dir, LuceneTestCase.NewIndexWriterConfig(r, v, a, similarity, timezone))
             {
             }
     
    --- End diff --
    
    can you add a LUCENENET comment saying this is specific to the .NET port + reasoning, so we don't override this change in the future?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---