Skip to content

Commit 70e0d6f

Browse files
committed
[sinttest] Move exit status logic into TestRunResult
1 parent 69a9d6f commit 70e0d6f

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

smack-integration-test/src/main/java/org/igniterealtime/smack/inttest/SmackIntegrationTestFramework.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ public static void main(String[] args) throws IOException, KeyManagementExceptio
114114
SmackIntegrationTestFramework sinttest = new SmackIntegrationTestFramework(config);
115115
TestRunResult testRunResult = sinttest.run();
116116

117-
int exitStatus = testRunResult.failedIntegrationTests.isEmpty() ? 0 : 2;
118-
if (config.failOnImpossibleTest && (!testRunResult.impossibleTestClasses.isEmpty() || !testRunResult.impossibleIntegrationTests.isEmpty())) {
119-
exitStatus += 4;
120-
}
121-
System.exit(exitStatus);
117+
System.exit(testRunResult.getExitStatus());
122118
}
123119

124120
public static class JulTestRunResultProcessor implements TestRunResultProcessor {
@@ -214,7 +210,7 @@ public synchronized TestRunResult run()
214210
break;
215211
}
216212

217-
testRunResult = new TestRunResult();
213+
testRunResult = new TestRunResult(config);
218214
sinttestDebugger = config.createSinttestDebugger(testRunResult.testRunStart, testRunResult.testRunId);
219215
// Create a connection manager *after* we created the testRunId (in testRunResult).
220216
this.connectionManager = new XmppConnectionManager(this);
@@ -744,6 +740,8 @@ public static final class TestRunResult {
744740

745741
public final ZonedDateTime testRunStart = ZonedDateTime.now();
746742

743+
private final Configuration config;
744+
747745
private final List<SuccessfulTest> successfulIntegrationTests = Collections.synchronizedList(new ArrayList<SuccessfulTest>());
748746
private final List<FailedTest> failedIntegrationTests = Collections.synchronizedList(new ArrayList<FailedTest>());
749747
private final List<TestNotPossible> impossibleIntegrationTests = Collections.synchronizedList(new ArrayList<TestNotPossible>());
@@ -755,7 +753,8 @@ public static final class TestRunResult {
755753

756754
private final Map<Class<? extends AbstractSmackIntTest>, Throwable> impossibleTestClasses = new HashMap<>();
757755

758-
TestRunResult() {
756+
TestRunResult(Configuration config) {
757+
this.config = config;
759758
}
760759

761760
public String getTestRunId() {
@@ -781,6 +780,15 @@ public List<TestNotPossible> getNotPossibleTests() {
781780
public Map<Class<? extends AbstractSmackIntTest>, Throwable> getImpossibleTestClasses() {
782781
return Collections.unmodifiableMap(impossibleTestClasses);
783782
}
783+
784+
public int getExitStatus() {
785+
int exitStatus = failedIntegrationTests.isEmpty() ? 0 : 2;
786+
if (config.failOnImpossibleTest && (!impossibleTestClasses.isEmpty() || !impossibleIntegrationTests.isEmpty())) {
787+
exitStatus += 4;
788+
}
789+
790+
return exitStatus;
791+
}
784792
}
785793

786794
final class PreparedTest {

smack-integration-test/src/test/java/org/igniterealtime/smack/inttest/DummySmackIntegrationTestFramework.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright 2015-2024 Florian Schmaus
3+
* Copyright 2015-2025 Florian Schmaus
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ public DummySmackIntegrationTestFramework(Configuration configuration) throws Ke
4747
InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
4848
NoSuchAlgorithmException, SmackException, IOException, XMPPException, InterruptedException {
4949
super(configuration);
50-
testRunResult = new TestRunResult();
50+
testRunResult = new TestRunResult(configuration);
5151
}
5252

5353
@Override

0 commit comments

Comments
 (0)