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

   Wait - about passing a temp directory. Let's not do that. I looked at the 
code and it is passing `tests.seed`, which will sync up the directory name (as 
well as make the spawned process repeatable).
   
   So, let's NOT do:
   
   ```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);
               }
           }
   ```
   
   And instead pass the system properties. We have renamed them in .NET using a 
`:` because `.` has a special meaning. This can either be passed as an 
environment variable or on the command line, although, the latter is a [bit of 
black 
magic](https://github.com/microsoft/vstest-docs/blob/main/docs/RunSettingsArguments.md).
   
   You are missing a bunch of command line arguments to get this to work. This 
is probably the bare minimum of what we need.
   
   ```c#
   ProcessStartInfo startInfo = new ProcessStartInfo
   {
       FileName = "dotnet",
       Arguments = String.Join(" ", new[] {
           "test", this.GetType().Assembly.Location,
           "--framework", GetTargetFramework(),
           "--filter", "Name~TestIndexWriterOnJRECrash",
           "--logger\":console;verbosity=normal\"",
           "--no-build",
           // NOTE: This is special syntax that dotnet test supports to pass 
.runsettings on the command line
           "--", $"RunConfiguration.TargetPlatform={GetTargetPlatform()}" }),
       WorkingDirectory = theDirectory,
       EnvironmentVariables = {
           { "tests:seed", RandomizedContext.CurrentContext.RandomSeedAsHex }, 
           { "tests:culture", Thread.CurrentThread.CurrentCulture.Name }, 
           { "tests:crashmode", "true" }, 
           // passing NIGHTLY to this test makes it run for much longer, easier 
to catch it in the act...
           { "tests: nightly", "true" }
       },
       RedirectStandardOutput = true,
       RedirectStandardError = true,
       UseShellExecute = false
   };
   ```
   
   And yes, that means we can keep the existing `SetUp()` method and 
`tests:crashmode` environment variable code.
   
   I am not sure how much testing has been done with passing system properties 
as environment variables has been done, but I know for certain the command line 
approach works if the above code does not.
   
   Note that I don't know for certain this is the right filter. I got it 
working before, but I thought I specified `~=` or `=~` in that case.


-- 
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