Skip to content

Commit

Permalink
Fix bad option in publish test results
Browse files Browse the repository at this point in the history
Tweak process runner tests. They seem to only fail on CI and are brittle. Added more debug information to the trace to help dx failures.
  • Loading branch information
atruskie committed Apr 3, 2020
1 parent 2fd130e commit 45e6232
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ jobs:
- task: PublishTestResults@2
inputs:
testResultFormat: VSTest
testResultFiles: '**/*.trx'
testResultsFiles: '**/*.trx'
searchFolder: $(Agent.TempDirectory)/Acoustics.Test_Results
testRunTitle: "Acoustics.Test for ${{ platform.rid }} ${{ configuration }}"
buildConfig: ${{ configuration }}
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
- task: PublishTestResults@2
inputs:
testResultFormat: VSTest
testResultFiles: '**/*.trx'
testResultsFiles: '**/*.trx'
searchFolder: $(Agent.TempDirectory)/AED.Test_Results
testRunTitle: ".Test for ${{ platform.rid }} ${{ configuration }}"
buildConfig: ${{ configuration }}
Expand Down
6 changes: 4 additions & 2 deletions tests/Acoustics.Test/Shared/ProcessRunnerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,20 @@ private bool RunFfprobeIndefinite(int index)
var dest = PathHelper.GetTempFile(this.TestOutputDirectory, ".mp3");
using (ProcessRunner runner = new ProcessRunner(AppConfigHelper.FfmpegExe))
{
runner.WaitForExitMilliseconds = 1000;
runner.WaitForExitMilliseconds = 500;
runner.WaitForExit = true;
runner.MaxRetries = 1;

Assert.ThrowsException<ProcessRunner.ProcessMaximumRetriesException>(() =>
{
runner.Run($@"-i ""{path}"" -ar 8000 ""{dest}""", this.TestOutputDirectory.FullName);
Assert.Fail($"Process running finished without timing out - this should not happen. Exit code: {runner.ExitCode}.\nStdout:\n{runner.StandardOutput}\nStdErr\n{runner.ErrorOutput}");
});

Assert.AreEqual(0, runner.StandardOutput.Length);
Assert.IsTrue(
runner.ErrorOutput.Length > 1500,
runner.ErrorOutput.Length > 1000,
$"Expected stderr to at least include ffmpeg header but it was only {runner.ErrorOutput.Length} chars. Index: {index}. StdErr:\n{runner.ErrorOutput}");

if (AppConfigHelper.IsWindows)
Expand Down
18 changes: 9 additions & 9 deletions tests/Acoustics.Test/TestHelpers/RetryTestMethodAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public override TestResult[] Execute(ITestMethod testMethod)

var result = new List<TestResult>();

var success = false;
for (int count = 0; count < retryCount; count++)
{
var testResults = base.Execute(testMethod);
Expand All @@ -41,20 +40,21 @@ public override TestResult[] Execute(ITestMethod testMethod)
var failed = testResults.FirstOrDefault((tr) => tr.Outcome == UnitTestOutcome.Failed);
if (failed != null)
{
failed.TestContextMessages += $"Test iteration {count + 1} of {retryCount} failed. Attempting to run again.";
failed.Outcome = UnitTestOutcome.Inconclusive;
var isLast = count + 1 == retryCount;
var retryString = isLast ? " Attempting to run again." : " Exhausted retries, remaining failed.";
failed.TestContextMessages += $"Test iteration {count + 1} of {retryCount} failed.{retryString}";

if (!isLast)
{
failed.Outcome = UnitTestOutcome.Inconclusive;
}

continue;
}

success = true;
break;
}

if (!success)
{
result[^1].Outcome = UnitTestOutcome.Failed;
}

return result.ToArray();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Acoustics.Test/TestHelpers/TestSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void AssemblyInitialize(TestContext context)
enableMemoryLogger: true,
enableFileLogger: false,
colorConsole: false,
defaultLevel: Level.Verbose,
defaultLevel: Level.Info,
quietConsole: true);
}
}
Expand Down

0 comments on commit 45e6232

Please sign in to comment.