mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
1. Add project conversion test
2. Change newly added getToolBySuperClassId to getToolsBySuperClassId
This commit is contained in:
parent
87143e82fe
commit
06da385853
5 changed files with 179 additions and 13 deletions
|
@ -4388,6 +4388,91 @@
|
||||||
</toolChain>
|
</toolChain>
|
||||||
</configuration>
|
</configuration>
|
||||||
</projectType>
|
</projectType>
|
||||||
|
|
||||||
|
<!-- tool chain definitions for test project type for verifying the project conversion -->
|
||||||
|
|
||||||
|
<projectType
|
||||||
|
isAbstract="false"
|
||||||
|
isTest="true"
|
||||||
|
name="TestProject Conversion - Version 1.0"
|
||||||
|
convertToId="testProject_2.0.0"
|
||||||
|
id="testProject_1.0.0">
|
||||||
|
<configuration
|
||||||
|
name="Test Configuration"
|
||||||
|
id="testProject.config_1.0.0"
|
||||||
|
cleanCommand="rm -rf"
|
||||||
|
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
|
||||||
|
<toolChain
|
||||||
|
id="testProject.toolChain_1.0.0"
|
||||||
|
name="Test ToolChain Ver 1.0"
|
||||||
|
archList="all">
|
||||||
|
<targetPlatform
|
||||||
|
id="testProject.target_1.0.0"
|
||||||
|
name="Test Target"
|
||||||
|
binaryParser="org.eclipse.cdt.core.ELF"
|
||||||
|
archList="all">
|
||||||
|
</targetPlatform>
|
||||||
|
<builder
|
||||||
|
id="testProject.builder_1.0.0"
|
||||||
|
name="Test Builder Version 1.0"
|
||||||
|
command="make"
|
||||||
|
arguments="-k"
|
||||||
|
buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
|
||||||
|
</builder>
|
||||||
|
<tool
|
||||||
|
id="testProject.tool1_1.0.0"
|
||||||
|
name="Test Tool 1 - - Version 1.0"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
||||||
|
</tool>
|
||||||
|
<tool
|
||||||
|
id="testProject.tool2_1.0.0"
|
||||||
|
name="Test Tool 2 - Version 1.0"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</configuration>
|
||||||
|
</projectType>
|
||||||
|
|
||||||
|
<projectType
|
||||||
|
isAbstract="false"
|
||||||
|
isTest="true"
|
||||||
|
name="TestProject Conversion - Version 2.0"
|
||||||
|
id="testProject_2.0.0">
|
||||||
|
<configuration
|
||||||
|
name="Test Configuration"
|
||||||
|
id="testProject.config_2.0.0"
|
||||||
|
cleanCommand="rm -rf"
|
||||||
|
errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser">
|
||||||
|
<toolChain
|
||||||
|
id="testProject.toolChain_2.0.0"
|
||||||
|
name="Test ToolChain Ver 2.0"
|
||||||
|
archList="all">
|
||||||
|
<targetPlatform
|
||||||
|
id="testProject.target_2.0.0"
|
||||||
|
name="Test Target"
|
||||||
|
binaryParser="org.eclipse.cdt.core.ELF"
|
||||||
|
archList="all">
|
||||||
|
</targetPlatform>
|
||||||
|
<builder
|
||||||
|
id="testProject.builder_2.0.0"
|
||||||
|
name="Test Builder Version 2.0"
|
||||||
|
command="make"
|
||||||
|
arguments="-k"
|
||||||
|
buildfileGenerator="org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator">
|
||||||
|
</builder>
|
||||||
|
<tool
|
||||||
|
id="testProject.tool1_2.0.0"
|
||||||
|
name="Test Tool 1 - - Version 2.0"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.c.compiler">
|
||||||
|
</tool>
|
||||||
|
<tool
|
||||||
|
id="testProject.tool2_2.0.0"
|
||||||
|
name="Test Tool 2 - Version 2.0"
|
||||||
|
superClass="cdt.managedbuild.tool.gnu.cpp.compiler">
|
||||||
|
</tool>
|
||||||
|
</toolChain>
|
||||||
|
</configuration>
|
||||||
|
</projectType>
|
||||||
|
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
|
@ -4401,6 +4486,16 @@
|
||||||
toId="test.toolchain_1.2.0"
|
toId="test.toolchain_1.2.0"
|
||||||
mbsVersion="3.0.0">
|
mbsVersion="3.0.0">
|
||||||
</converter>
|
</converter>
|
||||||
|
<!-- converter for the projectType testProject_1.0.0 -->
|
||||||
|
<converter
|
||||||
|
id="testProject.converter"
|
||||||
|
name="Test Project Converter"
|
||||||
|
class="org.eclipse.cdt.managedbuilder.core.tests.TestProjectConverter"
|
||||||
|
fromId="testProject_1.0.0"
|
||||||
|
toId="testProject_2.0.0"
|
||||||
|
mbsVersion="3.0.0">
|
||||||
|
</converter>
|
||||||
|
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension
|
<extension
|
||||||
|
|
Binary file not shown.
|
@ -164,7 +164,9 @@ public class ManagedCommandLineGeneratorTest extends TestCase {
|
||||||
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
|
||||||
IConfiguration config = info.getDefaultConfiguration();
|
IConfiguration config = info.getDefaultConfiguration();
|
||||||
// Set values for the options
|
// Set values for the options
|
||||||
ITool tool = config.getToolBySuperClassId("cdt.test.dollarValue.Tool");
|
ITool[] tools = config.getToolsBySuperClassId("cdt.test.dollarValue.Tool");
|
||||||
|
assertEquals(tools.length, 1);
|
||||||
|
ITool tool = tools[0];
|
||||||
IOption option1 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option1");
|
IOption option1 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option1");
|
||||||
IOption option2 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option2");
|
IOption option2 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option2");
|
||||||
IOption option3 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option3");
|
IOption option3 = tool.getOptionBySuperClassId("cdt.test.dollarValue.option3");
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
suite.addTest(new MultiVersionSupportTests("testVersionsSupportedAttribute")); //$NON-NLS-1$
|
suite.addTest(new MultiVersionSupportTests("testVersionsSupportedAttribute")); //$NON-NLS-1$
|
||||||
suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT20")); //$NON-NLS-1$
|
suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT20")); //$NON-NLS-1$
|
||||||
suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT21")); //$NON-NLS-1$
|
suite.addTest(new MultiVersionSupportTests("testToolChainConversion_CDT21")); //$NON-NLS-1$
|
||||||
|
suite.addTest(new MultiVersionSupportTests("testProjectConversion")); //$NON-NLS-1$
|
||||||
//$JUnit-END$
|
//$JUnit-END$
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
@ -394,8 +394,8 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToolChainConversion_CDT20() throws Exception {
|
public void testToolChainConversion_CDT20() throws Exception {
|
||||||
// Pass CDT version as '2.0', and 'true' to update Project
|
// Pass projDirName as 'test20', and 'true' to update Project
|
||||||
doTestProjectUpdate("2.0", true); //$NON-NLS-1$
|
doTestProjectUpdate("test20", true); //$NON-NLS-1$
|
||||||
|
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -419,8 +419,8 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testToolChainConversion_CDT21() throws Exception {
|
public void testToolChainConversion_CDT21() throws Exception {
|
||||||
// Pass CDT version as '2.1', and 'true' to update Project
|
// Pass projDirName as 'test21', and 'true' to update Project
|
||||||
doTestProjectUpdate("2.1", true); //$NON-NLS-1$
|
doTestProjectUpdate("test21", true); //$NON-NLS-1$
|
||||||
|
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -443,20 +443,46 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testProjectConversion() throws Exception {
|
||||||
|
// Pass the 'projDirName' as 'testProjectConversion', and 'true' to update Project
|
||||||
|
doTestProjectUpdate("testProjectConversion", true); //$NON-NLS-1$
|
||||||
|
|
||||||
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
File inputFile = new File(tmpDir + "/testProjectConverterOutput.txt"); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
|
assertTrue(inputFile.exists());
|
||||||
|
|
||||||
|
String expectedContent = "The converter for the projectType testProject_1.0.0 is invoked"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
BufferedReader data = new BufferedReader(new FileReader(inputFile));
|
||||||
|
String actualContent;
|
||||||
|
|
||||||
|
if ((actualContent = data.readLine()) != null) {
|
||||||
|
assertEquals(actualContent,expectedContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IProject getCDT_TestProject(String projDirName) {
|
||||||
private IProject getCDT_TestProject(String cdtVersion) {
|
|
||||||
|
|
||||||
IProject project = null;
|
IProject project = null;
|
||||||
File file = null;
|
File file = null;
|
||||||
|
|
||||||
if (cdtVersion.equalsIgnoreCase("2.0")) { //$NON-NLS-1$
|
if (projDirName.equalsIgnoreCase("test20")) { //$NON-NLS-1$
|
||||||
file = CTestPlugin.getFileInPlugin(new Path(
|
file = CTestPlugin.getFileInPlugin(new Path(
|
||||||
"resources/toolChainConversionProjects/test20")); //$NON-NLS-1$
|
"resources/toolChainConversionProjects/test20")); //$NON-NLS-1$
|
||||||
} else if (cdtVersion.equals("2.1")) { //$NON-NLS-1$
|
} else if (projDirName.equals("test21")) { //$NON-NLS-1$
|
||||||
file = CTestPlugin.getFileInPlugin(new Path(
|
file = CTestPlugin.getFileInPlugin(new Path(
|
||||||
"resources/toolChainConversionProjects/test21")); //$NON-NLS-1$
|
"resources/toolChainConversionProjects/test21")); //$NON-NLS-1$
|
||||||
}
|
} else if (projDirName.equals("testProjectConversion")) { //$NON-NLS-1$
|
||||||
|
file = CTestPlugin.getFileInPlugin(new Path(
|
||||||
|
"resources/toolChainConversionProjects/testProjectConversion")); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
fail("Test project directory " + file.getName() //$NON-NLS-1$
|
fail("Test project directory " + file.getName() //$NON-NLS-1$
|
||||||
|
@ -508,7 +534,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doTestProjectUpdate(String cdtVersion, boolean updateProject) {
|
private void doTestProjectUpdate(String projDirName, boolean updateProject) {
|
||||||
IOverwriteQuery queryALL = new IOverwriteQuery(){
|
IOverwriteQuery queryALL = new IOverwriteQuery(){
|
||||||
public String queryOverwrite(String file) {
|
public String queryOverwrite(String file) {
|
||||||
return ALL;
|
return ALL;
|
||||||
|
@ -520,7 +546,7 @@ public class MultiVersionSupportTests extends TestCase {
|
||||||
|
|
||||||
UpdateManagedProjectManager.setUpdateProjectQuery(updateProject ? queryALL : queryNOALL);
|
UpdateManagedProjectManager.setUpdateProjectQuery(updateProject ? queryALL : queryNOALL);
|
||||||
|
|
||||||
final IProject project = getCDT_TestProject(cdtVersion);
|
final IProject project = getCDT_TestProject(projDirName);
|
||||||
if (project == null)
|
if (project == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2005 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
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.managedbuilder.core.tests;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IBuildObject;
|
||||||
|
import org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject;
|
||||||
|
|
||||||
|
|
||||||
|
public class TestProjectConverter implements IConvertManagedBuildObject {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.managedbuilder.core.IConvertManagedBuildObject#convert(org.eclipse.cdt.managedbuilder.core.IBuildObject, java.lang.String, java.lang.String, boolean)
|
||||||
|
*/
|
||||||
|
public IBuildObject convert(IBuildObject buildObj, String fromId,
|
||||||
|
String toId, boolean isConfirmed) {
|
||||||
|
|
||||||
|
String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
File outputFile = new File(tmpDir + "/testProjectConverterOutput.txt"); //$NON-NLS-1$
|
||||||
|
try {
|
||||||
|
FileWriter out = new FileWriter(outputFile);
|
||||||
|
out.write("The converter for the projectType testProject_1.0.0 is invoked"); //$NON-NLS-1$
|
||||||
|
out.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Exception raised."); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return buildObj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue