forked from eclipse-platform/eclipse.platform.ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't run the automatic registration during test execution
If the IDE is running because we are executing automated tests it doesn't make sense to run this registration job. Fixes : eclipse-platform#2245
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/JUnitTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 SAP SE. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Matthias Becker / Sebastian Ratz - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.ui.internal.ide.application; | ||
|
||
import java.util.Set; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.core.runtime.ServiceCaller; | ||
import org.eclipse.osgi.service.environment.EnvironmentInfo; | ||
|
||
public class JUnitTestUtil { | ||
private static Boolean cachedIsJunitTestRunning = null; | ||
|
||
public static boolean isJunitTestRunning() { | ||
if (cachedIsJunitTestRunning == null) { | ||
try { | ||
if (Platform.isRunning()) { | ||
AtomicBoolean result = new AtomicBoolean(); | ||
cachedIsJunitTestRunning = ServiceCaller.callOnce(JUnitTestUtil.class, EnvironmentInfo.class, envInfo -> { | ||
String application = envInfo.getProperty("eclipse.application"); //$NON-NLS-1$ | ||
result.set(application != null && Set.of( // | ||
// see org.eclipse.pde.internal.launching.IPDEConstants | ||
"org.eclipse.pde.junit.runtime.nonuithreadtestapplication", // //$NON-NLS-1$ | ||
"org.eclipse.pde.junit.runtime.uitestapplication", // //$NON-NLS-1$ | ||
"org.eclipse.pde.junit.runtime.coretestapplication", // //$NON-NLS-1$ | ||
// see org.eclipse.tycho.surefire.AbstractTestMojo | ||
"org.eclipse.tycho.surefire.osgibooter.uitest", //$NON-NLS-1$ | ||
"org.eclipse.tycho.surefire.osgibooter.headlesstest") // //$NON-NLS-1$ | ||
.contains(application)); | ||
}); | ||
cachedIsJunitTestRunning = result.get(); | ||
} else { | ||
cachedIsJunitTestRunning = true; // probably | ||
} | ||
} catch (Throwable t) { | ||
// log | ||
cachedIsJunitTestRunning = false; | ||
} | ||
} | ||
|
||
return cachedIsJunitTestRunning; | ||
} | ||
|
||
} |