use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class UpdateRequestsQueue method waitUntilRefreshed.
@TestOnly
public void waitUntilRefreshed() {
while (true) {
final Semaphore semaphore = new Semaphore();
synchronized (myLock) {
if (!myRequestSubmitted && !myRequestRunning) {
return;
}
if (!myRequestRunning) {
myFuture.set(myExecutor.submit(new MyRunnable()));
}
semaphore.down();
myWaitingUpdateCompletionSemaphores.add(semaphore);
}
if (!semaphore.waitFor(100 * 1000)) {
LOG.error("Too long VCS update");
return;
}
}
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class VfsRootAccess method allowRootAccess.
@TestOnly
public static void allowRootAccess(@NotNull Disposable disposable, @NotNull final String... roots) {
if (roots.length == 0)
return;
allowRootAccess(roots);
Disposer.register(disposable, new Disposable() {
@Override
public void dispose() {
disallowRootAccess(roots);
}
});
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class VfsRootAccess method assertAccessInTests.
@TestOnly
static void assertAccessInTests(@NotNull VirtualFileSystemEntry child, @NotNull NewVirtualFileSystem delegate) {
final Application application = ApplicationManager.getApplication();
if (SHOULD_PERFORM_ACCESS_CHECK && application.isUnitTestMode() && application instanceof ApplicationImpl && ((ApplicationImpl) application).isComponentsCreated() && !ApplicationInfoImpl.isInStressTest()) {
if (delegate != LocalFileSystem.getInstance() && delegate != JarFileSystem.getInstance()) {
return;
}
// root' children are loaded always
if (child.getParent() == null || child.getParent().getParent() == null) {
return;
}
Set<String> allowed = ApplicationManager.getApplication().runReadAction(new Computable<Set<String>>() {
@Override
public Set<String> compute() {
return allowedRoots();
}
});
boolean isUnder = allowed == null || allowed.isEmpty();
if (!isUnder) {
String childPath = child.getPath();
if (delegate == JarFileSystem.getInstance()) {
VirtualFile local = JarFileSystem.getInstance().getVirtualFileForJar(child);
assert local != null : child;
childPath = local.getPath();
}
for (String root : allowed) {
if (FileUtil.startsWith(childPath, root)) {
isUnder = true;
break;
}
if (root.startsWith(JarFileSystem.PROTOCOL_PREFIX)) {
String rootLocalPath = FileUtil.toSystemIndependentName(PathUtil.toPresentableUrl(root));
isUnder = FileUtil.startsWith(childPath, rootLocalPath);
if (isUnder)
break;
}
}
}
assert isUnder : "File accessed outside allowed roots: " + child + ";\nAllowed roots: " + new ArrayList<>(allowed);
}
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class NativeFileWatcherImpl method shutdown.
@Override
@TestOnly
public void shutdown() throws InterruptedException {
Application app = ApplicationManager.getApplication();
assert app != null && app.isUnitTestMode() : app;
MyProcessHandler processHandler = myProcessHandler;
if (processHandler != null) {
myIsShuttingDown = true;
shutdownProcess();
long t = System.currentTimeMillis();
while (!processHandler.isProcessTerminated()) {
if ((System.currentTimeMillis() - t) > 5000) {
throw new InterruptedException("Timed out waiting watcher process to terminate");
}
TimeoutUtil.sleep(100);
}
}
}
use of org.jetbrains.annotations.TestOnly in project intellij-community by JetBrains.
the class NativeFileWatcherImpl method startup.
@Override
@TestOnly
public void startup() throws IOException {
Application app = ApplicationManager.getApplication();
assert app != null && app.isUnitTestMode() : app;
myIsShuttingDown = false;
myStartAttemptCount = 0;
startupProcess(false);
}
Aggregations