1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-03 14:25:37 +02:00

Fix flaky test testPersistentProperties

Don't sleep for a hardcoded time but wait for the actual condition.
1000 ms was often insufficient on my system.
This commit is contained in:
Christian Walther 2022-08-18 16:39:44 +02:00 committed by Jonah Graham
parent ccdd9b2c99
commit 5f3cd7ac20

View file

@ -202,7 +202,6 @@ public class CProjectDescriptionSerializationTests extends TestCase {
coreModel.setProjectDescription(project, des);
Assert.assertEquals(project, des.getProject());
Thread.sleep(1000); // let scanner discovery participate
try {
QualifiedName pdomName = new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomName");
QualifiedName activeCfg = new QualifiedName(CCorePlugin.PLUGIN_ID, "activeConfiguration");
@ -210,6 +209,13 @@ public class CProjectDescriptionSerializationTests extends TestCase {
QualifiedName discoveredScannerConfigFileName = new QualifiedName(MakeCorePlugin.PLUGIN_ID,
"discoveredScannerConfigFileName");
// pdomName is set by indexer setup, which may still be postponed or not even
// scheduled yet, so we can't join the job. Just wait for the property to appear.
// (The other properties were set synchronously in setProjectDescription().)
for (int i = 0; i < 100 && !project.getPersistentProperties().containsKey(pdomName); i++) {
Thread.sleep(100);
}
assertTrue("pdomName", project.getPersistentProperties().containsKey(pdomName));
assertTrue("activeCfg", project.getPersistentProperties().containsKey(activeCfg));
assertTrue("discoveredScannerConfigFileName",