fix(cli): guard min-time overflow + normalize 0 exec-timeout to null + stale comment (#54 review)

This commit is contained in:
Joseph Doherty
2026-06-19 03:24:11 -04:00
parent 597d664a53
commit e3b83f8561
4 changed files with 41 additions and 4 deletions
@@ -117,4 +117,34 @@ public class TemplateScriptTimingTests
Assert.Null(d);
Assert.NotNull(err);
}
/// <summary>
/// An absurdly large value (16-digit millisecond count) would overflow long/TimeSpan
/// without the overflow guard. The parser must return false cleanly — not throw.
/// </summary>
[Theory]
[InlineData("9999999999999999ms")] // 16-digit ms: far exceeds TimeSpan.MaxValue (~922337203685477ms)
[InlineData("9999999999999999s")] // 16-digit seconds: even larger when scaled
[InlineData("9999999999999999min")] // 16-digit minutes
public void MinTime_AbsurdlyLarge_ReturnsFalseWithoutThrowing(string value)
{
// Must not throw — TryParse contract: never throws, always returns bool.
var threw = false;
bool result = false;
TimeSpan? duration = null;
string? error = null;
try
{
result = TemplateCommands.TryParseMinTimeBetweenRuns(value, out duration, out error);
}
catch
{
threw = true;
}
Assert.False(threw, "TryParseMinTimeBetweenRuns must not throw on large input");
Assert.False(result);
Assert.Null(duration);
Assert.NotNull(error);
}
}