From ea791c5e41030b39a5277674adcdb3f50d542bf9 Mon Sep 17 00:00:00 2001 From: Andrii Date: Thu, 27 Nov 2025 12:17:58 +0100 Subject: [PATCH 1/5] ci: idfToolsPath test --- .../IDFProjectToolsInstallationTest.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java new file mode 100644 index 000000000..02820b42d --- /dev/null +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java @@ -0,0 +1,95 @@ +package com.espressif.idf.ui.test.executable.cases.project; + +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.lang3.SystemUtils; +import org.eclipse.core.runtime.IPath; +import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.junit.After; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; + +import com.espressif.idf.core.IDFConstants; +import com.espressif.idf.core.util.IDFUtil; +import com.espressif.idf.ui.test.common.WorkBenchSWTBot; +import com.espressif.idf.ui.test.common.utility.TestWidgetWaitUtility; +import com.espressif.idf.ui.test.operations.EnvSetupOperations; +import com.espressif.idf.ui.test.operations.ProjectTestOperations; + +/** + * Test class to verify tools installation + * + * @author Andrii Filippov + * + */ +@SuppressWarnings("restriction") +@RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class IDFProjectToolsInstallationTest { + @BeforeClass + public static void beforeTestClass() throws Exception { + Fixture.loadEnv(); + } + + @After + public void afterEachTest() { + Fixture.cleanTestEnv(); + } + + @Test + public void givenNewEnvironmentWhenOpenSbomThenSbomIsDisabled() throws Exception { + Fixture.openPreferencesBuildEnvVariables(); + Fixture.verifyToolsPaths(); + } + + private static class Fixture { + private static SWTWorkbenchBot bot; + + private static void loadEnv() throws Exception { + bot = WorkBenchSWTBot.getBot(); + EnvSetupOperations.setupEspressifEnv(bot); + bot.sleep(1000); + } + + private static void cleanTestEnv() { + TestWidgetWaitUtility.waitForOperationsInProgressToFinishAsync(bot); + ProjectTestOperations.closeAllProjects(bot); + ProjectTestOperations.deleteAllProjects(bot); + } + + private static void openPreferencesBuildEnvVariables() throws Exception { + bot.menu("Window").menu("Preferences...").click(); + SWTBotShell preferencesShell = bot.shell("Preferences"); + preferencesShell.bot().tree().getTreeItem("C/C++").select(); + preferencesShell.bot().tree().getTreeItem("C/C++").expand(); + preferencesShell.bot().tree().getTreeItem("C/C++").getNode("Build").select(); + preferencesShell.bot().tree().getTreeItem("C/C++").getNode("Build").expand(); + preferencesShell.bot().tree().getTreeItem("C/C++").getNode("Build").getNode("Environment").select(); + } + + private static void verifyToolsPaths() { + idfToolsPath(); + } + + private static void idfToolsPath() { + bot.table().select("IDF_TOOLS_PATH"); + bot.table().getTableItem("IDF_TOOLS_PATH").doubleClick(); + bot.sleep(1000); + + Path idfToolsPath = Paths.get(System.getProperty("user.home"), ".espressif", IDFConstants.TOOLS_FOLDER); + String actualPath = bot.textWithLabel("Value:").getText(); + assertTrue(actualPath.equals(idfToolsPath.toString())); + } + } +} From 85a4778c4e64e2bdb6df1e9163464f425e3bfca6 Mon Sep 17 00:00:00 2001 From: Andrii Date: Thu, 27 Nov 2025 16:54:08 +0100 Subject: [PATCH 2/5] ci: added OpenOCD/Python/PythonExe --- .../IDFProjectToolsInstallationTest.java | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java index 02820b42d..904b44344 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java @@ -4,7 +4,9 @@ import java.io.File; import java.io.IOException; +import java.nio.file.FileSystems; import java.nio.file.Path; +import java.nio.file.PathMatcher; import java.nio.file.Paths; import org.apache.commons.lang3.SystemUtils; @@ -80,16 +82,79 @@ private static void openPreferencesBuildEnvVariables() throws Exception { private static void verifyToolsPaths() { idfToolsPath(); + closeDialog(); + idfPath(); + closeDialog(); + openOCDScripts(); + closeDialog(); + idfPythonEnvPath(); + closeDialog(); + pythonExePath(); + closeDialog(); } private static void idfToolsPath() { bot.table().select("IDF_TOOLS_PATH"); bot.table().getTableItem("IDF_TOOLS_PATH").doubleClick(); - bot.sleep(1000); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit variable", 5000); Path idfToolsPath = Paths.get(System.getProperty("user.home"), ".espressif", IDFConstants.TOOLS_FOLDER); String actualPath = bot.textWithLabel("Value:").getText(); assertTrue(actualPath.equals(idfToolsPath.toString())); } + + private static void idfPath() { + bot.table().select("IDF_PATH"); + bot.table().getTableItem("IDF_PATH").doubleClick(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit variable", 5000); + + Path idfPath = Paths.get(IDFUtil.getIDFPath()); + String actualPath = bot.textWithLabel("Value:").getText(); + assertTrue(actualPath.equals(idfPath.toString())); + } + + private static void openOCDScripts() { + bot.table().select("OPENOCD_SCRIPTS"); + bot.table().getTableItem("OPENOCD_SCRIPTS").doubleClick(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit variable", 5000); + + String actualPath = bot.textWithLabel("Value:").getText(); + String home = System.getProperty("user.home").replace("\\", "/"); + String pattern = "glob:" + home + "/.espressif/" + IDFConstants.TOOLS_FOLDER + + "/openocd-esp32/*/openocd-esp32/share/openocd/scripts"; + + PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern); + assertTrue(matcher.matches(Paths.get(actualPath))); + } + + private static void idfPythonEnvPath() { + bot.table().select("IDF_PYTHON_ENV_PATH"); + bot.table().getTableItem("IDF_PYTHON_ENV_PATH").doubleClick(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit variable", 5000); + + String actualPath = bot.textWithLabel("Value:").getText(); + String home = System.getProperty("user.home").replace("\\", "/"); + String pattern = "glob:" + home + "/.espressif/" + IDFConstants.TOOLS_FOLDER + "/python/*/venv"; + + PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern); + assertTrue(matcher.matches(Paths.get(actualPath))); + } + + private static void pythonExePath() { + bot.table().select("PYTHON_EXE_PATH"); + bot.table().getTableItem("PYTHON_EXE_PATH").doubleClick(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit variable", 5000); + + String actualPath = bot.textWithLabel("Value:").getText(); + String home = System.getProperty("user.home").replace("\\", "/"); + String pattern = "glob:" + home + "/.espressif/" + IDFConstants.TOOLS_FOLDER + "/python/*/venv/bin/python"; + + PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern); + assertTrue(matcher.matches(Paths.get(actualPath))); + } + + private static void closeDialog() { + bot.button("OK").click(); + } } } From f6236461f3d76a65dd38d7c0efe45079a9427f64 Mon Sep 17 00:00:00 2001 From: Andrii Date: Fri, 28 Nov 2025 13:13:56 +0100 Subject: [PATCH 3/5] ci: added cmake/ninja test --- .../IDFProjectToolsInstallationTest.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java index 904b44344..bcf00f5cc 100644 --- a/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java +++ b/tests/com.espressif.idf.ui.test/src/com/espressif/idf/ui/test/executable/cases/project/IDFProjectToolsInstallationTest.java @@ -91,6 +91,8 @@ private static void verifyToolsPaths() { closeDialog(); pythonExePath(); closeDialog(); + cmakeAndNinjaPath(); + closeDialog(); } private static void idfToolsPath() { @@ -100,7 +102,7 @@ private static void idfToolsPath() { Path idfToolsPath = Paths.get(System.getProperty("user.home"), ".espressif", IDFConstants.TOOLS_FOLDER); String actualPath = bot.textWithLabel("Value:").getText(); - assertTrue(actualPath.equals(idfToolsPath.toString())); + assertTrue("IDF_TOOLS_PATH mismatch", actualPath.equals(idfToolsPath.toString())); } private static void idfPath() { @@ -110,7 +112,7 @@ private static void idfPath() { Path idfPath = Paths.get(IDFUtil.getIDFPath()); String actualPath = bot.textWithLabel("Value:").getText(); - assertTrue(actualPath.equals(idfPath.toString())); + assertTrue("IDF_PATH mismatch", actualPath.equals(idfPath.toString())); } private static void openOCDScripts() { @@ -124,7 +126,7 @@ private static void openOCDScripts() { + "/openocd-esp32/*/openocd-esp32/share/openocd/scripts"; PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern); - assertTrue(matcher.matches(Paths.get(actualPath))); + assertTrue("OPENOCD_SCRIPTS mismatch", matcher.matches(Paths.get(actualPath))); } private static void idfPythonEnvPath() { @@ -137,7 +139,7 @@ private static void idfPythonEnvPath() { String pattern = "glob:" + home + "/.espressif/" + IDFConstants.TOOLS_FOLDER + "/python/*/venv"; PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern); - assertTrue(matcher.matches(Paths.get(actualPath))); + assertTrue("IDF_PYTHON_ENV_PATH mismatch", matcher.matches(Paths.get(actualPath))); } private static void pythonExePath() { @@ -150,7 +152,17 @@ private static void pythonExePath() { String pattern = "glob:" + home + "/.espressif/" + IDFConstants.TOOLS_FOLDER + "/python/*/venv/bin/python"; PathMatcher matcher = FileSystems.getDefault().getPathMatcher(pattern); - assertTrue(matcher.matches(Paths.get(actualPath))); + assertTrue("PYTHON_EXE_PATH mismatch", matcher.matches(Paths.get(actualPath))); + } + + private static void cmakeAndNinjaPath() { + bot.table().select("PATH"); + bot.table().getTableItem("PATH").doubleClick(); + TestWidgetWaitUtility.waitForDialogToAppear(bot, "Edit variable", 5000); + + String actualPath = bot.textWithLabel("Value:").getText(); + assertTrue("cmake not found in the PATH", actualPath.contains("cmake")); + assertTrue("ninja not found in the PATH", actualPath.contains("ninja")); } private static void closeDialog() { From 4843eca0fe93df79439046a4cbce70942295bc54 Mon Sep 17 00:00:00 2001 From: Andrii Date: Fri, 28 Nov 2025 16:33:28 +0100 Subject: [PATCH 4/5] ci: runs SWT on real UI thread --- tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pom.xml b/tests/pom.xml index 550801bd9..bb35bf9dc 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -27,7 +27,7 @@ ${tycho-version} true - false + true org.eclipse.ui.ide.workbench -Xms4096m -Xmx8192m -DtestRun=true From 0892386e4d88cfe78ba947811301cc583be12839 Mon Sep 17 00:00:00 2001 From: Andrii Date: Fri, 28 Nov 2025 17:48:40 +0100 Subject: [PATCH 5/5] ci: explicit runs SWT on real UI thread --- tests/pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/pom.xml b/tests/pom.xml index bb35bf9dc..c805c243d 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -26,9 +26,11 @@ tycho-surefire-plugin ${tycho-version} + org.eclipse.ui.ide.workbench true true - org.eclipse.ui.ide.workbench + + org.eclipse.platform.ide -Xms4096m -Xmx8192m -DtestRun=true ${skipTests}