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 GCUtil method tryGcSoftlyReachableObjects.
/**
* Try to force VM to collect soft references if possible.
* Method doesn't guarantee to succeed, and should not be used in the production code.
* Commits / hours optimized method code: 5 / 3
*/
@TestOnly
public static void tryGcSoftlyReachableObjects() {
//long started = System.nanoTime();
ReferenceQueue<Object> q = new ReferenceQueue<Object>();
SoftReference<Object> ref = new SoftReference<Object>(new Object(), q);
ArrayList<SoftReference<?>> list = ContainerUtil.newArrayListWithCapacity(100 + useReference(ref));
System.gc();
final long freeMemory = Runtime.getRuntime().freeMemory();
for (int i = 0; i < 100; i++) {
if (q.poll() != null) {
break;
}
// full gc is caused by allocation of large enough array below, SoftReference will be cleared after two full gc
int bytes = Math.min((int) (freeMemory * 0.45), Integer.MAX_VALUE / 2);
list.add(new SoftReference<Object>(new byte[bytes]));
}
// use ref is important as to loop to finish with several iterations: long runs of the method (~80 run of PsiModificationTrackerTest)
// discovered 'ref' being collected and loop iterated 100 times taking a lot of time
list.ensureCapacity(list.size() + useReference(ref));
// do not leave a chance for our created SoftReference's content to lie around until next full GC's
for (SoftReference createdReference : list) createdReference.clear();
//System.out.println("Done gc'ing refs:" + ((System.nanoTime() - started) / 1000000));
}
use of org.jetbrains.annotations.TestOnly in project kotlin by JetBrains.
the class JSLibraryStdDescription method createNewLibraryForTests.
@TestOnly
public NewLibraryConfiguration createNewLibraryForTests() {
KotlinJsModuleConfigurator configurator = (KotlinJsModuleConfigurator) getConfiguratorByName(NAME);
assert configurator != null : "Cannot find configurator with name " + NAME;
RuntimeLibraryFiles files = configurator.getExistingJarFiles();
return createConfiguration(Collections.singletonList(files.getRuntimeJar()), files.getRuntimeSourcesJar());
}
use of org.jetbrains.annotations.TestOnly in project kotlin by JetBrains.
the class ClassFileFactory method createText.
@NotNull
@TestOnly
public String createText() {
StringBuilder answer = new StringBuilder();
for (OutputFile file : asList()) {
answer.append("@").append(file.getRelativePath()).append('\n');
answer.append(file.asText());
}
return answer.toString();
}
use of org.jetbrains.annotations.TestOnly in project android by JetBrains.
the class GradleWrapper method updateDistributionUrl.
@TestOnly
public void updateDistributionUrl(@NotNull File gradleDistribution) throws IOException {
String path = gradleDistribution.getPath();
if (!extensionEquals(path, "zip")) {
throw new IllegalArgumentException("'" + path + "' should be a zip file");
}
Properties properties = getProperties();
properties.setProperty(DISTRIBUTION_URL_PROPERTY, gradleDistribution.toURI().toURL().toString());
savePropertiesToFile(properties, myPropertiesFilePath, null);
}
Aggregations