Skip to content

Commit

Permalink
Merge pull request #17035 from stuartwdouglas/pause-live-reload
Browse files Browse the repository at this point in the history
Ability to pause live reload
  • Loading branch information
stuartwdouglas authored May 6, 2021
2 parents 9aee2a0 + 5fb83bc commit 3d04145
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public class RuntimeUpdatesProcessor implements HotReplacementContext, Closeable
private final TestSupport testSupport;
private volatile boolean firstTestScanComplete;
private volatile Boolean instrumentationEnabled;
private volatile boolean liveReloadEnabled = true;

public RuntimeUpdatesProcessor(Path applicationRoot, DevModeContext context, QuarkusCompiler compiler,
DevModeType devModeType, BiConsumer<Set<String>, ClassScanResult> restartCallback,
Expand Down Expand Up @@ -286,6 +287,13 @@ public DevModeType getDevModeType() {

@Override
public boolean doScan(boolean userInitiated) throws IOException {
return doScan(userInitiated, false);
}

public boolean doScan(boolean userInitiated, boolean force) throws IOException {
if (!liveReloadEnabled && !force) {
return false;
}
scanLock.lock();
try {
if (testSupport != null) {
Expand Down Expand Up @@ -888,6 +896,16 @@ public boolean toggleInstrumentation() {
return instrumentationEnabled;
}

public boolean toggleLiveReloadEnabled() {
liveReloadEnabled = !liveReloadEnabled;
if (liveReloadEnabled) {
log.info("Live reload enabled");
} else {
log.info("Live reload disabled");
}
return liveReloadEnabled;
}

static class TimestampSet {
final Map<Path, Long> watchedFileTimestamps = new ConcurrentHashMap<>();
final Map<Path, Long> classFileChangeTimeStamps = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.deployment.dev.testing;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Consumer;
Expand All @@ -8,6 +9,7 @@
import org.junit.platform.engine.TestExecutionResult;
import org.junit.platform.launcher.TestIdentifier;

import io.quarkus.deployment.dev.RuntimeUpdatesProcessor;
import io.quarkus.dev.console.InputHandler;
import io.quarkus.dev.console.QuarkusConsole;

Expand Down Expand Up @@ -60,6 +62,14 @@ public void handleInput(int[] keys) {
printUsage();
} else if (k == 'b') {
testController.toggleBrokenOnlyMode();
} else if (k == 'l') {
RuntimeUpdatesProcessor.INSTANCE.toggleLiveReloadEnabled();
} else if (k == 's') {
try {
RuntimeUpdatesProcessor.INSTANCE.doScan(true, true);
} catch (IOException e) {
log.error("Live reload scan failed", e);
}
}
}
}
Expand All @@ -83,8 +93,10 @@ public void printUsage() {
System.out.println("b - Toggle 'broken only' mode, where only failing tests are run");
System.out.println("v - Print failures from the last test run");
System.out.println("o - Toggle test output");
System.out.println("p - Pause tests");
System.out.println("i - Toggle instrumentation based reload");
System.out.println("d - Disable tests");
System.out.println("l - Toggle live reload");
System.out.println("s - Force live reload scan");
System.out.println("h - Display this help");

}
Expand Down

0 comments on commit 3d04145

Please sign in to comment.