mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 17:25:38 +02:00
Add tests for new default dependency calculators
This commit is contained in:
parent
95c618c300
commit
61c6b0788f
13 changed files with 6430 additions and 6084 deletions
|
@ -6014,5 +6014,106 @@
|
|||
</configuration>
|
||||
</projectType>
|
||||
|
||||
<!-- projects for testing the default dependency calculators -->
|
||||
<projectType
|
||||
isAbstract="false"
|
||||
isTest="true"
|
||||
name="DependencyCalculator2 Tester"
|
||||
id="depcalc2.managedbuild.target.gnu.exe">
|
||||
<configuration
|
||||
name="Debug"
|
||||
id="depcalc2.managedbuild.config.gnu.exe.debug">
|
||||
<toolChain
|
||||
id="test.dependency.calculator.2"
|
||||
name="GCC using DependencyCalculator2"
|
||||
superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
|
||||
<tool
|
||||
id="depcalc2.managedbuild.tool.gnu.c.compiler"
|
||||
superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<inputType
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2"
|
||||
id="depcalc2.managedbuild.tool.gnu.c.compiler.input"
|
||||
superClass="cdt.managedbuild.tool.gnu.c.compiler.input">
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool
|
||||
id="depcalc2.managedbuild.tool.gnu.cpp.compiler"
|
||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
|
||||
<inputType
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator2"
|
||||
id="depcalc2.managedbuild.tool.gnu.cpp.compiler.input"
|
||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input">
|
||||
</inputType>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</configuration>
|
||||
</projectType>
|
||||
<projectType
|
||||
isAbstract="false"
|
||||
isTest="true"
|
||||
name="DependencyCalculator3 Tester"
|
||||
id="depcalc3.managedbuild.target.gnu.exe">
|
||||
<configuration
|
||||
name="Debug"
|
||||
id="depcalc3.managedbuild.config.gnu.exe.debug">
|
||||
<toolChain
|
||||
id="test.dependency.calculator.3"
|
||||
name="GCC using DependencyCalculator3"
|
||||
superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
|
||||
<tool
|
||||
id="depcalc3.managedbuild.tool.gnu.c.compiler"
|
||||
superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<inputType
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator3"
|
||||
id="depcalc3.managedbuild.tool.gnu.c.compiler.input"
|
||||
superClass="cdt.managedbuild.tool.gnu.c.compiler.input">
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool
|
||||
id="depcalc3.managedbuild.tool.gnu.cpp.compiler"
|
||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
|
||||
<inputType
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculator3"
|
||||
id="depcalc3.managedbuild.tool.gnu.cpp.compiler.input"
|
||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input">
|
||||
</inputType>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</configuration>
|
||||
</projectType>
|
||||
<projectType
|
||||
isAbstract="false"
|
||||
isTest="true"
|
||||
name="DependencyCalculatorPreBuild Tester"
|
||||
id="depcalcPreBuild.managedbuild.target.gnu.exe">
|
||||
<configuration
|
||||
name="Debug"
|
||||
id="depcalcPreBuild.managedbuild.config.gnu.exe.debug">
|
||||
<toolChain
|
||||
id="test.dependency.calculator.PreBuild"
|
||||
name="GCC using DependencyCalculatorPreBuild"
|
||||
superClass="cdt.managedbuild.toolchain.gnu.exe.debug">
|
||||
<tool
|
||||
id="depcalcPreBuild.managedbuild.tool.gnu.c.compiler"
|
||||
superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.debug">
|
||||
<inputType
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculatorPreBuild"
|
||||
id="depcalcPreBuild.managedbuild.tool.gnu.c.compiler.input"
|
||||
superClass="cdt.managedbuild.tool.gnu.c.compiler.input">
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool
|
||||
id="depcalcPreBuild.managedbuild.tool.gnu.cpp.compiler"
|
||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.debug">
|
||||
<inputType
|
||||
dependencyCalculator="org.eclipse.cdt.managedbuilder.makegen.gnu.DefaultGCCDependencyCalculatorPreBuild"
|
||||
id="depcalcPreBuild.managedbuild.tool.gnu.cpp.compiler.input"
|
||||
superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input">
|
||||
</inputType>
|
||||
</tool>
|
||||
</toolChain>
|
||||
</configuration>
|
||||
</projectType>
|
||||
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -19,6 +19,7 @@ import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests20;
|
|||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests_SharedToolOptions;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildMacrosTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildTCSupportedTest;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedCommandLineGeneratorTest;
|
||||
import org.eclipse.cdt.managedbuilder.core.tests.ManagedProject21MakefileTests;
|
||||
|
@ -59,6 +60,7 @@ public class AllManagedBuildTests {
|
|||
suite.addTest(ManagedBuildTCSupportedTest.suite());
|
||||
suite.addTest(MultiVersionSupportTests.suite());
|
||||
suite.addTest(OptionEnablementTests.suite());
|
||||
suite.addTest(ManagedBuildDependencyCalculatorTests.suite());
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,240 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation 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:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
/**********************************************************************
|
||||
* These tests are for the default dependency calculators
|
||||
**********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.ui.dialogs.IOverwriteQuery;
|
||||
|
||||
public class ManagedBuildDependencyCalculatorTests extends TestCase {
|
||||
|
||||
public ManagedBuildDependencyCalculatorTests(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(ManagedBuildDependencyCalculatorTests.class.getName());
|
||||
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc2"));
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalc3"));
|
||||
suite.addTest(new ManagedBuildDependencyCalculatorTests("test1DepCalcPreBuild"));
|
||||
return suite;
|
||||
}
|
||||
|
||||
private IProject[] createProject(String projName, IPath location, String projectTypeId, boolean containsZip){
|
||||
ArrayList projectList = null;
|
||||
if (containsZip) {
|
||||
File testDir = CTestPlugin.getFileInPlugin(new Path("resources/depCalcProjects/" + projName));
|
||||
if(testDir == null) {
|
||||
fail("Test project directory " + projName + " is missing.");
|
||||
return null;
|
||||
}
|
||||
|
||||
File projectZips[] = testDir.listFiles(new FileFilter(){
|
||||
public boolean accept(File pathname){
|
||||
if(pathname.isDirectory())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
projectList = new ArrayList(projectZips.length);
|
||||
for(int i = 0; i < projectZips.length; i++){
|
||||
try{
|
||||
String projectName = projectZips[i].getName();
|
||||
if(!projectName.endsWith(".zip"))
|
||||
continue;
|
||||
|
||||
projectName = projectName.substring(0,projectName.length()-".zip".length());
|
||||
if(projectName.length() == 0)
|
||||
continue;
|
||||
IProject project = ManagedBuildTestHelper.createProject(projectName, projectZips[i], location, projectTypeId);
|
||||
if(project != null)
|
||||
projectList.add(project);
|
||||
}
|
||||
catch(Exception e){
|
||||
}
|
||||
}
|
||||
if(projectList.size() == 0) {
|
||||
fail("No projects found in test project directory " + testDir.getName() + ". The .zip file may be missing or corrupt.");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
try{
|
||||
IProject project = ManagedBuildTestHelper.createProject(projName, null, location, projectTypeId);
|
||||
if(project != null)
|
||||
projectList = new ArrayList(1);
|
||||
projectList.add(project);
|
||||
} catch(Exception e){}
|
||||
}
|
||||
|
||||
return (IProject[])projectList.toArray(new IProject[projectList.size()]);
|
||||
}
|
||||
|
||||
private IProject[] createProjects(String projName, IPath location, String projectTypeId, boolean containsZip) {
|
||||
|
||||
// In case the projects need to be updated...
|
||||
IOverwriteQuery queryALL = new IOverwriteQuery(){
|
||||
public String queryOverwrite(String file) {
|
||||
return ALL;
|
||||
}};
|
||||
IOverwriteQuery queryNOALL = new IOverwriteQuery(){
|
||||
public String queryOverwrite(String file) {
|
||||
return NO_ALL;
|
||||
}};
|
||||
|
||||
UpdateManagedProjectManager.setBackupFileOverwriteQuery(queryALL);
|
||||
UpdateManagedProjectManager.setUpdateProjectQuery(queryALL);
|
||||
|
||||
IProject projects[] = createProject(projName, location, projectTypeId, containsZip);
|
||||
return projects;
|
||||
}
|
||||
|
||||
private void buildProjectsWorker(IProject projects[], IPath[] files, boolean compareBenchmark) {
|
||||
if(projects == null || projects.length == 0)
|
||||
return;
|
||||
|
||||
boolean succeeded = true;
|
||||
for (int i = 0; i < projects.length; i++){
|
||||
IProject curProject = projects[i];
|
||||
|
||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
|
||||
|
||||
//check whether the managed build info is converted
|
||||
boolean isCompatible = UpdateManagedProjectManager.isCompatibleProject(info);
|
||||
assertTrue(isCompatible);
|
||||
|
||||
if (isCompatible){
|
||||
// Build the project in order to generate the makefiles
|
||||
try{
|
||||
curProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD,null);
|
||||
}
|
||||
catch(CoreException e){
|
||||
fail(e.getStatus().getMessage());
|
||||
}
|
||||
catch(OperationCanceledException e){
|
||||
fail("the project \"" + curProject.getName() + "\" build was cancelled, exception message: " + e.getMessage());
|
||||
}
|
||||
|
||||
//compare the generated makefiles to their benchmarks
|
||||
if (files != null && files.length > 0) {
|
||||
if (i == 0) {
|
||||
String configName = info.getDefaultConfiguration().getName();
|
||||
IPath buildDir = Path.fromOSString(configName);
|
||||
if (compareBenchmark)
|
||||
succeeded = ManagedBuildTestHelper.compareBenchmarks(curProject, buildDir, files);
|
||||
else
|
||||
succeeded = ManagedBuildTestHelper.verifyFilesDoNotExist(curProject, buildDir, files);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (succeeded) { // Otherwise leave the projects around for comparison
|
||||
for (int i = 0; i < projects.length; i++)
|
||||
ManagedBuildTestHelper.removeProject(projects[i].getName());
|
||||
}
|
||||
}
|
||||
|
||||
// Build projects and compare benchmarks
|
||||
private void buildProjects(IProject projects[], IPath[] files) {
|
||||
buildProjectsWorker(projects, files, true);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation as a side-effect of compilation
|
||||
*/
|
||||
public void test1DepCalc2(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalc2", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation using Echo, a 2nd conmpilation step, and post-processing
|
||||
*/
|
||||
public void test1DepCalc3(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalc3", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* test for dependency calculation that uses a separate, pre-build, step to generate dependency files
|
||||
*/
|
||||
public void test1DepCalcPreBuild(){
|
||||
IPath[] makefiles = {
|
||||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk"),
|
||||
// This file is different using Cygwin vs GCC
|
||||
//Path.fromOSString("main.d"),
|
||||
Path.fromOSString("Sources/subdir.mk"),
|
||||
Path.fromOSString("Sources/func1.d"),
|
||||
Path.fromOSString("Sources/func2.d"),
|
||||
Path.fromOSString("Sources/func4.d"),
|
||||
Path.fromOSString("Sources/sub sources/func 3.d"),
|
||||
Path.fromOSString("Sources/sub sources/subdir.mk")};
|
||||
IProject[] projects = createProjects("test1DepCalcPreBuild", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
||||
}
|
|
@ -614,7 +614,10 @@ public class ManagedProject30MakefileTests extends TestCase {
|
|||
Path.fromOSString("makefile"),
|
||||
Path.fromOSString("objects.mk"),
|
||||
Path.fromOSString("sources.mk"),
|
||||
Path.fromOSString("subdir.mk")};
|
||||
Path.fromOSString("subdir.mk"),
|
||||
Path.fromOSString("main with spaces.d"),
|
||||
Path.fromOSString("sub folder with spaces/subdir.mk"),
|
||||
Path.fromOSString("sub folder with spaces/foo with spaces.d")};
|
||||
IProject[] projects = createProjects("test with spaces", null, null, true);
|
||||
buildProjects(projects, makefiles);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue