Skip to content

Commit 3d55d61

Browse files
authored
Merge pull request #203 from smadala/fixtestcasefilter
Fix for testcasefilter is not working for netcore
2 parents b5cd5ab + 4c30dd5 commit 3d55d61

File tree

3 files changed

+148
-41
lines changed

3 files changed

+148
-41
lines changed

src/Microsoft.TestPlatform.CrossPlatEngine/Client/Parallel/ParallelProxyExecutionManager.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,16 @@ private bool StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecuti
272272
{
273273
EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSource);
274274

275-
testRunCriteria = new TestRunCriteria(new List<string>() { nextSource }, this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent, this.actualTestRunCriteria.KeepAlive, this.actualTestRunCriteria.TestRunSettings, this.actualTestRunCriteria.RunStatsChangeEventTimeout, this.actualTestRunCriteria.TestHostLauncher);
275+
testRunCriteria = new TestRunCriteria(
276+
new List<string>() { nextSource },
277+
this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent,
278+
this.actualTestRunCriteria.KeepAlive,
279+
this.actualTestRunCriteria.TestRunSettings,
280+
this.actualTestRunCriteria.RunStatsChangeEventTimeout,
281+
this.actualTestRunCriteria.TestHostLauncher)
282+
{
283+
TestCaseFilter = this.actualTestRunCriteria.TestCaseFilter
284+
};
276285
}
277286
}
278287
else
@@ -283,7 +292,12 @@ private bool StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecuti
283292
EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSetOfTests?.FirstOrDefault()?.Source);
284293

285294
testRunCriteria = new TestRunCriteria(
286-
nextSetOfTests, this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent, this.actualTestRunCriteria.KeepAlive, this.actualTestRunCriteria.TestRunSettings, this.actualTestRunCriteria.RunStatsChangeEventTimeout, this.actualTestRunCriteria.TestHostLauncher);
295+
nextSetOfTests,
296+
this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent,
297+
this.actualTestRunCriteria.KeepAlive,
298+
this.actualTestRunCriteria.TestRunSettings,
299+
this.actualTestRunCriteria.RunStatsChangeEventTimeout,
300+
this.actualTestRunCriteria.TestHostLauncher);
287301
}
288302
}
289303

src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs

Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class TestRunCriteria : BaseTestRunCriteria, ITestRunConfiguration
2121
private string testCaseFilter;
2222

2323
/// <summary>
24-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
24+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
2525
/// </summary>
2626
/// <param name="sources">
2727
/// Sources which contains tests that should be executed
@@ -35,7 +35,7 @@ public TestRunCriteria(IEnumerable<string> sources, long frequencyOfRunStatsChan
3535
}
3636

3737
/// <summary>
38-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
38+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
3939
/// </summary>
4040
/// <param name="sources">
4141
/// Sources which contains tests that should be executed
@@ -52,7 +52,7 @@ public TestRunCriteria(IEnumerable<string> sources, long frequencyOfRunStatsChan
5252
}
5353

5454
/// <summary>
55-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
55+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
5656
/// </summary>
5757
/// <param name="sources">
5858
/// Sources which contains tests that should be executed
@@ -72,7 +72,7 @@ public TestRunCriteria(IEnumerable<string> sources, long frequencyOfRunStatsChan
7272
}
7373

7474
/// <summary>
75-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
75+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
7676
/// </summary>
7777
/// <param name="sources">
7878
/// Sources which contains tests that should be executed
@@ -95,7 +95,7 @@ public TestRunCriteria(IEnumerable<string> sources, long frequencyOfRunStatsChan
9595
}
9696

9797
/// <summary>
98-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
98+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
9999
/// Create the TestRunCriteria for a test run
100100
/// </summary>
101101
/// <param name="sources">
@@ -115,7 +115,7 @@ public TestRunCriteria(IEnumerable<string> sources, BaseTestRunCriteria baseTest
115115
}
116116

117117
/// <summary>
118-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
118+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
119119
/// </summary>
120120
/// <param name="sources">
121121
/// Sources which contains tests that should be executed
@@ -152,7 +152,7 @@ public TestRunCriteria(
152152
}
153153

154154
/// <summary>
155-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
155+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
156156
/// </summary>
157157
/// <param name="adapterSourceMap">
158158
/// Sources which contains tests that should be executed
@@ -187,7 +187,7 @@ public TestRunCriteria(
187187
}
188188

189189
/// <summary>
190-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
190+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
191191
/// </summary>
192192
/// <param name="tests">
193193
/// Tests which should be executed
@@ -201,7 +201,7 @@ public TestRunCriteria(IEnumerable<TestCase> tests, long frequencyOfRunStatsChan
201201
}
202202

203203
/// <summary>
204-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
204+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
205205
/// </summary>
206206
/// <param name="tests">
207207
/// Tests which should be executed
@@ -218,7 +218,7 @@ public TestRunCriteria(IEnumerable<TestCase> tests, long frequencyOfRunStatsChan
218218
}
219219

220220
/// <summary>
221-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
221+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
222222
/// </summary>
223223
/// <param name="tests">
224224
/// Tests which should be executed
@@ -238,7 +238,7 @@ public TestRunCriteria(IEnumerable<TestCase> tests, long frequencyOfRunStatsChan
238238
}
239239

240240
/// <summary>
241-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
241+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
242242
/// </summary>
243243
/// <param name="tests">
244244
/// Tests which should be executed
@@ -261,7 +261,7 @@ public TestRunCriteria(IEnumerable<TestCase> tests, long frequencyOfRunStatsChan
261261
}
262262

263263
/// <summary>
264-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
264+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
265265
/// </summary>
266266
/// <param name="tests">
267267
/// Tests which should be executed
@@ -279,7 +279,7 @@ public TestRunCriteria(IEnumerable<TestCase> tests, BaseTestRunCriteria baseTest
279279
}
280280

281281
/// <summary>
282-
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
282+
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
283283
/// </summary>
284284
/// <param name="tests">
285285
/// Sources which contains tests that should be executed
@@ -331,7 +331,7 @@ public IEnumerable<string> Sources
331331
public Dictionary<string, IEnumerable<string>> AdapterSourceMap { get; private set; }
332332

333333
/// <summary>
334-
/// Gets the tests that need to executed in this test run.
334+
/// Gets the tests that need to executed in this test run.
335335
/// This will be null if test run is created with specific test containers
336336
/// </summary>
337337
[DataMember]
@@ -394,6 +394,46 @@ public override string ToString()
394394

395395
return sb.ToString();
396396
}
397+
398+
protected bool Equals(TestRunCriteria other)
399+
{
400+
return base.Equals(other)
401+
&& string.Equals(this.testCaseFilter, other.testCaseFilter);
402+
}
403+
404+
/// <inheritdoc/>
405+
public override bool Equals(object obj)
406+
{
407+
if (object.ReferenceEquals(null, obj))
408+
{
409+
return false;
410+
}
411+
412+
if (object.ReferenceEquals(this, obj))
413+
{
414+
return true;
415+
}
416+
417+
if (obj.GetType() != this.GetType())
418+
{
419+
return false;
420+
}
421+
422+
return this.Equals((TestRunCriteria)obj);
423+
}
424+
425+
/// <inheritdoc/>
426+
public override int GetHashCode()
427+
{
428+
unchecked
429+
{
430+
int hashCode = base.GetHashCode();
431+
hashCode = (hashCode * 397) ^ (this.testCaseFilter != null ? this.testCaseFilter.GetHashCode() : 0);
432+
hashCode = (hashCode * 397) ^ (this.AdapterSourceMap != null ? this.AdapterSourceMap.GetHashCode() : 0);
433+
hashCode = (hashCode * 397) ^ (this.Tests != null ? this.Tests.GetHashCode() : 0);
434+
return hashCode;
435+
}
436+
}
397437
}
398438

399439
/// <summary>
@@ -536,14 +576,14 @@ public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent, bool keepAlive,
536576
public ITestHostLauncher TestHostLauncher { get; private set; }
537577

538578
/// <summary>
539-
/// Gets the frequency of run stats test event.
579+
/// Gets the frequency of run stats test event.
540580
/// </summary>
541581
/// <remarks>
542-
/// Run stats change event will be raised after completion of these number of tests.
543-
/// Note that this event is raised asynchronously and the underlying execution process is not
544-
/// paused during the listener invocation. So if the event handler, you try to query the
582+
/// Run stats change event will be raised after completion of these number of tests.
583+
/// Note that this event is raised asynchronously and the underlying execution process is not
584+
/// paused during the listener invocation. So if the event handler, you try to query the
545585
/// next set of results, you may get more than 'FrequencyOfRunStatsChangeEvent'.
546-
/// </remarks>
586+
/// </remarks>
547587
[DataMember]
548588
public long FrequencyOfRunStatsChangeEvent { get; private set; }
549589

@@ -552,5 +592,47 @@ public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent, bool keepAlive,
552592
/// </summary>
553593
[DataMember]
554594
public TimeSpan RunStatsChangeEventTimeout { get; private set; }
595+
596+
protected bool Equals(BaseTestRunCriteria other)
597+
{
598+
return this.KeepAlive == other.KeepAlive
599+
&& string.Equals(this.TestRunSettings, other.TestRunSettings)
600+
&& this.FrequencyOfRunStatsChangeEvent == other.FrequencyOfRunStatsChangeEvent
601+
&& this.RunStatsChangeEventTimeout.Equals(other.RunStatsChangeEventTimeout);
602+
}
603+
604+
/// <inheritdoc/>
605+
public override bool Equals(object obj)
606+
{
607+
if (object.ReferenceEquals(null, obj))
608+
{
609+
return false;
610+
}
611+
612+
if (object.ReferenceEquals(this, obj))
613+
{
614+
return true;
615+
}
616+
617+
if (obj.GetType() != this.GetType())
618+
{
619+
return false;
620+
}
621+
622+
return this.Equals((BaseTestRunCriteria)obj);
623+
}
624+
625+
/// <inheritdoc/>
626+
public override int GetHashCode()
627+
{
628+
unchecked
629+
{
630+
var hashCode = this.KeepAlive.GetHashCode();
631+
hashCode = (hashCode * 397) ^ (this.TestRunSettings != null ? this.TestRunSettings.GetHashCode() : 0);
632+
hashCode = (hashCode * 397) ^ this.FrequencyOfRunStatsChangeEvent.GetHashCode();
633+
hashCode = (hashCode * 397) ^ this.RunStatsChangeEventTimeout.GetHashCode();
634+
return hashCode;
635+
}
636+
}
555637
}
556638
}

0 commit comments

Comments
 (0)