Skip to content

Commit

Permalink
Enable tests "Hang due to System.Console.ReadKey()" (#1707)
Browse files Browse the repository at this point in the history
* enable tests "Hang due to System.Console.ReadKey()"

* modify AssertInstrumentLines

* remove attributes and comments
  • Loading branch information
Bertk authored Nov 18, 2024
1 parent 7e0c7e8 commit 3004bb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
24 changes: 10 additions & 14 deletions test/coverlet.core.tests/Coverage/CoverageTests.DoesNotReturn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void NoBranches_DoesNotReturnAttribute_InstrumentsCorrect()
}
}

[Fact(Skip = "Hang due to System.Console.ReadKey()")]
[Fact]
public void If_DoesNotReturnAttribute_InstrumentsCorrect()
{
string path = Path.GetTempFileName();
Expand All @@ -68,16 +68,15 @@ public void If_DoesNotReturnAttribute_InstrumentsCorrect()
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);

result.Document("Instrumentation.DoesNotReturn.cs")
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 19, 20, 22, 23, 24, 25, 29, 30)
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 26, 27);
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 19, 20, 22, 23, 24, 25, 29, 30, 26, 27);
}
finally
{
File.Delete(path);
}
}

[Fact(Skip = "Hang due to System.Console.ReadKey()")]
[Fact]
public void Switch_DoesNotReturnAttribute_InstrumentsCorrect()
{
string path = Path.GetTempFileName();
Expand All @@ -100,16 +99,15 @@ public void Switch_DoesNotReturnAttribute_InstrumentsCorrect()
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);

result.Document("Instrumentation.DoesNotReturn.cs")
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 33, 34, 36, 39, 40, 44, 45, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62, 64, 65, 68, 69)
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 41, 42);
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 33, 34, 36, 39, 40, 44, 45, 49, 50, 52, 53, 55, 56, 58, 59, 61, 62, 64, 65, 68, 69, 41, 42);
}
finally
{
File.Delete(path);
}
}

[Fact(Skip = "Hang due to System.Console.ReadKey()")]
[Fact]
public void Subtle_DoesNotReturnAttribute_InstrumentsCorrect()
{
string path = Path.GetTempFileName();
Expand All @@ -132,16 +130,15 @@ public void Subtle_DoesNotReturnAttribute_InstrumentsCorrect()
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);

result.Document("Instrumentation.DoesNotReturn.cs")
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 72, 73, 75, 78, 82, 83, 86, 87, 91, 92, 95, 101, 102, 103)
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 79, 80, 88, 96, 98, 99);
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 72, 73, 75, 78, 82, 83, 86, 87, 91, 92, 95, 101, 102, 103, 79, 80, 88, 96, 98, 99);
}
finally
{
File.Delete(path);
}
}

[Fact(Skip = "Hang due to System.Console.ReadKey()")]
[Fact]
public void UnreachableBranch_DoesNotReturnAttribute_InstrumentsCorrect()
{
string path = Path.GetTempFileName();
Expand All @@ -164,8 +161,7 @@ public void UnreachableBranch_DoesNotReturnAttribute_InstrumentsCorrect()
CoverageResult result = TestInstrumentationHelper.GetCoverageResult(path);

result.Document("Instrumentation.DoesNotReturn.cs")
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 106, 107, 108)
.AssertNonInstrumentedLines(BuildConfiguration.Debug, 110, 111, 112, 113, 114);
.AssertInstrumentLines(BuildConfiguration.Debug, 7, 8, 106, 107, 108, 110, 111, 112, 113, 114);
}
finally
{
Expand Down Expand Up @@ -270,7 +266,7 @@ public void WithLeave_DoesNotReturnAttribute_InstrumentsCorrect()
}

[Fact]
public void FiltersAndFinallies_DoesNotReturnAttribute_InstrumentsCorrect()
public void FiltersAndFinally_DoesNotReturnAttribute_InstrumentsCorrect()
{
string path = Path.GetTempFileName();
try
Expand All @@ -279,7 +275,7 @@ public void FiltersAndFinallies_DoesNotReturnAttribute_InstrumentsCorrect()
{
CoveragePrepareResult coveragePrepareResult = await TestInstrumentationHelper.Run<DoesNotReturn>(instance =>
{
try { instance.FiltersAndFinallies(); }
try { instance.FiltersAndFinally(); }
catch (Exception) { }
return Task.CompletedTask;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void Subtle()
case 'C':
System.Console.WriteLine("In-Constant-3");
Throws();
goto alwayUnreachable; // unreachable
goto alwaysUnreachable; // unreachable

case 'D':
System.Console.WriteLine("In-Constant-4");
Expand All @@ -95,7 +95,7 @@ public void Subtle()
Throws();
System.Console.WriteLine("Out-Constant-1"); // unreachable

alwayUnreachable: // unreachable
alwaysUnreachable: // unreachable
System.Console.WriteLine("Out-Constant-2"); // unreachable

subtlyReachable:
Expand Down Expand Up @@ -167,7 +167,7 @@ public void WithLeave()
System.Console.WriteLine("Constant-2");
}

public void FiltersAndFinallies()
public void FiltersAndFinally()
{
try
{
Expand Down

0 comments on commit 3004bb7

Please sign in to comment.