Skip to content

Commit

Permalink
Merge pull request #203 from smadala/fixtestcasefilter
Browse files Browse the repository at this point in the history
Fix for testcasefilter is not working for netcore
  • Loading branch information
codito authored Nov 14, 2016
2 parents b5cd5ab + 4c30dd5 commit 3d55d61
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,16 @@ private bool StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecuti
{
EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSource);

testRunCriteria = new TestRunCriteria(new List<string>() { nextSource }, this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent, this.actualTestRunCriteria.KeepAlive, this.actualTestRunCriteria.TestRunSettings, this.actualTestRunCriteria.RunStatsChangeEventTimeout, this.actualTestRunCriteria.TestHostLauncher);
testRunCriteria = new TestRunCriteria(
new List<string>() { nextSource },
this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent,
this.actualTestRunCriteria.KeepAlive,
this.actualTestRunCriteria.TestRunSettings,
this.actualTestRunCriteria.RunStatsChangeEventTimeout,
this.actualTestRunCriteria.TestHostLauncher)
{
TestCaseFilter = this.actualTestRunCriteria.TestCaseFilter
};
}
}
else
Expand All @@ -283,7 +292,12 @@ private bool StartTestRunOnConcurrentManager(IProxyExecutionManager proxyExecuti
EqtTrace.Info("ProxyParallelExecutionManager: Triggering test run for next source: {0}", nextSetOfTests?.FirstOrDefault()?.Source);

testRunCriteria = new TestRunCriteria(
nextSetOfTests, this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent, this.actualTestRunCriteria.KeepAlive, this.actualTestRunCriteria.TestRunSettings, this.actualTestRunCriteria.RunStatsChangeEventTimeout, this.actualTestRunCriteria.TestHostLauncher);
nextSetOfTests,
this.actualTestRunCriteria.FrequencyOfRunStatsChangeEvent,
this.actualTestRunCriteria.KeepAlive,
this.actualTestRunCriteria.TestRunSettings,
this.actualTestRunCriteria.RunStatsChangeEventTimeout,
this.actualTestRunCriteria.TestHostLauncher);
}
}

Expand Down
120 changes: 101 additions & 19 deletions src/Microsoft.TestPlatform.ObjectModel/Client/TestRunCriteria.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TestRunCriteria : BaseTestRunCriteria, ITestRunConfiguration
private string testCaseFilter;

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

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

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

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

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

/// <summary>
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
/// </summary>
/// <param name="sources">
/// Sources which contains tests that should be executed
Expand Down Expand Up @@ -152,7 +152,7 @@ public TestRunCriteria(
}

/// <summary>
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
/// Initializes a new instance of the <see cref="TestRunCriteria"/> class.
/// </summary>
/// <param name="adapterSourceMap">
/// Sources which contains tests that should be executed
Expand Down Expand Up @@ -187,7 +187,7 @@ public TestRunCriteria(
}

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

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

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

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

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

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

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

return sb.ToString();
}

protected bool Equals(TestRunCriteria other)
{
return base.Equals(other)
&& string.Equals(this.testCaseFilter, other.testCaseFilter);
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}

if (object.ReferenceEquals(this, obj))
{
return true;
}

if (obj.GetType() != this.GetType())
{
return false;
}

return this.Equals((TestRunCriteria)obj);
}

/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.testCaseFilter != null ? this.testCaseFilter.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.AdapterSourceMap != null ? this.AdapterSourceMap.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.Tests != null ? this.Tests.GetHashCode() : 0);
return hashCode;
}
}
}

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

/// <summary>
/// Gets the frequency of run stats test event.
/// Gets the frequency of run stats test event.
/// </summary>
/// <remarks>
/// Run stats change event will be raised after completion of these number of tests.
/// Note that this event is raised asynchronously and the underlying execution process is not
/// paused during the listener invocation. So if the event handler, you try to query the
/// Run stats change event will be raised after completion of these number of tests.
/// Note that this event is raised asynchronously and the underlying execution process is not
/// paused during the listener invocation. So if the event handler, you try to query the
/// next set of results, you may get more than 'FrequencyOfRunStatsChangeEvent'.
/// </remarks>
/// </remarks>
[DataMember]
public long FrequencyOfRunStatsChangeEvent { get; private set; }

Expand All @@ -552,5 +592,47 @@ public BaseTestRunCriteria(long frequencyOfRunStatsChangeEvent, bool keepAlive,
/// </summary>
[DataMember]
public TimeSpan RunStatsChangeEventTimeout { get; private set; }

protected bool Equals(BaseTestRunCriteria other)
{
return this.KeepAlive == other.KeepAlive
&& string.Equals(this.TestRunSettings, other.TestRunSettings)
&& this.FrequencyOfRunStatsChangeEvent == other.FrequencyOfRunStatsChangeEvent
&& this.RunStatsChangeEventTimeout.Equals(other.RunStatsChangeEventTimeout);
}

/// <inheritdoc/>
public override bool Equals(object obj)
{
if (object.ReferenceEquals(null, obj))
{
return false;
}

if (object.ReferenceEquals(this, obj))
{
return true;
}

if (obj.GetType() != this.GetType())
{
return false;
}

return this.Equals((BaseTestRunCriteria)obj);
}

/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
var hashCode = this.KeepAlive.GetHashCode();
hashCode = (hashCode * 397) ^ (this.TestRunSettings != null ? this.TestRunSettings.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.FrequencyOfRunStatsChangeEvent.GetHashCode();
hashCode = (hashCode * 397) ^ this.RunStatsChangeEventTimeout.GetHashCode();
return hashCode;
}
}
}
}
Loading

0 comments on commit 3d55d61

Please sign in to comment.