Skip to main content
summaryrefslogtreecommitdiffstats
path: root/qt
diff options
context:
space:
mode:
authorAlena Laskavaia2014-12-01 11:21:03 -0500
committerElena Laskavaia2014-12-01 16:58:28 -0500
commit1e517e23e45c19d5601d62d6b66d26b5cae4665d (patch)
treea29afd059ab58742cff511229a7478581b7c8e61 /qt
parent351f1b86a4d04bff792fd4a36505ae2e03bd6625 (diff)
downloadorg.eclipse.cdt-1e517e23e45c19d5601d62d6b66d26b5cae4665d.tar.gz
org.eclipse.cdt-1e517e23e45c19d5601d62d6b66d26b5cae4665d.tar.xz
org.eclipse.cdt-1e517e23e45c19d5601d62d6b66d26b5cae4665d.zip
another attempt to fix race condition in Qt tests
after tests were fixed found funny bug that was there forever test was creating incorrect header file because our comment extractor takes comment from first occurence of function name, it is not actual java parser. Because indexer was not running test was passing. Change-Id: Ib0cea722e6c9766949d07b629ef7a9197529ef45 Signed-off-by: Alena Laskavaia <elaskavaia.cdt@gmail.com> Reviewed-on: https://git.eclipse.org/r/37410 Tested-by: Hudson CI
Diffstat (limited to 'qt')
-rw-r--r--qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java32
-rw-r--r--qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QmlRegistrationTests.java1
-rw-r--r--qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QtIndexTests.java20
3 files changed, 38 insertions, 15 deletions
diff --git a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java
index fd7210bf17..1eff209069 100644
--- a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java
+++ b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/BaseQtTestCase.java
@@ -7,6 +7,7 @@
*/
package org.eclipse.cdt.qt.tests;
+import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.index.IIndex;
@@ -18,6 +19,11 @@ import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.qt.core.QtNature;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
public class BaseQtTestCase extends BaseTestCase {
@@ -39,15 +45,31 @@ public class BaseQtTestCase extends BaseTestCase {
protected ICProject fCProject;
protected IIndex fIndex;
+ public static ICProject createQtProject(final String projectName, final String binFolderName) throws CoreException {
+ final IWorkspace ws = ResourcesPlugin.getWorkspace();
+ final ICProject newProject[] = new ICProject[1];
+ ws.run(new IWorkspaceRunnable() {
+ @Override
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ICProject cproject = CProjectHelper.createCProject(projectName, binFolderName, IPDOMManager.ID_FAST_INDEXER);
+ if (!cproject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
+ CProjectHelper.addNatureToProject(cproject.getProject(), CCProjectNature.CC_NATURE_ID, null);
+ QtNature.addNature(cproject.getProject(), new NullProgressMonitor());
+ }
+ newProject[0] = cproject;
+ }
+ }, null);
+ return newProject[0];
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
String projectName = "__" + getClass().getSimpleName() + "__";
- fCProject = CProjectHelper.createCCProject(projectName, "bin", IPDOMManager.ID_FAST_INDEXER);
+ fCProject = createQtProject(projectName, "bin");
fProject = fCProject.getProject();
- QtNature.addNature(fProject, new NullProgressMonitor());
fIndex = CCorePlugin.getIndexManager().getIndex(fCProject);
indexQObject_h();
@@ -150,15 +172,17 @@ public class BaseQtTestCase extends BaseTestCase {
// add the new content
fFile = TestSourceReader.createFile(fProject, filename, contents[0]);
+ CCorePlugin.getIndexManager().reindex(fCProject);// just make sure we re-indexing here
// wait for the index to change
Thread.yield();
+ waitForIndexer(fCProject);
for(long stopAt = System.currentTimeMillis() + 3000;
System.currentTimeMillis() < stopAt && timestamp == indexManager.getIndex(fCProject).getLastWriteAccess();
Thread.sleep(100)) {
- /* intentionally empty*/
+ waitForIndexer(fCProject);
}
-
assertNotSame(timestamp, indexManager.getIndex(fCProject).getLastWriteAccess());
+
}
/**
diff --git a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QmlRegistrationTests.java b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QmlRegistrationTests.java
index f75212ff78..bd39de5511 100644
--- a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QmlRegistrationTests.java
+++ b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QmlRegistrationTests.java
@@ -100,7 +100,6 @@ public class QmlRegistrationTests extends BaseQtTestCase {
// }
public void testQmlRegisterFwdDecl() throws Exception {
loadComment("qmlregistertype.hh");
- waitForIndexer(fCProject);
QtIndex qtIndex = QtIndex.getIndex(fProject);
assertNotNull(qtIndex);
diff --git a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QtIndexTests.java b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QtIndexTests.java
index e4fd185258..41a9576f63 100644
--- a/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QtIndexTests.java
+++ b/qt/org.eclipse.cdt.qt.tests/src/org/eclipse/cdt/qt/tests/QtIndexTests.java
@@ -18,6 +18,16 @@ public class QtIndexTests extends BaseQtTestCase {
// class B : public QObject
// {
// Q_OBJECT
+ // Q_PROPERTY(bool allowed READ isAllowed)
+ // };
+ public void changeBDecl() throws Exception {
+ loadComment(Filename_testCache);
+ }
+
+ // #include "junit-QObject.hh"
+ // class B : public QObject
+ // {
+ // Q_OBJECT
// };
public void testLookup() throws Exception {
loadComment(Filename_testCache);
@@ -36,14 +46,4 @@ public class QtIndexTests extends BaseQtTestCase {
assertNotNull(qobj2);
assertEquals("B", qobj2.getName());
}
-
- // #include "junit-QObject.hh"
- // class B : public QObject
- // {
- // Q_OBJECT
- // Q_PROPERTY(bool allowed READ isAllowed())
- // };
- public void changeBDecl() throws Exception {
- loadComment(Filename_testCache);
- }
}

Back to the top