Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2018-03-28 22:21:21 +0000
committerJeff Johnston2018-03-28 22:29:24 +0000
commit88cc9907cb458356e09ea796210a3f97262d0e5d (patch)
tree05f72d2be89219f6b9161c5b5b1efe4cefcb9038
parentfcbd010b2db517a0e867a9fe2728e5cedb5ee128 (diff)
downloadorg.eclipse.cdt-88cc9907cb458356e09ea796210a3f97262d0e5d.tar.gz
org.eclipse.cdt-88cc9907cb458356e09ea796210a3f97262d0e5d.tar.xz
org.eclipse.cdt-88cc9907cb458356e09ea796210a3f97262d0e5d.zip
Update Meson UI tests
- add new NewManualNinjaTest to test the Run ninja context menu item - add a check that Project->Clean... works for Meson projects in NewMesonProjectTest - fix all tests to substitute the project location instead of hard-coding it - fix the build ninja code to use env to run so that environment variables can be overridden from run ninja dialog - add new test to AutomatedIntegrationSuite for Meson UI tests Change-Id: I0e338df6935f343d6ffbce99a83265d252ea37a6
-rw-r--r--build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java18
-rw-r--r--build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/AutomatedIntegrationSuite.java2
-rw-r--r--build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewManualNinjaTest.java287
-rw-r--r--build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonConfigureTest.java46
-rw-r--r--build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonProjectTest.java67
5 files changed, 384 insertions, 36 deletions
diff --git a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java
index 6accbad4406..6bfa5e865f7 100644
--- a/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java
+++ b/build/org.eclipse.cdt.meson.core/src/org/eclipse/cdt/internal/meson/core/MesonBuildConfiguration.java
@@ -207,9 +207,6 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
}
List<String> envList = new ArrayList<>();
- if (ninjaEnv != null) {
- envList.addAll(Arrays.asList(ninjaEnv));
- }
String[] env = envList.toArray(new String[0]);
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(this);
@@ -221,10 +218,18 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
monitor.subTask(Messages.MesonBuildConfiguration_RunningNinja);
- org.eclipse.core.runtime.Path shPath = new org.eclipse.core.runtime.Path("sh"); //$NON-NLS-1$
+ org.eclipse.core.runtime.Path cmdPath = new org.eclipse.core.runtime.Path("/usr/bin/env"); //$NON-NLS-1$
org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(getBuildDirectory().toString());
List<String> argList = new ArrayList<>();
+
+ if (ninjaEnv != null) {
+ for (String envVar : ninjaEnv) {
+ argList.addAll(MesonUtils.stripEnvVars(envVar));
+ }
+ }
+
+ argList.add("sh"); //$NON-NLS-1$
argList.add("-c"); //$NON-NLS-1$
StringBuilder b = new StringBuilder();
b.append(buildCommand);
@@ -238,7 +243,7 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
}
argList.add(b.toString());
- Process p = launcher.execute(shPath, argList.toArray(new String[0]), env, workingDir, monitor);
+ Process p = launcher.execute(cmdPath, argList.toArray(new String[0]), env, workingDir, monitor);
if (p != null && launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(), SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
String errMsg = launcher.getErrorMessage();
console.getErrorStream().write(String.format(Messages.MesonBuildConfiguration_RunningNinjaFailure, errMsg));
@@ -287,9 +292,10 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
}
String[] command = cleanCommand.split(" "); //$NON-NLS-1$
- IPath cmd = new org.eclipse.core.runtime.Path("sh");
+ IPath cmd = new org.eclipse.core.runtime.Path("/usr/bin/env"); //$NON-NLS-1$
List<String> argList = new ArrayList<>();
+ argList.add("sh"); //$NON-NLS-1$
argList.add("-c"); //$NON-NLS-1$
argList.add(cleanCommand);
diff --git a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/AutomatedIntegrationSuite.java b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/AutomatedIntegrationSuite.java
index 1390f8b3e84..78be328e08e 100644
--- a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/AutomatedIntegrationSuite.java
+++ b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/AutomatedIntegrationSuite.java
@@ -14,7 +14,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses({ NewMesonProjectTest.class, NewMesonConfigureTest.class })
+@Suite.SuiteClasses({ NewMesonProjectTest.class, NewMesonConfigureTest.class, NewManualNinjaTest.class })
public class AutomatedIntegrationSuite {
}
diff --git a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewManualNinjaTest.java b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewManualNinjaTest.java
new file mode 100644
index 00000000000..8197a8ddb0f
--- /dev/null
+++ b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewManualNinjaTest.java
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2017, 2018 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - modified for Meson testing
+ *******************************************************************************/
+package org.eclipse.cdt.internal.meson.ui.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.core.index.IIndexManager;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.internal.meson.ui.tests.utils.CloseWelcomePageRule;
+import org.eclipse.cdt.meson.core.MesonNature;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.epp.logging.aeri.core.ISystemSettings;
+import org.eclipse.epp.logging.aeri.core.SendMode;
+import org.eclipse.epp.logging.aeri.core.SystemControl;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@SuppressWarnings("nls")
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class NewManualNinjaTest {
+
+ private static SWTWorkbenchBot bot;
+
+ @ClassRule
+ public static CloseWelcomePageRule closeWelcomePage = new CloseWelcomePageRule(
+ CloseWelcomePageRule.CDT_PERSPECTIVE_ID);
+
+ @BeforeClass
+ public static void beforeClass() {
+ SWTBotPreferences.TIMEOUT = 50000;
+ SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+ SWTBotPreferences.PLAYBACK_DELAY = 500;
+ bot = new SWTWorkbenchBot();
+ }
+
+ @Before
+ public void before() {
+ ISystemSettings settings = SystemControl.getSystemSettings();
+ settings.setSendMode(SendMode.NEVER);
+ bot.resetWorkbench();
+ }
+
+ @Test(timeout = 120000)
+ public void addNewMesonProject() throws Exception {
+ // open C++ perspective
+ if (!"C/C++".equals(bot.activePerspective().getLabel())) {
+ bot.perspectiveByLabel("C/C++").activate();
+ }
+
+ // Activate C/C++ wizard
+ bot.menu("File").menu("New").menu("C/C++ Project").click();
+ bot.shell("New C/C++ Project").activate();
+
+ // Double click on the template
+ SWTBotTable templateTable = bot.table();
+ bot.getDisplay().syncExec(() -> {
+ for (int i = 0; i < templateTable.rowCount(); ++i) {
+ SWTBotTableItem item = templateTable.getTableItem(i);
+ if ("Meson Project".equals(item.widget.getData(SWTBotPreferences.DEFAULT_KEY))) {
+ item.doubleClick();
+ break;
+ }
+ }
+ });
+
+ // Select the shell again since magic wizardry happened
+ SWTBotShell newProjectShell = bot.shell("New Meson Project").activate();
+ bot.waitUntil(Conditions.shellIsActive("New Meson Project"));
+ newProjectShell.setFocus();
+
+ // Create the project
+ String projectName = "MesonTestProj3";
+ bot.sleep(2000);
+ SWTBotText text = bot.textWithLabel("Project name:");
+ text.setText(projectName);
+ bot.button("Finish").click();
+
+ bot.waitUntil(Conditions.shellCloses(newProjectShell));
+
+ // Make sure it shows up in Project Explorer
+ SWTBotView explorer = bot.viewByPartName("Project Explorer");
+ explorer.show();
+ explorer.setFocus();
+
+ // Make sure the project indexer completes. At that point we're stable.
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ ICProject cproject = CoreModel.getDefault().create(project);
+ IIndexManager indexManager = CCorePlugin.getIndexManager();
+ while (!indexManager.isProjectContentSynced(cproject)) {
+ Thread.sleep(1000);
+ }
+
+ // Make sure it has the right nature
+ assertTrue(project.hasNature(MesonNature.ID));
+ }
+
+ @Test
+ public void buildMesonProject() throws Exception {
+ String projectName = "MesonTestProj3";
+ // Make sure the project indexer completes. At that point we're stable.
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ ICProject cproject = CoreModel.getDefault().create(project);
+
+ IPath projectPath = project.getLocation();
+
+ // open C++ perspective
+ if (!"C/C++".equals(bot.activePerspective().getLabel())) {
+ bot.perspectiveByLabel("C/C++").activate();
+ }
+
+ // Make sure it shows up in Project Explorer
+ SWTBotView explorer = bot.viewByPartName("Project Explorer");
+ explorer.show();
+ explorer.setFocus();
+ SWTBotTreeItem proj = explorer.bot().tree().getTreeItem(projectName).select();
+ proj.contextMenu("Build Project").click();
+
+ // Make sure the project indexer completes. At that point we're stable.
+ IIndexManager indexManager = CCorePlugin.getIndexManager();
+ while (!indexManager.isProjectContentSynced(cproject)) {
+ Thread.sleep(1000);
+ }
+
+ // check the build console output
+ SWTBotView console = bot.viewByPartName("Console");
+ console.show();
+ console.setFocus();
+
+ String[] lines = new String[0];
+
+ while (lines.length < 12) {
+ String output = console.bot().styledText().getText();
+ lines = output.split("\\r?\\n"); //$NON-NLS-1$
+ bot.sleep(2000);
+ }
+
+ bot.sleep(2000);
+
+ assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
+ assertEquals("The Meson build system", lines[2]);
+ assertTrue(lines[3].startsWith("Version:"));
+ assertEquals("Source dir: " + projectPath, lines[4]);
+ assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
+ assertEquals("Build type: native build", lines[6]);
+ assertEquals("Project name: MesonTestProj3", lines[7]);
+ assertTrue(lines[8].startsWith("Native C compiler: cc"));
+ assertEquals("Build complete: " + projectPath + "/build/default", lines[lines.length-1]);
+ }
+
+ @Test
+ public void manualNinja() throws Exception {
+ // check the build console output
+ String projectName = "MesonTestProj3";
+ // Make sure the project indexer completes. At that point we're stable.
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+
+ IPath projectPath = project.getLocation();
+
+ // open C++ perspective
+ if (!"C/C++".equals(bot.activePerspective().getLabel())) {
+ bot.perspectiveByLabel("C/C++").activate();
+ }
+
+ // Make sure it shows up in Project Explorer
+ SWTBotView explorer = bot.viewByPartName("Project Explorer");
+ explorer.show();
+ explorer.setFocus();
+ SWTBotTreeItem proj = explorer.bot().tree().getTreeItem(projectName).select();
+ proj.contextMenu("Run ninja").click();
+
+ bot.sleep(2000);
+
+ SWTBotShell shell = bot.activeShell();
+
+ while (!shell.getText().trim().isEmpty()) {
+ bot.sleep(1000);
+ shell = bot.activeShell();
+ }
+
+ SWTBot shellBot = shell.bot();
+
+ shellBot.textWithLabel("Environment:").setText("CFLAGS=\"-DJeff2\"");
+ shellBot.textWithLabel("Options:").setText("clean");
+
+ shellBot.button("Finish").click();
+
+ bot.waitUntil(Conditions.shellCloses(shell));
+
+ SWTBotView console = bot.viewByPartName("Console");
+ console.show();
+ console.setFocus();
+
+ String[] lines = new String[0];
+
+ while (lines.length < 4) {
+ String output = console.bot().styledText().getText();
+ lines = output.split("\\r?\\n"); //$NON-NLS-1$
+ bot.sleep(2000);
+ }
+
+ bot.sleep(2000);
+
+ assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
+ assertEquals("[1/1] Cleaning.", lines[1]);
+ assertEquals("Cleaning... 3 files.", lines[2]);
+ assertEquals("Build complete: " + projectPath + "/build/default", lines[3]);
+
+ // Make sure it shows up in Project Explorer
+ explorer = bot.viewByPartName("Project Explorer");
+ explorer.show();
+ explorer.setFocus();
+ proj = explorer.bot().tree().getTreeItem(projectName).select();
+ proj.contextMenu("Run ninja").click();
+
+ shell = bot.activeShell();
+
+ while (!shell.getText().trim().isEmpty()) {
+ bot.sleep(1000);
+ shell = bot.activeShell();
+ }
+
+ shellBot = shell.bot();
+
+ // verify last parameters are still present
+ assertEquals("CFLAGS=\"-DJeff2\"",shellBot.textWithLabel("Environment:").getText());
+ assertEquals("clean", shellBot.textWithLabel("Options:").getText());
+
+ shellBot.button("Cancel").click();
+
+ bot.waitUntil(Conditions.shellCloses(shell));
+
+ // Make sure it shows up in Project Explorer
+ explorer = bot.viewByPartName("Project Explorer");
+ explorer.show();
+ explorer.setFocus();
+ proj = explorer.bot().tree().getTreeItem(projectName).select();
+
+ proj.expand();
+ bot.sleep(500);
+ proj.expandNode("Binaries");
+
+ SWTBotTreeItem binaries = proj.getNode("Binaries").select();
+ List<String> binarynodes = binaries.getNodes();
+
+ // make sure that we no longer have the binary after the clean occurs
+ for (String node : binarynodes) {
+ if (node.contains(projectName)) {
+ fail();
+ }
+ }
+
+
+ }
+
+
+}
+
diff --git a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonConfigureTest.java b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonConfigureTest.java
index d9932ce35e3..241011589e9 100644
--- a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonConfigureTest.java
+++ b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonConfigureTest.java
@@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.meson.ui.tests.utils.CloseWelcomePageRule;
import org.eclipse.cdt.meson.core.MesonNature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.epp.logging.aeri.core.ISystemSettings;
import org.eclipse.epp.logging.aeri.core.SendMode;
import org.eclipse.epp.logging.aeri.core.SystemControl;
@@ -124,10 +125,6 @@ public class NewMesonConfigureTest {
@Test
public void attemptMesonConfiguration() throws Exception {
String projectName = "MesonTestProj2";
- // Make sure the project indexer completes. At that point we're stable.
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- ICProject cproject = CoreModel.getDefault().create(project);
-
// open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) {
bot.perspectiveByLabel("C/C++").activate();
@@ -190,6 +187,8 @@ public class NewMesonConfigureTest {
// Make sure the project indexer completes. At that point we're stable.
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cproject = CoreModel.getDefault().create(project);
+
+ IPath projectPath = project.getLocation();
// open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) {
@@ -224,29 +223,30 @@ public class NewMesonConfigureTest {
bot.sleep(2000);
- assertEquals("Building in: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[0]);
- assertEquals("env CFLAGS=\"-DJeff\" sh -c \"meson --backend=ninja --buildtype=debug --unity=off --werror --layout=mirror --default-library=shared --warnlevel=2 /home/jjohnstn/junit-workspace/MesonTestProj2\"", lines[1]);
+ assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
+ assertEquals("env CFLAGS=\"-DJeff\" sh -c \"meson --backend=ninja --buildtype=debug --unity=off --werror --layout=mirror --default-library=shared --warnlevel=2 " + projectPath + "\"", lines[1]);
assertEquals("The Meson build system", lines[2]);
assertTrue(lines[3].startsWith("Version:"));
- assertEquals("Source dir: /home/jjohnstn/junit-workspace/MesonTestProj2", lines[4]);
- assertEquals("Build dir: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[5]);
+ assertEquals("Source dir: " + projectPath, lines[4]);
+ assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
assertEquals("Build type: native build", lines[6]);
assertEquals("Project name: MesonTestProj2", lines[7]);
assertTrue(lines[8].startsWith("Native C compiler: cc"));
assertEquals("Build targets in project: 1", lines[12]);
- assertTrue(lines[13].startsWith("[1/2] cc -IMesonTestProj2@exe"));
- assertTrue(lines[13].contains("-Werror"));
- assertTrue(lines[14].startsWith("FAILED"));
- assertTrue(lines[17].contains("Werror=unused-parameter"));
- assertEquals("Build complete: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[lines.length-1]);
+ int index = 0;
+ if (!lines[13].startsWith("[1/2]")) {
+ index = 1;
+ }
+ assertTrue(lines[13+index].startsWith("[1/2] cc -IMesonTestProj2@exe"));
+ assertTrue(lines[13+index].contains("-Werror"));
+ assertTrue(lines[14+index].startsWith("FAILED"));
+ assertTrue(lines[17+index].contains("Werror=unused-parameter"));
+ assertEquals("Build complete: " + projectPath + "/build/default", lines[lines.length-1]);
}
@Test
public void configureAfterBuild() throws Exception {
String projectName = "MesonTestProj2";
- // Make sure the project indexer completes. At that point we're stable.
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- ICProject cproject = CoreModel.getDefault().create(project);
// open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) {
@@ -314,6 +314,8 @@ public class NewMesonConfigureTest {
// Make sure the project indexer completes. At that point we're stable.
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cproject = CoreModel.getDefault().create(project);
+
+ IPath projectPath = project.getLocation();
// open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) {
@@ -349,18 +351,18 @@ public class NewMesonConfigureTest {
String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$
- assertEquals("Building in: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[0]);
+ assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
assertEquals("The Meson build system", lines[2]);
assertTrue(lines[3].startsWith("Version:"));
- assertEquals("Source dir: /home/jjohnstn/junit-workspace/MesonTestProj2", lines[4]);
- assertEquals("Build dir: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[5]);
+ assertEquals("Source dir: " + projectPath, lines[4]);
+ assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
assertEquals("Build type: native build", lines[6]);
assertEquals("Project name: MesonTestProj2", lines[7]);
assertTrue(lines[8].startsWith("Native C compiler: cc"));
assertEquals("Build targets in project: 1", lines[11]);
- assertTrue(lines[12].startsWith("[1/2] cc -IMesonTestProj2@exe"));
- assertTrue(lines[13].startsWith("[2/2] cc -o MesonTestProj2"));
- assertEquals("Build complete: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[lines.length-1]);
+ assertTrue(lines[lines.length-3].startsWith("[1/2] cc -IMesonTestProj2@exe"));
+ assertTrue(lines[lines.length-2].startsWith("[2/2] cc -o MesonTestProj2"));
+ assertEquals("Build complete: " + projectPath + "/build/default", lines[lines.length-1]);
}
@Test
diff --git a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonProjectTest.java b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonProjectTest.java
index 9455c59d5cc..4f255d89214 100644
--- a/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonProjectTest.java
+++ b/build/org.eclipse.cdt.meson.ui.tests/src/org/eclipse/cdt/internal/meson/ui/tests/NewMesonProjectTest.java
@@ -14,6 +14,8 @@ import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRe
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.util.List;
+
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel;
@@ -23,6 +25,7 @@ import org.eclipse.cdt.internal.meson.ui.tests.utils.CloseWelcomePageRule;
import org.eclipse.cdt.meson.core.MesonNature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.epp.logging.aeri.core.ISystemSettings;
import org.eclipse.epp.logging.aeri.core.SendMode;
import org.eclipse.epp.logging.aeri.core.SystemControl;
@@ -127,6 +130,8 @@ public class NewMesonProjectTest {
// Make sure the project indexer completes. At that point we're stable.
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cproject = CoreModel.getDefault().create(project);
+
+ IPath projectPath = project.getLocation();
// open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) {
@@ -162,19 +167,19 @@ public class NewMesonProjectTest {
String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$
- assertEquals("Building in: /home/jjohnstn/junit-workspace/MesonTestProj/build/default", lines[0]);
- assertEquals(" sh -c \"meson /home/jjohnstn/junit-workspace/MesonTestProj\"", lines[1]);
+ assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
+ assertEquals(" sh -c \"meson " + projectPath + "\"", lines[1]);
assertEquals("The Meson build system", lines[2]);
assertTrue(lines[3].startsWith("Version:"));
- assertEquals("Source dir: /home/jjohnstn/junit-workspace/MesonTestProj", lines[4]);
- assertEquals("Build dir: /home/jjohnstn/junit-workspace/MesonTestProj/build/default", lines[5]);
+ assertEquals("Source dir: " + projectPath, lines[4]);
+ assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
assertEquals("Build type: native build", lines[6]);
assertEquals("Project name: MesonTestProj", lines[7]);
assertTrue(lines[8].startsWith("Native C compiler: cc"));
assertEquals("Build targets in project: 1", lines[11]);
- assertTrue(lines[12].startsWith("[1/2] cc -IMesonTestProj@exe"));
- assertTrue(lines[13].startsWith("[2/2] cc -o MesonTestProj"));
- assertEquals("Build complete: /home/jjohnstn/junit-workspace/MesonTestProj/build/default", lines[14]);
+ assertTrue(lines[lines.length-3].startsWith("[1/2] cc -IMesonTestProj@exe"));
+ assertTrue(lines[lines.length-2].startsWith("[2/2] cc -o MesonTestProj"));
+ assertEquals("Build complete: " + projectPath + "/build/default", lines[lines.length-1]);
}
@Test
@@ -219,4 +224,52 @@ public class NewMesonProjectTest {
String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$
assertEquals("Hello World", lines[0]);
}
+
+ @Test
+ public void tryCleaningMesonProject() throws Exception {
+ String projectName = "MesonTestProj";
+ // Make sure the project indexer completes. At that point we're stable.
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ CoreModel.getDefault().create(project);
+
+ // open C++ perspective
+ if (!"C/C++".equals(bot.activePerspective().getLabel())) {
+ bot.perspectiveByLabel("C/C++").activate();
+ }
+
+ bot.sleep(1000);
+
+ IPath projectPath = project.getLocation();
+
+ SWTBotShell mainShell = bot.shell("junit-workspace - Eclipse Platform");
+
+ // use mainShell to get Project menu because it will be found somewhere else
+ bot.menu(mainShell).menu("Project").menu("Clean...").click();
+ bot.waitUntil(Conditions.shellIsActive("Clean"));
+ bot.shell("Clean").activate();
+
+ SWTBotShell shell = bot.shell("Clean");
+ shell.bot().checkBox("Clean all projects").deselect();
+
+ shell.bot().button("Clean").click();
+
+ bot.waitUntil(Conditions.shellCloses(shell));
+
+ // check the build console output
+ SWTBotView console = bot.viewByPartName("Console");
+ console.show();
+ console.setFocus();
+ String output = console.bot().styledText().getText();
+
+ String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$
+
+ assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
+ assertEquals("ninja clean -v", lines[1]);
+ assertEquals("[1/1] ninja -t clean", lines[2]);
+ assertEquals("Cleaning... 3 files.", lines[3]);
+ assertEquals("Build complete: " + projectPath + "/build/default", lines[4]);
+
+ }
+
+
}

Back to the top