Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle flaky UI tests by waiting for the JDT index #3320

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
--show-version
--update-snapshots
-Dsurefire.rerunFailingTestsCount=5
#-Dsurefire.rerunFailingTestsCount=5
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* Copyright (c) 2023, 2025 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtend.ide.tests.compiler;

import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.core.resources.IFile;
import org.eclipse.xtend.ide.tests.AbstractXtendUITestCase;
import org.eclipse.xtend.ide.tests.WorkbenchTestHelper;
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil;
import org.junit.Test;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;

import com.google.common.io.ByteStreams;
import com.google.inject.Inject;

/**
* @author Christian Dietrich - Initial contribution and API
*/
public class QuickDebugSourceInstallingCompilationParticipantTest extends AbstractXtendUITestCase {
@Inject
private WorkbenchTestHelper workbenchTestHelper;

@Test
public void testIfThereIsAnyStatum() throws Exception {
// ensure JDT is fully functional and its participants registered
workbenchTestHelper.createFile("hello/Hello.java", """
package hello;

public class Hello {
}
""");
IResourcesSetupUtil.waitForBuild();

final IFile source = workbenchTestHelper.createFile("somePackage/Outer.xtend", """
package somePackage

class Outer {
def dosomething() {
println(1)
println(2)
println(3)
}
}
""");
IResourcesSetupUtil.waitForBuild();
final IFile clazz = source.getProject().getFile("bin/somePackage/Outer.class");
assertTrue("bytecode not found", clazz.exists());
final AtomicBoolean debugInfoFound = new AtomicBoolean(false);
try (var in = clazz.getContents()) {
final byte[] bytes = ByteStreams.toByteArray(in);
final ClassReader r = new ClassReader(bytes);
r.accept(new ClassVisitor(Opcodes.ASM9) {
@Override
public void visitSource(final String source, final String debug) {
if ("Outer.java".equals(source)) {
assertEquals("""
SMAP
Outer.java
Xtend
*S Xtend
*F
+ 0 Outer.xtend
somePackage/Outer.xtend
*L
4:8,2
5:10
6:11
7:12
4:13,2
*E
""", debug.replace("\r", ""));
debugInfoFound.set(true);
}
super.visitSource(source, debug);
}
}, 0);
if (!debugInfoFound.get()) {
fail("No source attribute found in bytecode");
}
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Collections;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
Expand Down Expand Up @@ -42,12 +41,12 @@ public void testDisabledProject() throws CoreException {
URI uri = URI.createURI("platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore");
assertNull(descriptions.getResourceDescription(uri));

IProject foo = createPluginProject("foo", false, null);
foo.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
createPluginProject("foo", false, null);
fullBuild();
assertNull(descriptions.getResourceDescription(uri));

createPluginProject("bar", true, "foo");
foo.getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
fullBuild();
assertNotNull(descriptions.getResourceDescription(uri));
}

Expand Down
Loading
Loading