Skip to content

Commit 7c3c0dd

Browse files
CopilotMalcolmnixonCopilot
authored
fix: resolve VersionMark-CommandLine-Review, VersionMark-Utilities-Review, VersionMark-Configuration-Review, VersionMark-VersionInfo-Review, and VersionMark-Validation-Review failures (#37)
* Initial plan * fix: address VersionMark-CommandLine-Review failures - Add missing justification and tags to Cmd-ErrorOutput, Cmd-InvalidArgs, Cmd-ExitCode requirements - Fix stale test reference VersionMark_GeneratesMarkdownReport -> VersionMark_PublishCommand_GeneratesMarkdownReport in publish.yaml - Remove non-existent VersionMark_CapturesVersions test reference from capture.yaml - Align priority table in command-line.md with Program.cs priority comments Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: correct VersionMark-Fmt-MarkdownList requirement wording (subscript → bold) Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * fix: correct stale remarks on RunCommand in VersionMarkConfig.cs Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * fix: resolve VersionMark-VersionInfo-Review failures Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * fix: resolve VersionMark-Validation-Review failures Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> * fix: strengthen two weak test assertions in CommandLine test files TEST-01 fix 1 - Program_Run_WithVersionFlag_DisplaysVersionOnly (ProgramTests.cs): Added positive assertion that a version string IS printed, in addition to the existing negative assertions that the banner is NOT shown. Without this, the test would pass even if nothing was printed at all. TEST-01 fix 2 - IntegrationTest_SilentFlag_SuppressesOutput (IntegrationTests.cs): Captured the output instead of discarding it and added DoesNotContain assertions for the tool's normal banner content. The prior test only checked exit code and had a comment 'Output check removed', making the test name misleading. All 57 ContextTests/ProgramTests/IntegrationTests pass on net8.0/net9.0/net10.0. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com> Co-authored-by: Malcolm Nixon <Malcolm.nixon@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 1a2c41d commit 7c3c0dd

11 files changed

Lines changed: 66 additions & 19 deletions

File tree

docs/design/command-line.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ generate event-log entries. This satisfies requirements `VersionMark-Cmd-ExitCod
3434
| Priority | Condition | Action |
3535
|----------|------------------------|---------------------------------|
3636
| 1 | `context.Version` | Print version string and return |
37-
| 2 | Print banner | Always executed after priority 1|
38-
| 3 | `context.Help` | Print usage and return |
39-
| 4 | `context.Validate` | Run self-validation and return |
40-
| 5 | `context.Capture` | Run capture mode and return |
41-
| 5.5 | `context.Publish` | Run publish mode and return |
42-
| 6 | Default | Run placeholder tool logic |
37+
| | Print banner | Always executed after priority 1|
38+
| 2 | `context.Help` | Print usage and return |
39+
| 3 | `context.Validate` | Run self-validation and return |
40+
| 4 | `context.Capture` | Run capture mode and return |
41+
| 4.5 | `context.Publish` | Run publish mode and return |
42+
| 5 | Default | Run placeholder tool logic |
4343

4444
This dispatch order satisfies requirements `VersionMark-Cmd-Version`, `VersionMark-Cmd-Help`,
4545
`VersionMark-Cmd-Validate`, `VersionMark-Cap-Capture`, and `VersionMark-Pub-Publish`.

docs/design/validation.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ organizes all test execution internally.
3030

3131
1. Creates a `TemporaryDirectory` (see below).
3232
2. Writes a minimal `.versionmark.yaml` containing only the `dotnet` tool.
33-
3. Constructs a `Context` with `--capture`, `--job-id test-job`, and `--output <file>`.
33+
3. Constructs a `Context` with `--silent`, `--log <file>`, `--capture`, `--job-id test-job`,
34+
and `--output <file>`.
3435
4. Changes the current directory to the temp directory and calls `Program.Run`.
3536
5. Verifies exit code is 0, output file exists, `JobId` equals `"test-job"`, and `dotnet`
3637
version was captured and is non-empty.
@@ -43,7 +44,8 @@ The test name is `VersionMark_CapturesVersions`, satisfying `VersionMark-Cap-Cap
4344

4445
1. Creates a `TemporaryDirectory`.
4546
2. Writes two `VersionInfo` JSON files with known content.
46-
3. Constructs a `Context` with `--publish`, `--report <file>`, and `-- versionmark-*.json`.
47+
3. Constructs a `Context` with `--silent`, `--log <file>`, `--publish`, `--report <file>`,
48+
`--report-depth 2`, and `-- versionmark-*.json`.
4749
4. Changes the current directory to the temp directory and calls `Program.Run`.
4850
5. Verifies exit code is 0, report file exists, and contains `## Tool Versions`,
4951
`**dotnet**`, `**node**`, `8.0.0`, and `20.0.0`.

docs/design/version-info.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ The `VersionInfo` record (`VersionInfo.cs`) is a positional record with two prop
2020
`SaveToFile` serializes the record to indented JSON using `JsonSerializer.Serialize` with
2121
`WriteIndented = true` and writes it to the specified path using UTF-8 encoding. Non-`InvalidOperationException`
2222
errors are wrapped and re-thrown as `InvalidOperationException` with context. This satisfies
23-
requirements `VersionMark-Cap-JsonOutput` and `VersionMark-Cap-DefaultOutput`.
23+
requirement `VersionMark-Cap-JsonOutput`. The default output filename (`versionmark-<job-id>.json`)
24+
is determined by the CLI layer and contributes to satisfying `VersionMark-Cap-DefaultOutput`.
2425

2526
### LoadFromFile Method
2627

docs/reqstream/capture.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ sections:
1212
tags:
1313
- capture
1414
tests:
15-
- VersionMark_CapturesVersions
1615
- Program_Run_WithCaptureCommand_CapturesToolVersions
1716
- IntegrationTest_CaptureCommand_CapturesToolVersions
1817

docs/reqstream/command-line.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,22 @@ sections:
9494

9595
- id: VersionMark-Cmd-ErrorOutput
9696
title: The tool shall write error messages to stderr.
97+
justification: |
98+
Separating error output from standard output allows callers and CI/CD
99+
pipelines to distinguish normal output from failure diagnostics.
100+
tags:
101+
- cli
97102
tests:
98103
- Context_WriteError_NotSilent_WritesToConsole
99104
- IntegrationTest_UnknownArgument_ReturnsError
100105

101106
- id: VersionMark-Cmd-InvalidArgs
102107
title: The tool shall reject unknown or malformed command-line arguments with a descriptive error.
108+
justification: |
109+
Clear rejection of invalid arguments prevents silent misconfiguration and
110+
guides users toward correct usage without requiring external documentation.
111+
tags:
112+
- cli
103113
tests:
104114
- Context_Create_UnknownArgument_ThrowsArgumentException
105115
- Context_Create_LogFlag_WithoutValue_ThrowsArgumentException
@@ -108,6 +118,11 @@ sections:
108118

109119
- id: VersionMark-Cmd-ExitCode
110120
title: The tool shall return a non-zero exit code on failure.
121+
justification: |
122+
A non-zero exit code on failure enables CI/CD pipelines and scripts to
123+
detect and respond to tool failures automatically.
124+
tags:
125+
- cli
111126
tests:
112127
- Context_WriteError_SetsErrorExitCode
113128
- IntegrationTest_UnknownArgument_ReturnsError

docs/reqstream/formatter.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ sections:
4141

4242
- id: VersionMark-Fmt-MarkdownList
4343
title: >-
44-
The tool shall use subscript formatting and parenthesized job IDs to indicate which
44+
The tool shall use bold formatting and parenthesized job IDs to indicate which
4545
jobs had which versions.
4646
justification: |
4747
Provides clear visual distinction between different job executions and their

docs/reqstream/publish.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sections:
1212
tags:
1313
- publish
1414
tests:
15-
- VersionMark_GeneratesMarkdownReport
15+
- VersionMark_PublishCommand_GeneratesMarkdownReport
1616

1717
- id: VersionMark-Pub-Report
1818
title: The tool shall support --report parameter to specify the output markdown file path in publish mode.
@@ -22,7 +22,7 @@ sections:
2222
tags:
2323
- publish
2424
tests:
25-
- VersionMark_GeneratesMarkdownReport
25+
- VersionMark_PublishCommand_GeneratesMarkdownReport
2626

2727
- id: VersionMark-Pub-ReportDepth
2828
title: The tool shall support --report-depth parameter to control heading depth in generated markdown.
@@ -52,7 +52,8 @@ sections:
5252
tags:
5353
- publish
5454
tests:
55-
- VersionMark_GeneratesMarkdownReport
55+
- VersionMark_PublishCommandWithCustomGlobPatterns_FiltersFiles
56+
- Context_Create_GlobPatternsAfterSeparator_CapturesPatterns
5657

5758
- id: VersionMark-Pub-Consolidate
5859
title: The tool shall read and parse JSON files matching the specified glob patterns in publish mode.
@@ -62,7 +63,7 @@ sections:
6263
tags:
6364
- publish
6465
tests:
65-
- VersionMark_GeneratesMarkdownReport
66+
- VersionMark_PublishCommand_GeneratesMarkdownReport
6667

6768
- id: VersionMark-Pub-ConflictReport
6869
title: The tool shall report errors when no JSON files match the specified glob patterns.

src/DemaConsulting.VersionMark/VersionMarkConfig.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,9 @@ public VersionInfo FindVersions(IEnumerable<string> toolNames, string jobId)
331331
/// <returns>The combined stdout and stderr output.</returns>
332332
/// <exception cref="InvalidOperationException">Thrown when the command fails to execute.</exception>
333333
/// <remarks>
334-
/// Commands are split on the first space character to separate executable from arguments.
335-
/// This does not handle quoted arguments containing spaces.
334+
/// Commands are delegated to the OS shell (<c>cmd.exe /c</c> on Windows, <c>/bin/sh -c</c>
335+
/// elsewhere) via <c>ArgumentList</c> to avoid escaping issues. This supports <c>.cmd</c>/<c>.bat</c>
336+
/// files on Windows and shell features (pipes, redirects, built-ins) on all platforms.
336337
/// </remarks>
337338
private static string RunCommand(string command)
338339
{

test/DemaConsulting.VersionMark.Tests/IntegrationTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,17 @@ public void IntegrationTest_SilentFlag_SuppressesOutput()
196196
{
197197
// Arrange & Act - Run the application with --silent flag
198198
var exitCode = Runner.Run(
199-
out var _,
199+
out var output,
200200
"dotnet",
201201
_dllPath,
202202
"--silent");
203203

204204
// Assert - Verify success
205205
Assert.AreEqual(0, exitCode);
206206

207-
// Output check removed since silent mode may still produce some output
207+
// Verify the tool's normal output is suppressed
208+
Assert.DoesNotContain("VersionMark version", output);
209+
Assert.DoesNotContain("Copyright (c) DEMA Consulting", output);
208210
}
209211

210212
/// <summary>

test/DemaConsulting.VersionMark.Tests/ProgramTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public void Program_Run_WithVersionFlag_DisplaysVersionOnly()
4545

4646
// Assert - Verify version-only output
4747
var output = outWriter.ToString();
48+
Assert.IsFalse(string.IsNullOrWhiteSpace(output), "Version string should be printed");
4849
Assert.DoesNotContain("Copyright", output);
4950
Assert.DoesNotContain("VersionMark version", output);
5051
}

0 commit comments

Comments
 (0)