Skip to content

Commit

Permalink
Avoid unnecessary pre-flight checks
Browse files Browse the repository at this point in the history
  • Loading branch information
si618 committed Mar 11, 2024
1 parent b44c36b commit 5787f88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 6 additions & 3 deletions Benchmarks.App/PreFlightCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

internal static class PreFlightCheck
{
internal static void CanStartTestContainers()
internal static void Run(bool isApp)
{
ConsoleWriter.WriteHeader(clearConsole: false);
ConsoleWriter.WriteHeader();

AnsiConsole.MarkupLine("[gray]Running pre-flight check to verify test containers can start[/]");
AnsiConsole.WriteLine();
Expand All @@ -20,6 +20,9 @@ internal static void CanStartTestContainers()
AnsiConsole.WriteLine();
AnsiConsole.MarkupLine("[gray]Test container pre-flight check passed[/]");

Thread.Sleep(TimeSpan.FromSeconds(1.66));
if (isApp)
{
Thread.Sleep(TimeSpan.FromSeconds(1.66));
}
}
}
11 changes: 8 additions & 3 deletions Benchmarks.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@

try
{
// Do not run the preflight check if the user is asking for help or version information
if (args.Length > 0 && !args.Any(a => a.StartsWith('-')))
var isPreFlightCheckNeeded =
(args.Length > 0 && !args.Any(arg => arg.StartsWith('-'))) &&
args.Any(arg =>
arg.Contains("app", StringComparison.OrdinalIgnoreCase) ||
arg.Contains("benchmark", StringComparison.OrdinalIgnoreCase));
if (isPreFlightCheckNeeded)
{
PreFlightCheck.CanStartTestContainers();
var isApp = args.Any(arg => arg.Contains("app", StringComparison.OrdinalIgnoreCase));
PreFlightCheck.Run(isApp);
}

return await app.RunAsync(args);
Expand Down

0 comments on commit 5787f88

Please sign in to comment.