From bf95b80b0543269677655d558765c2288f640a97 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Fri, 31 Oct 2014 18:14:51 -0400 Subject: [PATCH] Fix Autotools UI SWTBot tests - force tests to be run in file order by requesting alphabetic order and renaming tests to they alphabetic equals file order - fix configuration test which looks for C/C++ Build page from properties by looking for it in the properties search text box - put configuration tests last in suite Change-Id: I21b943c2a6691f9277bc8cc712684f2bc1fd2db4 Reviewed-on: https://git.eclipse.org/r/35767 Tested-by: Hudson CI Reviewed-by: Marc Khouzam Tested-by: Marc Khouzam --- .../cdt/autotools/ui/tests/AbstractTest.java | 2 ++ .../cdt/autotools/ui/tests/AllTests.java | 8 +++--- .../ui/tests/SetConfigurationParameter.java | 18 +++++++++---- .../ui/tests/TestEnvironmentVars.java | 9 ++++--- .../autotools/ui/tests/TestMakeTargets.java | 5 +++- .../autotools/ui/tests/TestToolActions.java | 27 ++++++++++--------- 6 files changed, 44 insertions(+), 25 deletions(-) diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java index 155fbc44a9b..8fc60c56b2b 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AbstractTest.java @@ -61,7 +61,9 @@ public abstract class AbstractTest { public static void init(String projectName) throws Exception { SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; + SWTBotPreferences.PLAYBACK_DELAY = 10; bot = new SWTWorkbenchBot(); + bot.sleep(5000); mainShell = null; for (int i = 0, attempts = 100; i < attempts; i++) { for (SWTBotShell shell : bot.shells()) { diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java index d5143ea62f6..ec804247016 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AllTests.java @@ -21,10 +21,10 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ - SetConfigurationParameter.class, - TestToolActions.class, - TestEnvironmentVars.class, - TestMakeTargets.class + TestToolActions.class, + TestEnvironmentVars.class, + TestMakeTargets.class, + SetConfigurationParameter.class }) public class AllTests { diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java index b7e02b08dda..000bacf8451 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java @@ -22,6 +22,7 @@ import java.util.regex.Pattern; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import org.eclipse.cdt.autotools.ui.tests.AbstractTest.NodeAvailableAndSelect; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; @@ -34,8 +35,10 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; @@ -43,6 +46,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class SetConfigurationParameter extends AbstractTest { @BeforeClass @@ -96,7 +100,7 @@ public class SetConfigurationParameter extends AbstractTest { // Verify we can set a configuration parameter and that it is recorded in // the .autotools file for the project @Test - public void canSetConfigParm() throws Exception { + public void t1canSetConfigParm() throws Exception { IProject project = checkProject(); assertTrue(project != null); IPath path = project.getLocation(); @@ -137,7 +141,7 @@ public class SetConfigurationParameter extends AbstractTest { // Verify we can build the project with a configuration parameter and that // the configuration parameter can be found in the config.status file. @Test - public void canBuildWithConfigParm() throws Exception { + public void t2canBuildWithConfigParm() throws Exception { projectExplorer.bot().tree().select(projectName); clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); @@ -217,7 +221,7 @@ public class SetConfigurationParameter extends AbstractTest { // Verify a new configuration will copy the configuration parameters // of its base configuration. @Test - public void newConfigCopiesParms() throws Exception { + public void t3newConfigCopiesParms() throws Exception { projectExplorer.bot().tree().select(projectName); clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); @@ -249,6 +253,10 @@ public class SetConfigurationParameter extends AbstractTest { assertEquals("--enable-jeff", val); // Verify that the build directory for the new configuration has been // switched to build-debug + shell = bot.shell("Properties for " + projectName); + shell.activate(); + bot.text().setText(""); + bot.tree().select("C/C++ Build"); String buildDir = bot.textWithLabel("Build directory:").getText(); assertTrue(buildDir.endsWith("build-debug")); @@ -368,7 +376,7 @@ public class SetConfigurationParameter extends AbstractTest { // configuration to // another and then cancel without changing configuration settings. @Test - public void doubleRenameCancel() throws Exception { + public void t4doubleRenameCancel() throws Exception { openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); @@ -423,7 +431,7 @@ public class SetConfigurationParameter extends AbstractTest { // configuration to // another and inheriting the settings properly. @Test - public void doubleRenameOk() throws Exception { + public void t5doubleRenameOk() throws Exception { openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java index d53f70fd9e7..dbde06d6511 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java @@ -25,10 +25,13 @@ import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestEnvironmentVars extends AbstractTest { @BeforeClass @@ -40,7 +43,7 @@ public class TestEnvironmentVars extends AbstractTest { // nulled out // Verifies fix for Bug: #303616 @Test - public void referenceUnknownEnvVar() throws Exception { + public void t1referenceUnknownEnvVar() throws Exception { SWTBotShell shell = openProperties("Autotools", "Configure Settings"); // Set the configure parameters to be --enable-jeff via user-defined // options @@ -80,7 +83,7 @@ public class TestEnvironmentVars extends AbstractTest { // Verify we can set an environment variable and use it as a configure // parameter // Verifies fix for Bug: #303616 - public void setEnvVar() throws Exception { + private void setEnvVar() throws Exception { openProperties("C/C++ Build", "Environment"); bot.button("Add...").click(); SWTBotShell shell = bot.shell("New variable"); @@ -124,7 +127,7 @@ public class TestEnvironmentVars extends AbstractTest { // Verify we can set an environment variable prior to the configuration // command and // it will be seen by the configure script - public void setEnvVarOnCommandLine() throws Exception { + private void setEnvVarOnCommandLine() throws Exception { IPath path = checkProject().getLocation(); // Create a fake configure script which prints out the values of // envvars some_var1, some_var2, and some_var3 diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java index 266a41c6bb2..892af6c115e 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java @@ -26,10 +26,13 @@ import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMakeTargets extends AbstractTest { @BeforeClass @@ -39,7 +42,7 @@ public class TestMakeTargets extends AbstractTest { @Test // Verify we can build and run the info MakeTarget tool - public void canBuildAndAccessInfoTarget() throws Exception { + public void t1canBuildAndAccessInfoTarget() throws Exception { clickProjectContextMenu("Build Project"); // Wait until the project is built diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java index 967b325bfeb..7e4cb49e981 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java @@ -21,20 +21,23 @@ import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; @RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestToolActions extends AbstractTest { @BeforeClass public static void beforeClass() throws Exception { - AbstractTest.init("GnuProject1"); + AbstractTest.init("GnuProject4"); } @Test // Verify we can set the tools via the Autotools Tools page - public void canSeeTools() throws Exception { + public void t1canSeeTools() throws Exception { openProperties("Autotools", "General"); bot.tabItem("Tools Settings").activate(); String aclocalName = bot.textWithLabel("aclocal").getText(); @@ -54,7 +57,7 @@ public class TestToolActions extends AbstractTest { // Verify we can access the aclocal tool @Test - public void canAccessAclocal() throws Exception { + public void t2canAccessAclocal() throws Exception { IPath path = checkProject().getLocation(); // Verify configure does not exist initially path = path.append("aclocal.m4"); @@ -108,7 +111,7 @@ public class TestToolActions extends AbstractTest { // Verify we can access the autoconf tool @Test - public void canAccessAutoconf() throws Exception { + public void t3canAccessAutoconf() throws Exception { IPath path = checkProject().getLocation(); // Verify configure does not exist initially path = path.append("configure"); @@ -171,7 +174,7 @@ public class TestToolActions extends AbstractTest { // Verify we can access the automake tool @Test - public void canAccessAutomake() throws Exception { + public void t4canAccessAutomake() throws Exception { IPath path = checkProject().getLocation(); // Verify configure does not exist initially IPath path2 = path.append("src/Makefile.in"); @@ -242,7 +245,7 @@ public class TestToolActions extends AbstractTest { // Verify we can access the libtoolize tool @Test - public void canAccessLibtoolize() throws Exception { + public void t5canAccessLibtoolize() throws Exception { clickProjectContextMenu("Invoke Autotools", "Invoke Libtoolize"); SWTBotShell shell = bot.shell("Libtoolize Options"); shell.activate(); @@ -261,13 +264,13 @@ public class TestToolActions extends AbstractTest { // Verify we can access the libtoolize tool @Test - public void canAccessAutoheader() throws Exception { + public void t6canAccessAutoheader() throws Exception { clickProjectContextMenu("Invoke Autotools", "Invoke Autoheader"); SWTBotShell shell = bot.shell("Autoheader Options"); shell.activate(); bot.text(0).typeText("--help"); bot.button("OK").click(); - bot.sleep(1000); + bot.sleep(2000); SWTBotView consoleView = bot.viewByPartName("Console"); consoleView.setFocus(); String output = consoleView.bot().styledText().getText(); @@ -280,7 +283,7 @@ public class TestToolActions extends AbstractTest { // Verify we can access the autoreconf tool @Test - public void canAccessAutoreconf() throws Exception { + public void t7canAccessAutoreconf() throws Exception { IPath path = checkProject().getLocation(); // Remove a number of generated files File f = new File(path.append("src/Makefile.in").toOSString()); @@ -339,7 +342,7 @@ public class TestToolActions extends AbstractTest { } @Test - public void canReconfigureProject() throws Exception { + public void t8canReconfigureProject() throws Exception { IPath path = checkProject().getLocation(); // Remove a number of generated files File f = new File(path.append("src/Makefile.in").toOSString()); @@ -389,7 +392,7 @@ public class TestToolActions extends AbstractTest { // Verify we can set and reset the tools via the Autotools Tools page // Verifies bug #317345 @Test - public void canResetTools() throws Exception { + public void t9canResetTools() throws Exception { openProperties("Autotools", "General"); bot.tabItem("Tools Settings").activate(); bot.textWithLabel("aclocal").setText(""); @@ -435,7 +438,7 @@ public class TestToolActions extends AbstractTest { // Verify we can set the tools via the Autotools Tools page @Test - public void canSetTools() throws Exception { + public void u1canSetTools() throws Exception { openProperties("Autotools", "General"); bot.tabItem("Tools Settings").activate(); bot.textWithLabel("aclocal").setText("");