private async Task WaitForLockToEngage(SyncdRunResult result) { var data = await result.Reader.ReadLineAsync(); // data will be null on Mac, skip the check on Mac if (!RuntimeEnvironmentHelper.IsMacOSX && data.Trim() != "Locked") { throw new InvalidOperationException($"Unexpected output from process: {data}"); } }
private async Task ReleaseLock(SyncdRunResult result) { await result.Writer.WriteLineAsync("Go"); await result.Writer.FlushAsync(); }
private async Task <SyncdRunResult> Run(string fileName, bool shouldAbandon, CancellationToken token, bool shareProcessObject = false, bool debug = false) { var dir = Directory.GetCurrentDirectory(); var throwFlag = shouldAbandon ? Program.AbandonSwitch : string.Empty; var debugFlag = debug ? Program.DebugSwitch : string.Empty; // Use a dummy file name so the whole system doesn't get locked var dummyFileName = Guid.NewGuid().ToString(); var result = new SyncdRunResult(); result.Start(); #if IS_CORECLR var testDir = new DirectoryInfo(dir); // Find the root test directory while (testDir.Parent != null && !testDir.Name.Equals("test")) { testDir = testDir.Parent; } var coreRunPath = Path.Combine(testDir.Parent.FullName, "cli", "bin", "CoreRun.exe"); if (!File.Exists(coreRunPath)) { throw new FileNotFoundException(coreRunPath); } var testAppDll = Directory.GetFiles(dir, "SynchronizationTestApp.dll", SearchOption.AllDirectories) .Where(file => file.IndexOf("netstandard", StringComparison.OrdinalIgnoreCase) > -1) .FirstOrDefault(); var inputParams = $"{testAppDll} {debugFlag} {fileName} {result.Port} {throwFlag}"; Console.WriteLine($"{coreRunPath} {inputParams}"); var r = CommandRunner.Run( coreRunPath, dir, inputParams, waitForExit: false, timeOutInMilliseconds: 100000, inputAction: null, shareProcessObject: shareProcessObject); #else var testAppName = nameof(SynchronizationTestApp); testAppName += ".exe"; var r = CommandRunner.Run( testAppName, dir, $"{debugFlag} {fileName} {result.Port} {throwFlag}", waitForExit: false, timeOutInMilliseconds: 100000, inputAction: null, shareProcessObject: shareProcessObject); #endif // Act && Assert result.Result = r; await result.Connect(token); return(result); }