Skip to content

Commit e8f3737

Browse files
author
Simon MacMullen
committed
Use the MAKE envirobnment variable, and extract a bit of commonality.
1 parent 6dc48cf commit e8f3737

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

test/src/com/rabbitmq/client/test/BrokerTestCase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ protected void restart()
9494

9595
protected void bareRestart()
9696
throws IOException {
97-
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
97+
Host.invokeMakeTarget("restart-app");
9898
}
9999

100100
public void openConnection()
@@ -248,11 +248,11 @@ protected void clearAllResourceAlarms() throws IOException, InterruptedException
248248
}
249249

250250
protected void setResourceAlarm(String source) throws IOException, InterruptedException {
251-
Host.executeCommand("cd ../rabbitmq-test; make set-resource-alarm SOURCE=" + source);
251+
Host.invokeMakeTarget("set-resource-alarm SOURCE=" + source);
252252
}
253253

254254
protected void clearResourceAlarm(String source) throws IOException, InterruptedException {
255-
Host.executeCommand("cd ../rabbitmq-test; make clear-resource-alarm SOURCE=" + source);
255+
Host.invokeMakeTarget("clear-resource-alarm SOURCE=" + source);
256256
}
257257

258258
protected void block() throws IOException, InterruptedException {

test/src/com/rabbitmq/client/test/functional/ClusteredTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ public void closeConnection() throws IOException {
124124
}
125125

126126
protected void stopSecondary() throws IOException {
127-
Host.executeCommand("cd ../rabbitmq-test; make stop-secondary-app");
127+
Host.invokeMakeTarget("stop-secondary-app");
128128
}
129129

130130
protected void startSecondary() throws IOException {
131-
Host.executeCommand("cd ../rabbitmq-test; make start-secondary-app");
131+
Host.invokeMakeTarget("start-secondary-app");
132132
}
133133
}

test/src/com/rabbitmq/client/test/server/DeadLetterExchangeDurable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public void testDeadLetterQueueTTLExpiredWhileDown() throws Exception {
3939
}
4040

4141
closeConnection();
42-
Host.executeCommand("cd ../rabbitmq-test; make stop-app");
42+
Host.invokeMakeTarget("stop-app");
4343
Thread.sleep(5000);
44-
Host.executeCommand("cd ../rabbitmq-test; make start-app");
44+
Host.invokeMakeTarget("start-app");
4545
openConnection();
4646
openChannel();
4747

test/src/com/rabbitmq/client/test/server/DurableBindingLifecycle.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ protected void restart() throws IOException {
4444
alternateConnection = null;
4545
alternateChannel = null;
4646

47-
Host.executeCommand("cd ../rabbitmq-test; make restart-secondary-node");
47+
Host.invokeMakeTarget("restart-secondary-node");
4848
}
4949
restartPrimary();
5050
}
5151

5252
private void restartPrimary() throws IOException {
5353
tearDown();
54-
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
54+
bareRestart();
5555
setUp();
5656
}
5757

test/src/com/rabbitmq/client/test/server/ExclusiveQueueDurability.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void testConnectionQueueSameNode() throws Exception {
5151
private void restartPrimaryAbruptly() throws IOException {
5252
connection = null;
5353
channel = null;
54-
Host.executeCommand("cd ../rabbitmq-test; make restart-app");
54+
bareRestart();
5555
setUp();
5656
}
5757

test/src/com/rabbitmq/client/test/server/HATests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static TestSuite suite() {
4040
public static class SetUp extends TestCase {
4141
@Override
4242
protected void setUp() throws Exception {
43-
Host.executeCommand("cd ../rabbitmq-test; make enable-ha");
43+
Host.invokeMakeTarget("enable-ha");
4444
HA_TESTS_RUNNING = true;
4545
}
4646

@@ -50,7 +50,7 @@ public void testNothing() {}
5050
public static class TearDown extends TestCase {
5151
@Override
5252
protected void tearDown() throws Exception {
53-
Host.executeCommand("cd ../rabbitmq-test; make disable-ha");
53+
Host.invokeMakeTarget("disable-ha");
5454
HA_TESTS_RUNNING = false;
5555
}
5656

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,24 @@ public static Process rabbitmqctlIgnoreErrors(String command) throws IOException
100100
return executeCommandIgnoringErrors("../rabbitmq-server/scripts/rabbitmqctl " + command);
101101
}
102102

103+
public static Process invokeMakeTarget(String command) throws IOException {
104+
return executeCommand("cd ../rabbitmq-test; " + makeCommand() + " " + command);
105+
}
106+
107+
private static String makeCommand()
108+
{
109+
// Get the make(1) executable to use from the environment:
110+
// make(1) provides the path to itself in $MAKE.
111+
String makecmd = System.getenv("MAKE");
112+
113+
// Default to "make" if the environment variable is unset.
114+
if (makecmd == null) {
115+
makecmd = "make";
116+
}
117+
118+
return makecmd;
119+
}
120+
103121
public static void closeConnection(String pid) throws IOException {
104122
rabbitmqctl("close_connection '" + pid + "' 'Closed via rabbitmqctl'");
105123
}

0 commit comments

Comments
 (0)