Skip to content

[MTP CLI Analysis] Duration-style options use inconsistent grammars and units #8430

@Evangelink

Description

@Evangelink

Summary

MTP currently uses three different duration grammars for closely related CLI switches: --timeout, --hangdump-timeout, and --retry-failed-tests-delay. The accepted units, examples, and defaults differ enough that copying a value from one option to another can either fail validation or change meaning.

Evidence

  • src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs:126-133

    if (commandOption.Name == TimeoutOptionKey) { ... if ((char.ToLowerInvariant(arg[size - 1]) != 'h' && ... != 'm' && ... != 's') || !float.TryParse(...) ... }

  • est/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoTests.cs:62-64

--timeout
Takes one argument as string in the format [h|m|s] where 'value' is float.

  • src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.cs:47-49

    if (commandOption.Name == HangDumpTimeoutOptionName && !TimeSpanParser.TryParse(arguments[0], out TimeSpan _))

  • src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resx:178-184

    1.5h, 1.5hour, 1.5hours, 90m, 90min, 90minute, 90minutes, 5400s, 5400sec...

  • src/Platform/Microsoft.Testing.Extensions.Retry/RetryCommandLineOptionsProvider.cs:86-91

    if (commandOption.Name == RetryFailedTestsDelayOptionName && (!TimeSpanParser.TryParse(arguments[0], out TimeSpan delay) ...))

  • src/Platform/Microsoft.Testing.Extensions.Retry/Resources/ExtensionResources.resx:167-171

    �.g. 200, 1s, 2.5m, 1h. Default unit is milliseconds.

  • est/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.cs:64-72,88-94

--retry-failed-tests-delay ... e.g. 200, 1s, 2.5m, 1h. Default unit is milliseconds.
--hangdump-timeout ... 1.5hour ... 90min ... 5400seconds.

Why this is a real issue

These are all duration-style options in the same command surface, but they do not speak the same language. For example, --retry-failed-tests-delay 200 is valid and means 200 ms, while --timeout 200 is invalid because a suffix is mandatory. Likewise --hangdump-timeout 90min is valid, but --timeout 90min is invalid. Users have to memorize per-option grammars instead of relying on a consistent duration convention.

Suggested resolution

Standardize duration parsing across MTP core and its extensions, or at least centralize it behind a shared grammar and shared help text. If keeping different syntaxes is intentional, help output should call that out more explicitly so users are not surprised when values that work for one duration option fail for another.

Related issues

None found.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions