1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 06:02:11 +02:00

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
This commit is contained in:
Jeff Johnston 2018-03-28 18:21:21 -04:00
parent fcbd010b2d
commit 88cc9907cb
5 changed files with 384 additions and 36 deletions

View file

@ -207,9 +207,6 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
} }
List<String> envList = new ArrayList<>(); List<String> envList = new ArrayList<>();
if (ninjaEnv != null) {
envList.addAll(Arrays.asList(ninjaEnv));
}
String[] env = envList.toArray(new String[0]); String[] env = envList.toArray(new String[0]);
ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(this); ICommandLauncher launcher = CommandLauncherManager.getInstance().getCommandLauncher(this);
@ -221,10 +218,18 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
monitor.subTask(Messages.MesonBuildConfiguration_RunningNinja); 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()); org.eclipse.core.runtime.Path workingDir = new org.eclipse.core.runtime.Path(getBuildDirectory().toString());
List<String> argList = new ArrayList<>(); 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$ argList.add("-c"); //$NON-NLS-1$
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(buildCommand); b.append(buildCommand);
@ -238,7 +243,7 @@ public class MesonBuildConfiguration extends CBuildConfiguration {
} }
argList.add(b.toString()); 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) { if (p != null && launcher.waitAndRead(epm.getOutputStream(), epm.getOutputStream(), SubMonitor.convert(monitor)) != ICommandLauncher.OK) {
String errMsg = launcher.getErrorMessage(); String errMsg = launcher.getErrorMessage();
console.getErrorStream().write(String.format(Messages.MesonBuildConfiguration_RunningNinjaFailure, errMsg)); 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$ 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<>(); List<String> argList = new ArrayList<>();
argList.add("sh"); //$NON-NLS-1$
argList.add("-c"); //$NON-NLS-1$ argList.add("-c"); //$NON-NLS-1$
argList.add(cleanCommand); argList.add(cleanCommand);

View file

@ -14,7 +14,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
@RunWith(Suite.class) @RunWith(Suite.class)
@Suite.SuiteClasses({ NewMesonProjectTest.class, NewMesonConfigureTest.class }) @Suite.SuiteClasses({ NewMesonProjectTest.class, NewMesonConfigureTest.class, NewManualNinjaTest.class })
public class AutomatedIntegrationSuite { public class AutomatedIntegrationSuite {
} }

View file

@ -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();
}
}
}
}

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.internal.meson.ui.tests.utils.CloseWelcomePageRule;
import org.eclipse.cdt.meson.core.MesonNature; import org.eclipse.cdt.meson.core.MesonNature;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin; 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.ISystemSettings;
import org.eclipse.epp.logging.aeri.core.SendMode; import org.eclipse.epp.logging.aeri.core.SendMode;
import org.eclipse.epp.logging.aeri.core.SystemControl; import org.eclipse.epp.logging.aeri.core.SystemControl;
@ -124,10 +125,6 @@ public class NewMesonConfigureTest {
@Test @Test
public void attemptMesonConfiguration() throws Exception { public void attemptMesonConfiguration() throws Exception {
String projectName = "MesonTestProj2"; 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 // open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) { if (!"C/C++".equals(bot.activePerspective().getLabel())) {
bot.perspectiveByLabel("C/C++").activate(); bot.perspectiveByLabel("C/C++").activate();
@ -191,6 +188,8 @@ public class NewMesonConfigureTest {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cproject = CoreModel.getDefault().create(project); ICProject cproject = CoreModel.getDefault().create(project);
IPath projectPath = project.getLocation();
// open C++ perspective // open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) { if (!"C/C++".equals(bot.activePerspective().getLabel())) {
bot.perspectiveByLabel("C/C++").activate(); bot.perspectiveByLabel("C/C++").activate();
@ -224,29 +223,30 @@ public class NewMesonConfigureTest {
bot.sleep(2000); bot.sleep(2000);
assertEquals("Building in: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[0]); 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 /home/jjohnstn/junit-workspace/MesonTestProj2\"", lines[1]); 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]); assertEquals("The Meson build system", lines[2]);
assertTrue(lines[3].startsWith("Version:")); assertTrue(lines[3].startsWith("Version:"));
assertEquals("Source dir: /home/jjohnstn/junit-workspace/MesonTestProj2", lines[4]); assertEquals("Source dir: " + projectPath, lines[4]);
assertEquals("Build dir: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[5]); assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
assertEquals("Build type: native build", lines[6]); assertEquals("Build type: native build", lines[6]);
assertEquals("Project name: MesonTestProj2", lines[7]); assertEquals("Project name: MesonTestProj2", lines[7]);
assertTrue(lines[8].startsWith("Native C compiler: cc")); assertTrue(lines[8].startsWith("Native C compiler: cc"));
assertEquals("Build targets in project: 1", lines[12]); assertEquals("Build targets in project: 1", lines[12]);
assertTrue(lines[13].startsWith("[1/2] cc -IMesonTestProj2@exe")); int index = 0;
assertTrue(lines[13].contains("-Werror")); if (!lines[13].startsWith("[1/2]")) {
assertTrue(lines[14].startsWith("FAILED")); index = 1;
assertTrue(lines[17].contains("Werror=unused-parameter")); }
assertEquals("Build complete: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[lines.length-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 @Test
public void configureAfterBuild() throws Exception { public void configureAfterBuild() throws Exception {
String projectName = "MesonTestProj2"; 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 // open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) { if (!"C/C++".equals(bot.activePerspective().getLabel())) {
@ -315,6 +315,8 @@ public class NewMesonConfigureTest {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cproject = CoreModel.getDefault().create(project); ICProject cproject = CoreModel.getDefault().create(project);
IPath projectPath = project.getLocation();
// open C++ perspective // open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) { if (!"C/C++".equals(bot.activePerspective().getLabel())) {
bot.perspectiveByLabel("C/C++").activate(); bot.perspectiveByLabel("C/C++").activate();
@ -349,18 +351,18 @@ public class NewMesonConfigureTest {
String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$ 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]); assertEquals("The Meson build system", lines[2]);
assertTrue(lines[3].startsWith("Version:")); assertTrue(lines[3].startsWith("Version:"));
assertEquals("Source dir: /home/jjohnstn/junit-workspace/MesonTestProj2", lines[4]); assertEquals("Source dir: " + projectPath, lines[4]);
assertEquals("Build dir: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[5]); assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
assertEquals("Build type: native build", lines[6]); assertEquals("Build type: native build", lines[6]);
assertEquals("Project name: MesonTestProj2", lines[7]); assertEquals("Project name: MesonTestProj2", lines[7]);
assertTrue(lines[8].startsWith("Native C compiler: cc")); assertTrue(lines[8].startsWith("Native C compiler: cc"));
assertEquals("Build targets in project: 1", lines[11]); assertEquals("Build targets in project: 1", lines[11]);
assertTrue(lines[12].startsWith("[1/2] cc -IMesonTestProj2@exe")); assertTrue(lines[lines.length-3].startsWith("[1/2] cc -IMesonTestProj2@exe"));
assertTrue(lines[13].startsWith("[2/2] cc -o MesonTestProj2")); assertTrue(lines[lines.length-2].startsWith("[2/2] cc -o MesonTestProj2"));
assertEquals("Build complete: /home/jjohnstn/junit-workspace/MesonTestProj2/build/default", lines[lines.length-1]); assertEquals("Build complete: " + projectPath + "/build/default", lines[lines.length-1]);
} }
@Test @Test

View file

@ -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.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.model.CoreModel; 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.cdt.meson.core.MesonNature;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin; 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.ISystemSettings;
import org.eclipse.epp.logging.aeri.core.SendMode; import org.eclipse.epp.logging.aeri.core.SendMode;
import org.eclipse.epp.logging.aeri.core.SystemControl; import org.eclipse.epp.logging.aeri.core.SystemControl;
@ -128,6 +131,8 @@ public class NewMesonProjectTest {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
ICProject cproject = CoreModel.getDefault().create(project); ICProject cproject = CoreModel.getDefault().create(project);
IPath projectPath = project.getLocation();
// open C++ perspective // open C++ perspective
if (!"C/C++".equals(bot.activePerspective().getLabel())) { if (!"C/C++".equals(bot.activePerspective().getLabel())) {
bot.perspectiveByLabel("C/C++").activate(); bot.perspectiveByLabel("C/C++").activate();
@ -162,19 +167,19 @@ public class NewMesonProjectTest {
String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$ String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$
assertEquals("Building in: /home/jjohnstn/junit-workspace/MesonTestProj/build/default", lines[0]); assertEquals("Building in: " + projectPath + "/build/default", lines[0]);
assertEquals(" sh -c \"meson /home/jjohnstn/junit-workspace/MesonTestProj\"", lines[1]); assertEquals(" sh -c \"meson " + projectPath + "\"", lines[1]);
assertEquals("The Meson build system", lines[2]); assertEquals("The Meson build system", lines[2]);
assertTrue(lines[3].startsWith("Version:")); assertTrue(lines[3].startsWith("Version:"));
assertEquals("Source dir: /home/jjohnstn/junit-workspace/MesonTestProj", lines[4]); assertEquals("Source dir: " + projectPath, lines[4]);
assertEquals("Build dir: /home/jjohnstn/junit-workspace/MesonTestProj/build/default", lines[5]); assertEquals("Build dir: " + projectPath + "/build/default", lines[5]);
assertEquals("Build type: native build", lines[6]); assertEquals("Build type: native build", lines[6]);
assertEquals("Project name: MesonTestProj", lines[7]); assertEquals("Project name: MesonTestProj", lines[7]);
assertTrue(lines[8].startsWith("Native C compiler: cc")); assertTrue(lines[8].startsWith("Native C compiler: cc"));
assertEquals("Build targets in project: 1", lines[11]); assertEquals("Build targets in project: 1", lines[11]);
assertTrue(lines[12].startsWith("[1/2] cc -IMesonTestProj@exe")); assertTrue(lines[lines.length-3].startsWith("[1/2] cc -IMesonTestProj@exe"));
assertTrue(lines[13].startsWith("[2/2] cc -o MesonTestProj")); assertTrue(lines[lines.length-2].startsWith("[2/2] cc -o MesonTestProj"));
assertEquals("Build complete: /home/jjohnstn/junit-workspace/MesonTestProj/build/default", lines[14]); assertEquals("Build complete: " + projectPath + "/build/default", lines[lines.length-1]);
} }
@Test @Test
@ -219,4 +224,52 @@ public class NewMesonProjectTest {
String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$ String[] lines = output.split("\\r?\\n"); //$NON-NLS-1$
assertEquals("Hello World", lines[0]); 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]);
}
} }