Skip to content

Commit

Permalink
refact: cleanup junit test configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Oct 23, 2024
1 parent 901e2ed commit ca02a1a
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 30 deletions.
3 changes: 1 addition & 2 deletions org.eclipse.tm4e.core.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<classpathentry kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.tm4e.core.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Require-Bundle: org.apache.batik.css;resolution:=optional,
com.google.gson;resolution:=optional,
org.eclipse.core.runtime,
org.eclipse.tm4e.core
Import-Package: org.junit.runner,
org.junit.jupiter.api,org.junit.jupiter.api.function,
Import-Package: org.junit.jupiter.api,
org.junit.jupiter.api.function,
org.w3c.css.sac;resolution:=optional,
org.w3c.css.sac.helpers;resolution:=optional
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.languageconfiguration.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Expand All @@ -11,7 +12,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="maven.pomderived" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.workbench,
org.eclipse.ui.workbench.texteditor,
org.eclipse.tm4e.languageconfiguration,
org.eclipse.tm4e.ui,
org.junit
org.eclipse.tm4e.ui
Bundle-ActivationPolicy: lazy
Import-Package: org.junit.jupiter.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
*/
package org.eclipse.tm4e.languageconfiguration.tests;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.*;

import java.io.ByteArrayInputStream;

Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.tm4e.ui.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Expand All @@ -11,14 +12,13 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<classpathentry kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
Expand Down
12 changes: 5 additions & 7 deletions org.eclipse.tm4e.ui.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ Require-Bundle: org.eclipse.jface.text,
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.editors,
org.eclipse.ui.genericeditor;resolution:=optional,
org.eclipse.ui.genericeditor,
org.eclipse.ui.ide,
org.eclipse.ui.tests.harness,
org.eclipse.tm4e.core,
org.eclipse.tm4e.registry,
org.eclipse.tm4e.ui,
com.google.gson;bundle-version="[2.10.1,3.0.0)",
org.junit,
junit-jupiter-api,
org.opentest4j
org.eclipse.tm4e.ui
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.core.filebuffers
Import-Package: org.junit.jupiter.api,
org.junit.jupiter.api.condition,
org.opentest4j
Automatic-Module-Name: org.eclipse.tm4e.ui.tests
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,31 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;

@DisabledIf("org.eclipse.tm4e.ui.tests.TMPresentationReconcilerTypeScriptTest#isDisabled")
class TMPresentationReconcilerTypeScriptTest {

static boolean isDisabled() {
// TODO ignore these tests on GitHub Actions Windows runner because they are extremely slow (4-5min) for an unknown reason
return TestUtils.isGitHubActions() && System.getProperty("os.name").toLowerCase().contains("windows");
}

private IGrammar grammar;
private ITokenProvider theme;
private TMEditor editor;

@BeforeEach
void setup() throws Exception {
// TODO ignore these tests on GitHub Actions Windows runner because they are extremely slow (4-5min) for an unknown reason
org.junit.Assume.assumeFalse(TestUtils.isGitHubActions() && System.getProperty("os.name").toLowerCase().contains("windows"));

TestUtils.assertNoTM4EThreadsRunning();

grammar = new Registry().addGrammar(IGrammarSource.fromResource(getClass(), "/grammars/TypeScript.tmLanguage.json"));
theme = TMUIPlugin.getThemeManager().getThemeById(ThemeIdConstants.SolarizedLight);
theme = TMUIPlugin.getThemeManager().getThemeById(ThemeIdConstants.SolarizedLight);
}

@AfterEach
void tearDown() throws InterruptedException {
if(editor != null)
if (editor != null)
editor.dispose();

TestUtils.assertNoTM4EThreadsRunning();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.tm4e.core.registry.Registry;
import org.eclipse.tm4e.ui.internal.model.TMDocumentModel;
import org.eclipse.tm4e.ui.tests.support.TestUtils;
import org.junit.function.ThrowingRunnable;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -42,6 +41,10 @@
@TestMethodOrder(MethodOrderer.MethodName.class)
class TMDocumentModelTest {

interface ThrowingRunnable {
void run() throws Throwable;
}

private static final String LF = "\n";
private static IGrammar grammar;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
package org.eclipse.tm4e.ui.tests.internal.utils;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand All @@ -28,8 +28,8 @@
import org.eclipse.ui.editors.text.FileDocumentProvider;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class DocumentInputStreamTest {

Expand All @@ -44,7 +44,7 @@ class DocumentInputStreamTest {
private final IDocumentProvider documentProvider = new FileDocumentProvider();
private IDocument document;

@Before
@BeforeEach
public void setUp() throws CoreException {
final IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.currentTimeMillis());
p.create(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package org.eclipse.tm4e.ui.tests.support;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

import java.io.File;
Expand Down Expand Up @@ -131,7 +130,7 @@ protected boolean condition() {
}
throw new AssertionError(errorMessage, ex.get());
}
assertTrue(errorMessage, isConditionMet);
assertTrue(isConditionMet, errorMessage);
}

public static boolean waitForCondition(final int timeout_ms, final Condition condition) {
Expand Down

0 comments on commit ca02a1a

Please sign in to comment.