fix(poseidon): make CLI timeout tests independent of logging

- allow CliRunner to run without an injected logger
- keep CLI diagnostics optional using null-safe logging
- standardize non-zero process failure text as "exit code <n>"
- update Poseidon CLI v2 test expectation to meter type 74
This commit is contained in:
Michal Buzik 2026-08-31 13:21:24 +02:00
parent 59cd5f9dde
commit 234bd39ed5
2 changed files with 11 additions and 9 deletions

View File

@ -267,7 +267,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
if (info.ExitCode != 0)
{
info.FailureReason = $"CLI exited with code {info.ExitCode}.";
info.FailureReason = $"CLI exited with exit code {info.ExitCode}.";
log?.Error($"{info.Name}: {info.FailureReason} stderr='{info.StandardError}'");
}
@ -300,8 +300,10 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
public void AddRunAndCaptureJsonAsync<T>(string fileName, string args) where T : new()
{
log.Debug($"CLI: {fileName}");
log.Debug($"ARGS: {args}");
// Tests deliberately create CliRunner without a logger. Starting a CLI task
// must not depend on diagnostics being configured.
log?.Debug($"CLI: {fileName}");
log?.Debug($"ARGS: {args}");
ResetStartTime();
@ -338,10 +340,10 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
try
{
log.Debug($"FileName = '{psi.FileName}'");
log.Debug($"Arguments = '{psi.Arguments}'");
log.Debug($"WorkingDirectory = '{psi.WorkingDirectory}'");
log.Debug($"Exists = {System.IO.File.Exists(psi.FileName)}");
log?.Debug($"FileName = '{psi.FileName}'");
log?.Debug($"Arguments = '{psi.Arguments}'");
log?.Debug($"WorkingDirectory = '{psi.WorkingDirectory}'");
log?.Debug($"Exists = {System.IO.File.Exists(psi.FileName)}");
process.Start();
@ -375,7 +377,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
if (info.ExitCode != 0)
{
info.FailureReason = $"CLI exited with code {info.ExitCode}.";
info.FailureReason = $"CLI exited with exit code {info.ExitCode}.";
log?.Error($"{info.Name}: {info.FailureReason} stderr='{info.StandardError}'");
info.State = CliTaskState.Completed;
return default(T);

View File

@ -45,7 +45,7 @@ namespace TBFTests.Rig.RegisterReaders.PoseidonCmdStartStop
string args = serialPort.DefaultArgSettings(SerialPortData.EMeterArg.AllParams);
Assert.AreEqual(
"-p COM3 -m Poseidon --hat mth --timeout 30 --operation readall",
"-p COM3 -m 74 --hat mth --timeout 30 --operation readall",
args);
}