10000 Allow to override the path to rabbitmqctl and rabbitmq-test · yezijiang/rabbitmq-java-client@6ff390a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6ff390a

Browse files
committed
Allow to override the path to rabbitmqctl and rabbitmq-test
1 parent 57ecae5 commit 6ff390a

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

test/src/com/rabbitmq/tools/Host.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ private static Process executeCommandProcess(String command) throws IOException
9393
}
9494

9595
public static Process rabbitmqctl(String command) throws IOException {
96-
return executeCommand("../rabbitmq-server/scripts/rabbitmqctl " + command);
96+
return executeCommand(rabbitmqctlCommand() + " " + command);
9797
}
9898

9999
public static Process rabbitmqctlIgnoreErrors(String command) throws IOException {
100-
return executeCommandIgnoringErrors("../rabbitmq-server/scripts/rabbitmqctl " + command);
100+
return executeCommandIgnoringErrors(rabbitmqctlCommand() + " " + command);
101101
}
102102

103103
public static Process invokeMakeTarget(String command) throws IOException {
104-
return executeCommand("cd ../rabbitmq-test; " + makeCommand() + " " + command);
104+
return executeCommand("cd " + rabbitmqTestDir() + "; " + makeCommand() + " " + command);
105105
}
106106

107107
private static String makeCommand()
@@ -118,6 +118,32 @@ private static String makeCommand()
118118
return makecmd;
119119
}
120120

121+
private static String rabbitmqctlCommand()
122+
{
123+
// Get the rabbitmqctl(1) executable to use from the environment.
124+
String cmd = System.getenv("RABBITMQCTL");
125+
126+
// Default to "make" if the environment variable is unset.
127+
if (cmd == null) {
128+
cmd = "../rabbitmq-server/scripts/rabbitmqctl";
129+
}
130+
131+
return cmd;
132+
}
133+
134+
private static String rabbitmqTestDir()
135+
{
136+
// Get the rabbitmq-test directory to use from the environment.
137+
String dir = System.getenv("RABBITMQ_TEST_DIR");
138+
139+
// Default to "make" if the environment variable is unset.
140+
if (dir == null) {
141+
dir = "../rabbitmq-test";
142+
}
143+
144+
return dir;
145+
}
146+
121147
public static void closeConnection(String pid) throws IOException {
122148
rabbitmqctl("close_connection '" + pid + "' 'Closed via rabbitmqctl'");
123149
}

0 commit comments

Comments
 (0)
0