mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Test for PR 80185 - output message to console when there are no source files to build
This commit is contained in:
parent
3950ab52ae
commit
bc4f611eb1
3 changed files with 67 additions and 9 deletions
Binary file not shown.
|
@ -242,6 +242,27 @@ public class ManagedBuildTestHelper {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public boolean verifyFilesDoNotExist(IProject project, IPath testDir, IPath[] files) {
|
||||||
|
try {
|
||||||
|
project.refreshLocal(IResource.DEPTH_INFINITE, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("File " + files[0].lastSegment() + " - project refresh failed.");
|
||||||
|
}
|
||||||
|
for (int i=0; i<files.length; i++) {
|
||||||
|
IPath testFile = testDir.append(files[i]);
|
||||||
|
IPath fullPath = project.getLocation().append(testFile);
|
||||||
|
try {
|
||||||
|
if (fullPath.toFile().exists()) {
|
||||||
|
Assert.fail("File " + testFile.lastSegment() + " unexpectedly found.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("File " + fullPath.toString() + " could not be referenced.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static public StringBuffer readContentsStripLineEnds(IProject project, IPath path) {
|
static public StringBuffer readContentsStripLineEnds(IProject project, IPath path) {
|
||||||
StringBuffer buff = new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
IPath fullPath = project.getLocation().append(path);
|
IPath fullPath = project.getLocation().append(path);
|
||||||
|
|
|
@ -25,6 +25,8 @@ import junit.framework.TestSuite;
|
||||||
|
|
||||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
||||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||||
|
@ -57,6 +59,7 @@ public class ManagedProject30MakefileTests extends TestCase {
|
||||||
//suite.addTest(new ManagedProject30MakefileTests("test30LinkedFolder"));
|
//suite.addTest(new ManagedProject30MakefileTests("test30LinkedFolder"));
|
||||||
suite.addTest(new ManagedProject30MakefileTests("test30CopyandDeploy"));
|
suite.addTest(new ManagedProject30MakefileTests("test30CopyandDeploy"));
|
||||||
suite.addTest(new ManagedProject30MakefileTests("test30DeleteFile"));
|
suite.addTest(new ManagedProject30MakefileTests("test30DeleteFile"));
|
||||||
|
suite.addTest(new ManagedProject30MakefileTests("test30NoFilesToBuild"));
|
||||||
suite.addTest(new ManagedProject30MakefileTests("test30_1"));
|
suite.addTest(new ManagedProject30MakefileTests("test30_1"));
|
||||||
suite.addTest(new ManagedProject30MakefileTests("test30_2"));
|
suite.addTest(new ManagedProject30MakefileTests("test30_2"));
|
||||||
|
|
||||||
|
@ -132,12 +135,12 @@ public class ManagedProject30MakefileTests extends TestCase {
|
||||||
return projects;
|
return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildProjects(IProject projects[], IPath[] files) {
|
private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) {
|
||||||
if(projects == null || projects.length == 0)
|
if(projects == null || projects.length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean succeeded = true;
|
boolean succeeded = true;
|
||||||
for(int i = 0; i < projects.length; i++){
|
for (int i = 0; i < projects.length; i++){
|
||||||
IProject curProject = projects[i];
|
IProject curProject = projects[i];
|
||||||
|
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
|
||||||
|
@ -146,7 +149,7 @@ public class ManagedProject30MakefileTests extends TestCase {
|
||||||
boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
|
boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
|
||||||
assertTrue(isCompatible);
|
assertTrue(isCompatible);
|
||||||
|
|
||||||
if(isCompatible){
|
if (isCompatible){
|
||||||
// Build the project in order to generate the makefiles
|
// Build the project in order to generate the makefiles
|
||||||
try{
|
try{
|
||||||
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
||||||
|
@ -163,18 +166,31 @@ public class ManagedProject30MakefileTests extends TestCase {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
String configName = info.getDefaultConfiguration().getName();
|
String configName = info.getDefaultConfiguration().getName();
|
||||||
IPath buildDir = Path.fromOSString(configName);
|
IPath buildDir = Path.fromOSString(configName);
|
||||||
succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
|
if (compareBenchmark)
|
||||||
|
succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
|
||||||
|
else
|
||||||
|
succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (succeeded) { // Otherwise leave the projects around for comparison
|
if (succeeded) { // Otherwise leave the projects around for comparison
|
||||||
for(int i = 0; i < projects.length; i++)
|
for (int i = 0; i < projects.length; i++)
|
||||||
ManagedBuildTestHelper.removeProject(projects[i].getName());
|
ManagedBuildTestHelper.removeProject(projects[i].getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build projects and compare benchmarks
|
||||||
|
private void buildProjects(IProject projects[], IPath[] files) {
|
||||||
|
buildProjectsWorker(projects, files, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build projects but don't compare benchmarks because there should be not build files generated
|
||||||
|
private void buildDegenerativeProjects(IProject projects[], IPath[] files) {
|
||||||
|
buildProjectsWorker(projects, files, false);
|
||||||
|
}
|
||||||
|
|
||||||
private void createPathVariable(IPath tmpDir) {
|
private void createPathVariable(IPath tmpDir) {
|
||||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||||
workspace = ResourcesPlugin.getWorkspace();
|
workspace = ResourcesPlugin.getWorkspace();
|
||||||
|
@ -348,10 +364,31 @@ public class ManagedProject30MakefileTests extends TestCase {
|
||||||
IResource[] fileResource = (IResource[])resourceList.toArray(new IResource[resourceList.size()]);
|
IResource[] fileResource = (IResource[])resourceList.toArray(new IResource[resourceList.size()]);
|
||||||
try {
|
try {
|
||||||
workspace.delete(fileResource, false, null);
|
workspace.delete(fileResource, false, null);
|
||||||
} catch (Exception e) {fail("could not delete file in project " + project.getName());}
|
} catch (Exception e) {
|
||||||
try {
|
fail("could not delete file in project " + project.getName());
|
||||||
buildProjects(projects, makefiles);
|
}
|
||||||
} finally {};
|
buildProjects(projects, makefiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* tests 3.0 managed build system with a project which has only a single source file that is marked as
|
||||||
|
* "excluded from build" to see that this degenerative case is handled gracefully
|
||||||
|
*/
|
||||||
|
public void test30NoFilesToBuild(){
|
||||||
|
IPath[] makefiles = {
|
||||||
|
Path.fromOSString("makefile"),
|
||||||
|
Path.fromOSString("objects.mk"),
|
||||||
|
Path.fromOSString("subdir.mk"),
|
||||||
|
Path.fromOSString("sources.mk")};
|
||||||
|
|
||||||
|
IProject[] projects = createProjects("noFilesToBuild", null, null, true);
|
||||||
|
IProject project = projects[0];
|
||||||
|
IFile projfile = project.getFile("filetobeexcluded.cxx");
|
||||||
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
|
IConfiguration config = info.getDefaultConfiguration();
|
||||||
|
IResourceConfiguration rconfig = config.createResourceConfiguration(projfile);
|
||||||
|
rconfig.setExclude(true);
|
||||||
|
buildDegenerativeProjects(projects, makefiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue