Skip to content

Commit

Permalink
Return RETURN_CODE_NOT_SET when Apple app's exit code not found (#813)
Browse files Browse the repository at this point in the history
  • Loading branch information
premun committed Feb 4, 2022
1 parent 4d24e26 commit 6eee948
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ private ExitCode ParseResult(

if (exitCode is null)
{
if (expectedExitCode != 0)
{
_logger.LogError("Application has finished but XHarness failed to determine its exit code! " +
"This is a known issue, please run the app again.");
return ExitCode.RETURN_CODE_NOT_SET;
}

_logger.LogInformation("App run ended, no abnormal exit code detected (0 assumed)");
exitCode = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,65 @@ public async Task OrchestrateMacCatalystRunTest()
_appInstaller.VerifyNoOtherCalls();
_appUninstaller.VerifyNoOtherCalls();
}

[Fact]
public async Task OrchestrateMacCatalystRunWithNoExitCodeTest()
{
// Setup
_appInstaller.Reset();
_appUninstaller.Reset();
_deviceFinder.Reset();

var testTarget = new TestTargetOs(TestTarget.MacCatalyst, null);

var envVars = new[] { ("envVar1", "value1"), ("envVar2", "value2") };

_macCatalystExitCodeDetector
.Setup(x => x.DetectExitCode(_appBundleInformation, It.IsAny<IReadableLog>()))
.Returns((int?)null)
.Verifiable();

_appRunner
.Setup(x => x.RunMacCatalystApp(
_appBundleInformation,
TimeSpan.FromMinutes(30),
true,
It.IsAny<IEnumerable<string>>(),
envVars,
It.IsAny<CancellationToken>()))
.ReturnsAsync(new ProcessExecutionResult
{
ExitCode = 0,
TimedOut = false,
})
.Verifiable();

// Act
var result = await _runOrchestrator.OrchestrateRun(
_appBundleInformation,
testTarget,
null,
TimeSpan.FromMinutes(30),
TimeSpan.FromMinutes(3),
expectedExitCode: 100,
includeWirelessDevices: false,
resetSimulator: true,
enableLldb: false,
signalAppEnd: true,
envVars,
Array.Empty<string>(),
new CancellationToken());

// Verify
Assert.Equal(ExitCode.RETURN_CODE_NOT_SET, result);

VerifySimulatorReset(false);
VerifySimulatorCleanUp(false);

_macCatalystExitCodeDetector.VerifyAll();
_appRunner.VerifyAll();
_deviceFinder.VerifyNoOtherCalls();
_appInstaller.VerifyNoOtherCalls();
_appUninstaller.VerifyNoOtherCalls();
}
}

0 comments on commit 6eee948

Please sign in to comment.