Skip to content

Commit

Permalink
attempt clearing the jdt index
Browse files Browse the repository at this point in the history
Seems to work
  • Loading branch information
LorenzoBettini committed Dec 2, 2022
1 parent 5741c2e commit 7377780
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
Expand Up @@ -28,7 +28,9 @@ Require-Bundle: org.eclipse.swtbot.go;bundle-version="2.3.0",
org.eclipse.xtext.ui.testing,
org.eclipse.xtext.testing,
org.slf4j.api;bundle-version="1.7.30",
org.apache.log4j;bundle-version="1.2.19"
org.apache.log4j;bundle-version="1.2.19",
org.eclipse.jdt.core;bundle-version="3.32.0",
org.apache.commons.commons-io;bundle-version="2.11.0"
Bundle-Activator: org.eclipse.emf.parsley.tests.swtbot.activator.EmfParsleySwtBotTestsActivator
Export-Package: org.eclipse.emf.parsley.tests.swtbot,
org.eclipse.emf.parsley.tests.swtbot.editors,
Expand Down
Expand Up @@ -10,7 +10,12 @@
*/
package org.eclipse.emf.parsley.tests.swtbot;

import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.junit.runner.RunWith;

@RunWith(SWTBotJunit4ClassRunner.class)
Expand All @@ -19,6 +24,35 @@ public abstract class EmfParsleyDslUiAbstractTests extends EmfParsleySWTBotAbstr

protected final String TEST_PROJ_NAME_BAD1 = "My-EmfParsley--project";

@Override
public void runAfterEveryTest() throws Exception {
super.runAfterEveryTest();
clearJdtIndex();
}

protected void clearJdtIndex() {
var jdtMetadata = JavaCore.getPlugin().getStateLocation().toFile();
bot.waitUntil(new DefaultCondition() {

@Override
public boolean test() {
System.err.println("Clean up index " + jdtMetadata.getAbsolutePath());
try {
FileUtils.deleteDirectory(jdtMetadata);
} catch (IOException e) {
System.err.println("retrying due to exception while cleaning");
return false;
}
return true;
}

@Override
public String getFailureMessage() {
return "cannot delete " + jdtMetadata;
}
});
}

public void createDslProjectWithWizard() throws Exception {
createProjectWithoutTemplateInWorkspace(EMF_PARSLEY_CATEGORY,
NEW_EMF_PARSLEY_DSL_PROJECT, TEST_PROJ_NAME);
Expand Down
Expand Up @@ -468,7 +468,7 @@ public static void clean() throws CoreException {
}

@After
public void runAfterEveryTest() throws CoreException {
public void runAfterEveryTest() throws Exception {
// bot.sleep(2000);
bot.saveAllEditors();
cleanWorkspace();
Expand Down
Expand Up @@ -54,7 +54,7 @@ public void runBefore() {

@Override
@After
public void runAfterEveryTest() throws CoreException {
public void runAfterEveryTest() throws Exception {
if (treeFormViewOpened)
closeView(TEST_SAVEABLE_TREE_FORM_VIEW);
if (tableFormViewOpened)
Expand Down

0 comments on commit 7377780

Please sign in to comment.