NightOwl888 commented on issue #768:
URL: https://github.com/apache/lucenenet/issues/768#issuecomment-1362590769

   Looks like it is coming along.
   
   1. I think the main issue is that you are not passing the name of the test 
DLL to dotnet test. If not passed a name, it will run all of the tests, which 
could take a several minutes.
   2. I don't think that `ThreadPumper` makes any sense in .NET. `ThreadPumper` 
is a Java-only thing. We can just attach `StandardOutput` events directly from 
process and it should "just work" without any "pumping". See: 
https://stackoverflow.com/a/285841 and https://stackoverflow.com/a/9730455
   3. Since we will have a random directory name, it is important that it is 
passed to the spawned thread from the original thread in an environment 
variable so the spawned thread knows where to create the index and the final 
check can use the same directory after the crash to check it. You are passing 
one in, but the second process (in the `SetUp()` method) needs to use it if is 
passed in. This is critical because the test in the base class uses this value 
when it creates the index. We need to use `TempDir.FullName` as the value of 
the `"tempDir"` environment variable that is passed to the spawned process. We 
can also use the `"tempDir"` environment variable instead of 
`"tests.crashmode"` to detect which process we are running and to set the 
`TempDir` in `SetUp()` of the spawned process. See the example below.
   4. We can eliminate everything in CrashJRE and simply throw an exception to 
bring down the runtime. However, we need to ensure that the crash thread 
`Join()` method call is before the loop for `Join()` method call. I think we 
will need two threads for this to work 1) A thread to run the crash (which we 
have) and 2) A thread to run the loop for `base.TestNRTThreads_Mem()`. The main 
thread should call `Join()` and wait for both of the other threads to complete. 
We may need some experimentation with what priority will work, though. 
ThreadJob will catch the exception and re-throw it when `Join()` is called, 
which is definitely where this needs to happen on .NET Framework. It should 
work on .NET Core also, but it would be a better test in that environment if we 
override `SafeRun(ThreadStart)` and leave the implementation empty so the 
exception happens during the thread run instead of at the `Join()` on the main 
thread.
   5. For the test name matching, I think we might need to use the contains 
(`~`) operator instead of the equality (`=`) operator. Also the name to use [is 
`Name` rather than `TestName` on 
NUnit](https://learn.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests?pivots=nunit).
 If that advice doesn't help, you might want to create a throwaway project with 
a couple of tests in it to experiment with getting it to execute one and not 
the other.
   
   ```c#
           [SetUp]
           public override void SetUp()
           {
               base. Setup();
               var tempDir = Environment.GetEnvironmentVariable("tempDir");
               if (tempDir is null)
               {
                   TempDir = CreateTempDir("netcrash");
                   TempDir.Delete();
                   TempDir.Create();
               }
               else
               {
                   TempDir = new DirectoryInfo(tempDir);
               }
           }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to