Skip to content

Commit

Permalink
Made unit test more robust (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
chitsaw authored Mar 21, 2024
1 parent fca7fa9 commit 6703aa7
Showing 1 changed file with 27 additions and 28 deletions.
55 changes: 27 additions & 28 deletions Sources/Runtime/Test.Psi/PipelineTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1976,36 +1976,35 @@ public void DiagnosticsTest()
var log = new List<string>();
PipelineDiagnostics graph = null;

using (var p = Pipeline.Create(enableDiagnostics: true, diagnosticsConfiguration: new DiagnosticsConfiguration() { SamplingInterval = TimeSpan.FromMilliseconds(1) }))
{
/*
* .........
* =---= . =---= . =---=
* | A |--->| B |--->| D |---+
* =---= . =---= . =---= |
* ^ ......... |
* | |
* +-----------------------+
*/
var sub = new Subpipeline(p);
var cIn = new Connector<int>(p, sub);
var cOut = new Connector<int>(sub, p);
var d = new FinalizationTestComponent(p, "C", log);
var b = new FinalizationTestComponent(sub, "B", log);
var a = new FinalizationTestComponent(p, "A", log);
var timer = Generators.Range(p, 0, 100, TimeSpan.FromMilliseconds(10));
timer.PipeTo(cIn.In);
cIn.Out.PipeTo(b.ReceiverX);
b.RelayFromX.PipeTo(cOut.In);
cOut.Out.PipeTo(d.ReceiverX);
using var p = Pipeline.Create(enableDiagnostics: true, diagnosticsConfiguration: new DiagnosticsConfiguration() { SamplingInterval = TimeSpan.FromMilliseconds(10) });

/*
* .........
* =---= . =---= . =---=
* | A |--->| B |--->| D |---+
* =---= . =---= . =---= |
* ^ ......... |
* | |
* +-----------------------+
*/
var sub = new Subpipeline(p);
var cIn = new Connector<int>(p, sub);
var cOut = new Connector<int>(sub, p);
var d = new FinalizationTestComponent(p, "C", log);
var b = new FinalizationTestComponent(sub, "B", log);
var a = new FinalizationTestComponent(p, "A", log);
var timer = Generators.Range(p, 0, 100, TimeSpan.FromMilliseconds(10));
timer.PipeTo(cIn.In);
cIn.Out.PipeTo(b.ReceiverX);
b.RelayFromX.PipeTo(cOut.In);
cOut.Out.PipeTo(d.ReceiverX);

p.Diagnostics.Do(diag => graph = diag.DeepClone());
p.Diagnostics.Do(diag => graph = diag.DeepClone());

p.RunAsync();
while (graph == null)
{
Thread.Sleep(10);
}
p.RunAsync();
while (graph == null)
{
Thread.Sleep(10);
}

Assert.AreEqual(2, graph.GetPipelineCount()); // total graphs
Expand Down

0 comments on commit 6703aa7

Please sign in to comment.