-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
25ab926
commit 9e43b96
Showing
34 changed files
with
476 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...src/main/java/io/quarkus/deployment/dev/testing/ContinuousTestingSharedStateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.quarkus.deployment.dev.testing; | ||
|
||
import java.util.function.Consumer; | ||
|
||
import io.quarkus.dev.testing.ContinuousTestingSharedStateManager; | ||
|
||
public class ContinuousTestingSharedStateListener implements TestListener { | ||
|
||
private volatile ContinuousTestingSharedStateManager.State lastState; | ||
|
||
@Override | ||
public void listenerRegistered(TestController testController) { | ||
|
||
} | ||
|
||
@Override | ||
public void testsEnabled() { | ||
if (lastState == null) { | ||
ContinuousTestingSharedStateManager | ||
.setLastState(new ContinuousTestingSharedStateManager.State( | ||
ContinuousTestingSharedStateManager.getLastState().lastRun, true, false, | ||
0, 0, 0, 0, | ||
0, 0, 0, ContinuousTestingSharedStateManager.getLastState().isBrokenOnly, | ||
ContinuousTestingSharedStateManager.getLastState().isTestOutput, | ||
ContinuousTestingSharedStateManager.getLastState().isInstrumentationBasedReload, | ||
ContinuousTestingSharedStateManager.getLastState().isLiveReload)); | ||
} else { | ||
ContinuousTestingSharedStateManager | ||
.setLastState(lastState); | ||
} | ||
} | ||
|
||
@Override | ||
public void testsDisabled() { | ||
ContinuousTestingSharedStateManager.setRunning(false); | ||
} | ||
|
||
@Override | ||
public void testRunStarted(Consumer<TestRunListener> listenerConsumer) { | ||
ContinuousTestingSharedStateManager.setInProgress(true); | ||
listenerConsumer.accept(new TestRunListener() { | ||
|
||
@Override | ||
public void runComplete(TestRunResults testRunResults) { | ||
lastState = new ContinuousTestingSharedStateManager.State(testRunResults.getId(), true, false, | ||
testRunResults.getPassedCount() + | ||
testRunResults.getFailedCount() + | ||
testRunResults.getSkippedCount(), | ||
testRunResults.getPassedCount(), | ||
testRunResults.getFailedCount(), testRunResults.getSkippedCount(), | ||
testRunResults.getCurrentPassedCount(), testRunResults.getCurrentFailedCount(), | ||
testRunResults.getCurrentSkippedCount(), | ||
ContinuousTestingSharedStateManager.getLastState().isBrokenOnly, | ||
ContinuousTestingSharedStateManager.getLastState().isTestOutput, | ||
ContinuousTestingSharedStateManager.getLastState().isInstrumentationBasedReload, | ||
ContinuousTestingSharedStateManager.getLastState().isLiveReload); | ||
ContinuousTestingSharedStateManager.setLastState(lastState); | ||
} | ||
|
||
@Override | ||
public void noTests(TestRunResults results) { | ||
runComplete(results); | ||
} | ||
|
||
@Override | ||
public void runAborted() { | ||
ContinuousTestingSharedStateManager.setInProgress(false); | ||
} | ||
}); | ||
|
||
} | ||
|
||
@Override | ||
public void setBrokenOnly(boolean bo) { | ||
ContinuousTestingSharedStateManager.setBrokenOnly(bo); | ||
} | ||
|
||
@Override | ||
public void setTestOutput(boolean to) { | ||
ContinuousTestingSharedStateManager.setTestOutput(to); | ||
} | ||
|
||
@Override | ||
public void setInstrumentationBasedReload(boolean ibr) { | ||
ContinuousTestingSharedStateManager.setInstrumentationBasedReload(ibr); | ||
} | ||
|
||
@Override | ||
public void setLiveReloadEnabled(boolean lre) { | ||
ContinuousTestingSharedStateManager.setLiveReloadEnabled(lre); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
...devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingSharedStateManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
package io.quarkus.dev.testing; | ||
|
||
import java.util.concurrent.CopyOnWriteArraySet; | ||
import java.util.function.Consumer; | ||
|
||
public class ContinuousTestingSharedStateManager { | ||
|
||
private static final CopyOnWriteArraySet<Consumer<State>> stateListeners = new CopyOnWriteArraySet<>(); | ||
public static final State INITIAL_STATE = new State(-1, false, false, 0, 0, 0, 0, 0, 0, 0, false, false, false, true); | ||
private static volatile State lastState = INITIAL_STATE; | ||
|
||
public static void addStateListener(Consumer<State> stateListener) { | ||
stateListeners.add(stateListener); | ||
if (lastState != null) { | ||
stateListener.accept(lastState); | ||
} | ||
} | ||
|
||
public static void removeStateListener(Consumer<State> stateListener) { | ||
stateListeners.remove(stateListener); | ||
} | ||
|
||
public static void reset() { | ||
setLastState(INITIAL_STATE); | ||
} | ||
|
||
public static void setLastState(State state) { | ||
lastState = state; | ||
for (var sl : stateListeners) { | ||
sl.accept(state); | ||
} | ||
} | ||
|
||
public static State getLastState() { | ||
return lastState; | ||
} | ||
|
||
public static void setInProgress(boolean inProgress) { | ||
State state = lastState; | ||
if (state != null) { | ||
setLastState( | ||
new State(state.lastRun, state.running, inProgress, state.run, state.passed, state.failed, state.skipped, | ||
state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, | ||
state.isTestOutput, state.isInstrumentationBasedReload, state.isLiveReload)); | ||
} | ||
} | ||
|
||
public static void setRunning(boolean running) { | ||
State state = lastState; | ||
if (state != null) { | ||
setLastState(new State(state.lastRun, running, running && state.inProgress, state.run, state.passed, state.failed, | ||
state.skipped, | ||
state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, state.isTestOutput, | ||
state.isInstrumentationBasedReload, state.isLiveReload)); | ||
} | ||
} | ||
|
||
public static void setBrokenOnly(boolean brokenOnly) { | ||
State state = lastState; | ||
if (state != null) { | ||
setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, | ||
state.skipped, | ||
state.currentPassed, state.currentFailed, state.currentSkipped, brokenOnly, state.isTestOutput, | ||
state.isInstrumentationBasedReload, state.isLiveReload)); | ||
} | ||
} | ||
|
||
public static void setTestOutput(boolean testOutput) { | ||
State state = lastState; | ||
if (state != null) { | ||
setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, | ||
state.skipped, | ||
state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, testOutput, | ||
state.isInstrumentationBasedReload, state.isLiveReload)); | ||
} | ||
} | ||
|
||
public static void setInstrumentationBasedReload(boolean instrumentationBasedReload) { | ||
State state = lastState; | ||
if (state != null) { | ||
setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, | ||
state.skipped, | ||
state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, state.isTestOutput, | ||
instrumentationBasedReload, state.isLiveReload)); | ||
} | ||
} | ||
|
||
public static void setLiveReloadEnabled(boolean liveReload) { | ||
State state = lastState; | ||
if (state != null) { | ||
setLastState(new State(state.lastRun, state.running, state.inProgress, state.run, state.passed, state.failed, | ||
state.skipped, | ||
state.currentPassed, state.currentFailed, state.currentSkipped, state.isBrokenOnly, state.isTestOutput, | ||
state.isInstrumentationBasedReload, liveReload)); | ||
} | ||
} | ||
|
||
public static class State { | ||
public final long lastRun; | ||
public final boolean running; | ||
public final boolean inProgress; | ||
public final long run; | ||
public final long passed; | ||
public final long failed; | ||
public final long skipped; | ||
public final long currentPassed; | ||
public final long currentFailed; | ||
public final long currentSkipped; | ||
public final boolean isBrokenOnly; | ||
public final boolean isTestOutput; | ||
public final boolean isInstrumentationBasedReload; | ||
public final boolean isLiveReload; | ||
|
||
public State(long lastRun, boolean running, boolean inProgress, long run, long passed, long failed, long skipped, | ||
long currentPassed, long currentFailed, long currentSkipped, boolean isBrokenOnly, boolean isTestOutput, | ||
boolean isInstrumentationBasedReload, boolean isLiveReload) { | ||
this.lastRun = lastRun; | ||
this.running = running; | ||
this.inProgress = inProgress; | ||
this.run = run; | ||
this.passed = passed; | ||
this.failed = failed; | ||
this.skipped = skipped; | ||
this.currentPassed = currentPassed; | ||
this.currentFailed = currentFailed; | ||
this.currentSkipped = currentSkipped; | ||
this.isBrokenOnly = isBrokenOnly; | ||
this.isTestOutput = isTestOutput; | ||
this.isInstrumentationBasedReload = isInstrumentationBasedReload; | ||
this.isLiveReload = isLiveReload; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "State{" + | ||
"lastRun=" + lastRun + | ||
", running=" + running + | ||
", inProgress=" + inProgress + | ||
", run=" + run + | ||
", passed=" + passed + | ||
", failed=" + failed + | ||
", skipped=" + skipped + | ||
", isBrokenOnly=" + isBrokenOnly + | ||
", isTestOutput=" + isTestOutput + | ||
", isInstrumentationBasedReload=" + isInstrumentationBasedReload + | ||
", isLiveReload=" + isLiveReload + | ||
'}'; | ||
} | ||
} | ||
} |
108 changes: 0 additions & 108 deletions
108
.../devmode-spi/src/main/java/io/quarkus/dev/testing/ContinuousTestingWebsocketListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.