Skip to content

Commit 5854108

Browse files
Fall back to rabbitmqctl (or rabbitmqctl.bat) if RABBITMQ_RABBITMQCTL_PATH or umbrella path are not available (#818)
Per discussion with @lukebakken
1 parent 067dd87 commit 5854108

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

projects/Unit/Fixtures.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
using System;
4444
using System.Collections.Generic;
4545
using System.Diagnostics;
46+
using System.IO;
4647
using System.Linq;
4748
using System.Text;
4849
using System.Text.RegularExpressions;
@@ -417,7 +418,6 @@ internal Process ExecRabbitMQCtl(string args)
417418
{
418419
// Allow the path to the rabbitmqctl.bat to be set per machine
419420
string envVariable = Environment.GetEnvironmentVariable("RABBITMQ_RABBITMQCTL_PATH");
420-
421421
string rabbitmqctlPath;
422422

423423
if (envVariable != null)
@@ -428,19 +428,31 @@ internal Process ExecRabbitMQCtl(string args)
428428
if (match.Success)
429429
{
430430
return ExecRabbitMqCtlUsingDocker(args, match.Groups["dockerMachine"].Value);
431-
}
432-
else
433-
{
431+
} else {
434432
rabbitmqctlPath = envVariable;
435433
}
436434
}
437-
else if (IsRunningOnMonoOrDotNetCore())
438-
{
439-
rabbitmqctlPath = "../../../../../../rabbit/scripts/rabbitmqctl";
440-
}
441435
else
442436
{
443-
rabbitmqctlPath = @"..\..\..\..\..\..\rabbit\scripts\rabbitmqctl.bat";
437+
// provided by the umbrella
438+
string umbrellaRabbitmqctlPath;
439+
// provided in PATH by a RabbitMQ installation
440+
string providedRabbitmqctlPath;
441+
442+
if (IsRunningOnMonoOrDotNetCore())
443+
{
444+
umbrellaRabbitmqctlPath = "../../../../../../rabbit/scripts/rabbitmqctl";
445+
providedRabbitmqctlPath = "rabbitmqctl";
446+
} else {
447+
umbrellaRabbitmqctlPath = @"..\..\..\..\..\..\rabbit\scripts\rabbitmqctl.bat";
448+
providedRabbitmqctlPath = "rabbitmqctl.bat";
449+
}
450+
451+
if (File.Exists(umbrellaRabbitmqctlPath)) {
452+
rabbitmqctlPath = umbrellaRabbitmqctlPath;
453+
} else {
454+
rabbitmqctlPath = providedRabbitmqctlPath;
455+
}
444456
}
445457

446458
return ExecCommand(rabbitmqctlPath, args);

0 commit comments

Comments
 (0)