Skip to content

Commit 2942563

Browse files
committed
refactor: allow output directory to be optional
1 parent 79ab1f1 commit 2942563

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/testr.Cli/Commands/RunCommand.cs

+18-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public RunCommand()
4747
"-o|--output-directory",
4848
"The output directory where the Test Case result will be stored.",
4949
CommandOptionType.SingleValue,
50-
cfg => cfg.DefaultValue = ".",
50+
cfg => cfg.DefaultValue = null,
5151
true
5252
);
5353

@@ -110,11 +110,15 @@ private async Task<int> ExecuteAsync(CancellationToken cancellationToken)
110110
_testCaseId.ParsedValue
111111
);
112112

113+
var outputDirectory = _outputDirectory.HasValue()
114+
? _outputDirectory.ParsedValue
115+
: null;
116+
113117
foreach (var file in files)
114118
{
115119
var result = await RunTestCaseAsync(
116120
_inputDirectory.ParsedValue,
117-
_outputDirectory.ParsedValue,
121+
outputDirectory,
118122
file,
119123
cancellationToken
120124
);
@@ -129,7 +133,7 @@ private async Task<int> ExecuteAsync(CancellationToken cancellationToken)
129133

130134
private async Task<int> RunTestCaseAsync(
131135
string inputDirectory,
132-
string outputDirectory,
136+
string? outputDirectory,
133137
string file,
134138
CancellationToken cancellationToken
135139
)
@@ -187,13 +191,16 @@ CancellationToken cancellationToken
187191
}
188192
}
189193

190-
// Store the Test Case run
191-
var run = new TestCaseRun(testCase, testStepResults);
192-
await run.SaveAsync(
193-
inputDirectory,
194-
outputDirectory,
195-
cancellationToken
196-
);
194+
if (!string.IsNullOrWhiteSpace(outputDirectory))
195+
{
196+
// Store the Test Case run
197+
var run = new TestCaseRun(testCase, testStepResults);
198+
await run.SaveAsync(
199+
inputDirectory,
200+
outputDirectory,
201+
cancellationToken
202+
);
203+
}
197204

198205
ConsoleHelper.WriteLineSuccess($"Test Case {testCase.Id} executed successfully.");
199206

@@ -227,4 +234,4 @@ private ExecutorConfig GetExecutorConfiguration()
227234
_recordVideoDir.ParsedValue
228235
);
229236
}
230-
}
237+
}

0 commit comments

Comments
 (0)