1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-21 07:55:24 +02:00

bug 404913: Cosmetics

This commit is contained in:
Andrew Gvozdev 2013-07-21 02:05:13 -04:00
parent bc98f57d9a
commit dae7358b7d

View file

@ -24,7 +24,6 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IOption; import org.eclipse.cdt.managedbuilder.core.IOption;
import org.eclipse.cdt.managedbuilder.core.IOption.ITreeOption; import org.eclipse.cdt.managedbuilder.core.IOption.ITreeOption;
import org.eclipse.cdt.managedbuilder.core.IOption.ITreeRoot; import org.eclipse.cdt.managedbuilder.core.IOption.ITreeRoot;
import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
import org.eclipse.cdt.managedbuilder.core.IOptionCategory; import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
import org.eclipse.cdt.managedbuilder.core.ITargetPlatform; import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
@ -81,34 +80,34 @@ public class ManagedBuildCoreTests extends TestCase {
String expectedBinaryParser = "org.eclipse.cdt.core.ELF"; String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
String expectedBinaryParser2 = "org.eclipse.cdt.core.PE"; String expectedBinaryParser2 = "org.eclipse.cdt.core.PE";
String[] expectedPlatformName = {"Dbg Platform", String[] expectedPlatformName = {"Dbg Platform",
"Rel Platform"}; "Rel Platform"};
String expectedCommand = "make"; String expectedCommand = "make";
String expectedArguments = "-k"; String expectedArguments = "-k";
String[] expectedBuilderName = {"Dbg Builder", String[] expectedBuilderName = {"Dbg Builder",
"Rel Builder"}; "Rel Builder"};
String expectedBuilderInfo = "org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator"; String expectedBuilderInfo = "org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator";
String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.compiler.exe.debug", String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.compiler.exe.debug",
"cdt.managedbuild.tool.testgnu.c.compiler.exe.release"}; "cdt.managedbuild.tool.testgnu.c.compiler.exe.release"};
String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.compiler"; String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.compiler";
String expectedSuperOutputFlag1 = "-o"; String expectedSuperOutputFlag1 = "-o";
String expectedSuperGetToolCommand1 = "gcc"; String expectedSuperGetToolCommand1 = "gcc";
String[] expectedSuperInputExt1 = {"c"}; String[] expectedSuperInputExt1 = {"c"};
String[] expectedSuperToolInterfaceExt1 = {"h"}; String[] expectedSuperToolInterfaceExt1 = {"h"};
String[] expectedSuperToolOutputExt1 = {"o"}; String[] expectedSuperToolOutputExt1 = {"o"};
String expectedOptionCategory1 = "testgnu.c.compiler.category.preprocessor"; String expectedOptionCategory1 = "testgnu.c.compiler.category.preprocessor";
String[] OptionId1 = {"testgnu.c.compiler.exe.debug.option.optimization.level", String[] OptionId1 = {"testgnu.c.compiler.exe.debug.option.optimization.level",
"testgnu.c.compiler.exe.release.option.optimization.level"}; "testgnu.c.compiler.exe.release.option.optimization.level"};
String[] expectedOptionIdValue1 = {"testgnu.c.optimization.level.none", String[] expectedOptionIdValue1 = {"testgnu.c.optimization.level.none",
"testgnu.c.optimization.level.most"}; "testgnu.c.optimization.level.most"};
String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most"; String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most";
int expectedSizeEnumList1 = 4; int expectedSizeEnumList1 = 4;
String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"}; String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"};
String OptionId2 = "testgnu.c.compiler.option.debugging.other"; String OptionId2 = "testgnu.c.compiler.option.debugging.other";
String expectedOptionIdName2 = "Posix.Debug.Other"; String expectedOptionIdName2 = "Posix.Debug.Other";
String OptionId3 = "testgnu.c.compiler.option.debugging.gprof"; String OptionId3 = "testgnu.c.compiler.option.debugging.gprof";
String expectedOptionIdName3 = "Posix.Debug.gprof"; String expectedOptionIdName3 = "Posix.Debug.gprof";
String expectedOptionIdCmd3 = "-pg"; String expectedOptionIdCmd3 = "-pg";
boolean expectedOptionIdValue3 = false; boolean expectedOptionIdValue3 = false;
int expecectedNumTools = 5; int expecectedNumTools = 5;
int numOrderCCompilerTool = 0; int numOrderCCompilerTool = 0;
int expecectedCNature = ITool.FILTER_C; int expecectedCNature = ITool.FILTER_C;
@ -129,110 +128,110 @@ public class ManagedBuildCoreTests extends TestCase {
// //
for (int iconfig=0; iconfig < configs.length; iconfig++) { for (int iconfig=0; iconfig < configs.length; iconfig++) {
// Verify configuration attributes // Verify configuration attributes
// //
assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig])); assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand()); assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
assertEquals(expectedParserId, configs[iconfig].getErrorParserIds()); assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
// Fetch toolchain // Fetch toolchain
// //
IToolChain toolChain = configs[iconfig].getToolChain(); IToolChain toolChain = configs[iconfig].getToolChain();
// Fetch and check platform // Fetch and check platform
// //
ITargetPlatform platform = toolChain.getTargetPlatform(); ITargetPlatform platform = toolChain.getTargetPlatform();
List<String> expectedOSListarr = new ArrayList<String>(); List<String> expectedOSListarr = new ArrayList<String>();
String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$ String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
for (i = 0; i < expectedOSListTokens.length; ++i) { for (i = 0; i < expectedOSListTokens.length; ++i) {
expectedOSListarr.add(expectedOSListTokens[i].trim()); expectedOSListarr.add(expectedOSListTokens[i].trim());
} }
assertTrue(Arrays.equals(platform.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList]))); assertTrue(Arrays.equals(platform.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(platform.getArchList(), expectedArchList)); assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
String[] binaryParsers = platform.getBinaryParserList(); String[] binaryParsers = platform.getBinaryParserList();
assertEquals(binaryParsers.length, 2); assertEquals(binaryParsers.length, 2);
assertEquals(binaryParsers[0], expectedBinaryParser); assertEquals(binaryParsers[0], expectedBinaryParser);
assertEquals(binaryParsers[1], expectedBinaryParser2); assertEquals(binaryParsers[1], expectedBinaryParser2);
assertEquals(platform.getName(), expectedPlatformName[iconfig]); assertEquals(platform.getName(), expectedPlatformName[iconfig]);
// Fetch and check builder // Fetch and check builder
// //
IBuilder builder = toolChain.getBuilder(); IBuilder builder = toolChain.getBuilder();
assertEquals(builder.getCommand(), expectedCommand); assertEquals(builder.getCommand(), expectedCommand);
assertEquals(builder.getArguments(), expectedArguments); assertEquals(builder.getArguments(), expectedArguments);
assertEquals(builder.getName(), expectedBuilderName[iconfig]); assertEquals(builder.getName(), expectedBuilderName[iconfig]);
IConfigurationElement element = ((Builder)builder).getBuildFileGeneratorElement(); IConfigurationElement element = ((Builder)builder).getBuildFileGeneratorElement();
if (element != null) { if (element != null) {
assertEquals(element.getAttribute(IBuilder.BUILDFILEGEN_ID), expectedBuilderInfo); assertEquals(element.getAttribute(IBuilder.BUILDFILEGEN_ID), expectedBuilderInfo);
} }
// Fetch and check tools list // Fetch and check tools list
// //
ITool[] tools = toolChain.getTools(); ITool[] tools = toolChain.getTools();
assertEquals(tools.length, expecectedNumTools); assertEquals(tools.length, expecectedNumTools);
// Fetch and check the gnu C compiler tool // Fetch and check the gnu C compiler tool
// //
ITool tool; ITool tool;
ITool superTool; ITool superTool;
tool = tools[numOrderCCompilerTool]; tool = tools[numOrderCCompilerTool];
superTool = tool.getSuperClass(); superTool = tool.getSuperClass();
assertEquals(tool.getId(), expectedToolId1[iconfig]); assertEquals(tool.getId(), expectedToolId1[iconfig]);
assertEquals(superTool.getId(), expectedSuperToolId1); assertEquals(superTool.getId(), expectedSuperToolId1);
assertEquals(tool.getNatureFilter(), expecectedCNature); assertEquals(tool.getNatureFilter(), expecectedCNature);
assertTrue(Arrays.equals(superTool.getAllInputExtensions(), expectedSuperInputExt1)); assertTrue(Arrays.equals(superTool.getAllInputExtensions(), expectedSuperInputExt1));
assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1); assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1); assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
assertTrue(Arrays.equals(superTool.getAllDependencyExtensions(), expectedSuperToolInterfaceExt1)); assertTrue(Arrays.equals(superTool.getAllDependencyExtensions(), expectedSuperToolInterfaceExt1));
assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedSuperToolOutputExt1)); assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedSuperToolOutputExt1));
assertTrue(superTool.isAbstract()); assertTrue(superTool.isAbstract());
// Fetch and check an option category // Fetch and check an option category
// //
IOptionCategory[] optionCats = superTool.getChildCategories(); IOptionCategory[] optionCats = superTool.getChildCategories();
assertEquals(optionCats[0].getId(), (expectedOptionCategory1)); assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
// Fetch and check options customized for this tool // Fetch and check options customized for this tool
// //
IOption option; IOption option;
// Fetch the optimization level option and verify that it has the proper // Fetch the optimization level option and verify that it has the proper
// default value, which should overwrite the value set in the abstract // default value, which should overwrite the value set in the abstract
// project that its containing project is derived from // project that its containing project is derived from
// //
option = tool.getOptionById(OptionId1[iconfig]); option = tool.getOptionById(OptionId1[iconfig]);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
String optionDefaultValue = (String)option.getDefaultValue(); String optionDefaultValue = (String)option.getDefaultValue();
assertEquals(option.getValueType(), (IOption.ENUMERATED)); assertEquals(option.getValueType(), IOption.ENUMERATED);
assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig])); assertEquals(optionDefaultValue, expectedOptionIdValue1[iconfig]);
String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue); String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue);
assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig])); assertEquals(optionEnumCmd1, expectedOptionEnumCmd1arr[iconfig]);
List<String> expectedEnumList1arr = new ArrayList<String>(); List<String> expectedEnumList1arr = new ArrayList<String>();
String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$ String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$
for (i = 0; i < expectedEnumList1Tokens.length; ++i) { for (i = 0; i < expectedEnumList1Tokens.length; ++i) {
expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim()); expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim());
} }
assertTrue(Arrays.equals(option.getApplicableValues(), expectedEnumList1arr.toArray(new String[expectedSizeEnumList1]))); assertTrue(Arrays.equals(option.getApplicableValues(), expectedEnumList1arr.toArray(new String[expectedSizeEnumList1])));
// Fetch the debug other option and verify // Fetch the debug other option and verify
// //
option = tool.getOptionById(OptionId2); option = tool.getOptionById(OptionId2);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.STRING)); assertEquals(option.getValueType(), IOption.STRING);
assertEquals(option.getName(), (expectedOptionIdName2)); assertEquals(option.getName(), expectedOptionIdName2);
// Fetch the debug gprof option and verify // Fetch the debug gprof option and verify
// //
option = tool.getOptionById(OptionId3); option = tool.getOptionById(OptionId3);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.BOOLEAN)); assertEquals(option.getValueType(), IOption.BOOLEAN);
boolean optionDefaultValueb = option.getBooleanValue(); boolean optionDefaultValueb = option.getBooleanValue();
assertEquals(optionDefaultValueb, (expectedOptionIdValue3)); assertEquals(optionDefaultValueb, expectedOptionIdValue3);
assertEquals(option.getName(), (expectedOptionIdName3)); assertEquals(option.getName(), expectedOptionIdName3);
assertEquals(option.getCommand(), (expectedOptionIdCmd3)); assertEquals(option.getCommand(), expectedOptionIdCmd3);
} // end for } // end for
} // end routine } // end routine
@ -240,7 +239,7 @@ public class ManagedBuildCoreTests extends TestCase {
/* /*
* Do a sanity check on the testgnu so project type. * Do a sanity check on the testgnu so project type.
*/ */
private void checkSoProjectType(IProjectType ptype) throws BuildException { private void checkSoProjectType(IProjectType ptype) throws BuildException {
int i; int i;
int expecectedNumConfigs = 2; int expecectedNumConfigs = 2;
String[] expectedConfigName = {"Debug", "Release"}; String[] expectedConfigName = {"Debug", "Release"};
@ -252,40 +251,40 @@ public class ManagedBuildCoreTests extends TestCase {
String[] expectedArchList = {"all"}; String[] expectedArchList = {"all"};
String expectedBinaryParser = "org.eclipse.cdt.core.ELF"; String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
String[] expectedPlatformName = {"so Debug Platform", String[] expectedPlatformName = {"so Debug Platform",
"so Release Platform"}; "so Release Platform"};
String expectedCommand = "make"; String expectedCommand = "make";
String expectedArguments = "-k"; String expectedArguments = "-k";
String[] expectedBuilderName = {"so Debug Builder", String[] expectedBuilderName = {"so Debug Builder",
"so Release Builder"}; "so Release Builder"};
String expectedScannerConfigDiscoveryProfileId = "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"; String expectedScannerConfigDiscoveryProfileId = "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile";
String[] expectedToolChainName = {"so Debug ToolChain", String[] expectedToolChainName = {"so Debug ToolChain",
"so Release ToolChain"}; "so Release ToolChain"};
String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.linker.so.debug", String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.c.linker.so.debug",
"cdt.managedbuild.tool.testgnu.c.linker.so.release"}; "cdt.managedbuild.tool.testgnu.c.linker.so.release"};
String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.linker"; String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.c.linker";
String expectedToolOutputPrefix = "lib"; String expectedToolOutputPrefix = "lib";
String[] expectedToolOutput = {""}; String[] expectedToolOutput = {""};
String expectedSuperOutputFlag1 = "-o"; String expectedSuperOutputFlag1 = "-o";
String expectedSuperGetToolCommand1 = "gcc"; String expectedSuperGetToolCommand1 = "gcc";
String[] expectedSuperInputExt1 = {"o"}; String[] expectedSuperInputExt1 = {"o"};
String[] expectedSuperToolOutputExt1 = {""}; String[] expectedSuperToolOutputExt1 = {""};
String expectedOptionCategory1 = "testgnu.c.link.category.general"; String expectedOptionCategory1 = "testgnu.c.link.category.general";
String OptionId1A = "testgnu.c.link.option.libs"; String OptionId1A = "testgnu.c.link.option.libs";
String OptionId1B = "testgnu.c.link.option.paths"; String OptionId1B = "testgnu.c.link.option.paths";
String OptionId1C = "testgnu.c.link.option.userobjs"; String OptionId1C = "testgnu.c.link.option.userobjs";
String expectedOptionCmd1Aarr = "-l"; String expectedOptionCmd1Aarr = "-l";
String expectedOptionCmd1Barr = "-L"; String expectedOptionCmd1Barr = "-L";
String OptionId2 = "testgnu.c.link.option.defname"; String OptionId2 = "testgnu.c.link.option.defname";
String expectedOptionIdName2 = "Posix.Linker.Defname"; String expectedOptionIdName2 = "Posix.Linker.Defname";
String expectedOptionIdCmd2 = "-Wl,--output-def="; String expectedOptionIdCmd2 = "-Wl,--output-def=";
String OptionId3 = "testgnu.c.link.option.nostart"; String OptionId3 = "testgnu.c.link.option.nostart";
String expectedOptionIdName3 = "Posix.Linker.NoStartFiles"; String expectedOptionIdName3 = "Posix.Linker.NoStartFiles";
String expectedOptionIdCmd3 = "-nostartfiles"; String expectedOptionIdCmd3 = "-nostartfiles";
boolean expectedOptionIdValue3 = false; boolean expectedOptionIdValue3 = false;
String OptionId4 = "testgnu.c.link.option.shared"; String OptionId4 = "testgnu.c.link.option.shared";
String expectedOptionIdName4 = "Posix.Linker.Shared"; String expectedOptionIdName4 = "Posix.Linker.Shared";
String expectedOptionIdCmd4 = "-shared"; String expectedOptionIdCmd4 = "-shared";
boolean expectedOptionIdValue4 = false; boolean expectedOptionIdValue4 = false;
int expecectedNumTools = 5; int expecectedNumTools = 5;
int numOrderCLinkerTool = 2; int numOrderCLinkerTool = 2;
int expecectedCNature = ITool.FILTER_C; int expecectedCNature = ITool.FILTER_C;
@ -306,133 +305,133 @@ public class ManagedBuildCoreTests extends TestCase {
// //
for (int iconfig=0; iconfig < configs.length; iconfig++) { for (int iconfig=0; iconfig < configs.length; iconfig++) {
// Verify configuration attributes // Verify configuration attributes
// //
assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig])); assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand()); assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
assertEquals(expectedParserId, configs[iconfig].getErrorParserIds()); assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension)); assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension));
// Fetch toolchain and verify // Fetch toolchain and verify
// //
IToolChain toolChain = configs[iconfig].getToolChain(); IToolChain toolChain = configs[iconfig].getToolChain();
assertEquals(toolChain.getName(), (expectedToolChainName[iconfig])); assertEquals(toolChain.getName(), (expectedToolChainName[iconfig]));
List<String> expectedOSListarr = new ArrayList<String>(); List<String> expectedOSListarr = new ArrayList<String>();
String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$ String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
for (i = 0; i < expectedOSListTokens.length; ++i) { for (i = 0; i < expectedOSListTokens.length; ++i) {
expectedOSListarr.add(expectedOSListTokens[i].trim()); expectedOSListarr.add(expectedOSListTokens[i].trim());
} }
assertEquals(expectedParserId, configs[iconfig].getErrorParserIds()); assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
assertTrue(Arrays.equals(toolChain.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList]))); assertTrue(Arrays.equals(toolChain.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList)); assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList));
assertEquals(expectedScannerConfigDiscoveryProfileId, toolChain.getScannerConfigDiscoveryProfileId()); assertEquals(expectedScannerConfigDiscoveryProfileId, toolChain.getScannerConfigDiscoveryProfileId());
// Fetch and check platform // Fetch and check platform
// //
ITargetPlatform platform = toolChain.getTargetPlatform(); ITargetPlatform platform = toolChain.getTargetPlatform();
assertTrue(Arrays.equals(platform.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList]))); assertTrue(Arrays.equals(platform.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(platform.getArchList(), expectedArchList)); assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
String[] binaryParsers = platform.getBinaryParserList(); String[] binaryParsers = platform.getBinaryParserList();
assertEquals(binaryParsers.length, 1); assertEquals(binaryParsers.length, 1);
assertEquals(binaryParsers[0], expectedBinaryParser); assertEquals(binaryParsers[0], expectedBinaryParser);
assertEquals(platform.getName(), expectedPlatformName[iconfig]); assertEquals(platform.getName(), expectedPlatformName[iconfig]);
// Fetch and check builder // Fetch and check builder
// //
IBuilder builder = toolChain.getBuilder(); IBuilder builder = toolChain.getBuilder();
assertEquals(builder.getCommand(), expectedCommand); assertEquals(builder.getCommand(), expectedCommand);
assertEquals(builder.getArguments(), expectedArguments); assertEquals(builder.getArguments(), expectedArguments);
assertEquals(builder.getName(), expectedBuilderName[iconfig]); assertEquals(builder.getName(), expectedBuilderName[iconfig]);
// Fetch and check tools list // Fetch and check tools list
// //
ITool[] tools = toolChain.getTools(); ITool[] tools = toolChain.getTools();
assertEquals(tools.length, expecectedNumTools); assertEquals(tools.length, expecectedNumTools);
// Fetch and check the gnu C linker tool // Fetch and check the gnu C linker tool
// //
ITool tool; ITool tool;
ITool superTool; ITool superTool;
tool = tools[numOrderCLinkerTool]; tool = tools[numOrderCLinkerTool];
superTool = tool.getSuperClass(); superTool = tool.getSuperClass();
assertEquals(tool.getId(), expectedToolId1[iconfig]); assertEquals(tool.getId(), expectedToolId1[iconfig]);
assertEquals(superTool.getId(), expectedSuperToolId1); assertEquals(superTool.getId(), expectedSuperToolId1);
assertEquals(tool.getNatureFilter(), expecectedCNature); assertEquals(tool.getNatureFilter(), expecectedCNature);
assertEquals(tool.getOutputPrefix(), expectedToolOutputPrefix); assertEquals(tool.getOutputPrefix(), expectedToolOutputPrefix);
assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedToolOutput)); assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedToolOutput));
assertTrue(Arrays.equals(superTool.getAllInputExtensions(), expectedSuperInputExt1)); assertTrue(Arrays.equals(superTool.getAllInputExtensions(), expectedSuperInputExt1));
assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1); assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1); assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedSuperToolOutputExt1)); assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedSuperToolOutputExt1));
// Fetch and check an option category // Fetch and check an option category
// //
IOptionCategory[] optionCats = superTool.getChildCategories(); IOptionCategory[] optionCats = superTool.getChildCategories();
assertEquals(optionCats[0].getId(), (expectedOptionCategory1)); assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
// Fetch and check options customized for this tool // Fetch and check options customized for this tool
// //
IOption option; IOption option;
// Fetch the libs option and verify // Fetch the libs option and verify
// //
option = tool.getOptionById(OptionId1A); option = tool.getOptionById(OptionId1A);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.LIBRARIES)); assertEquals(option.getValueType(), (IOption.LIBRARIES));
assertEquals(option.getCommand(), (expectedOptionCmd1Aarr)); assertEquals(option.getCommand(), (expectedOptionCmd1Aarr));
assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE)); assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE));
// Fetch the libsearch option and verify // Fetch the libsearch option and verify
// //
option = tool.getOptionById(OptionId1B); option = tool.getOptionById(OptionId1B);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.STRING_LIST)); assertEquals(option.getValueType(), (IOption.STRING_LIST));
assertEquals(option.getCommand(), (expectedOptionCmd1Barr)); assertEquals(option.getCommand(), (expectedOptionCmd1Barr));
assertEquals(option.getBrowseType(), (IOption.BROWSE_DIR)); assertEquals(option.getBrowseType(), (IOption.BROWSE_DIR));
// Fetch the user objs option and verify // Fetch the user objs option and verify
// //
option = tool.getOptionById(OptionId1C); option = tool.getOptionById(OptionId1C);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.OBJECTS)); assertEquals(option.getValueType(), (IOption.OBJECTS));
assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE)); assertEquals(option.getBrowseType(), (IOption.BROWSE_FILE));
// Fetch the defname option and verify // Fetch the defname option and verify
// //
option = tool.getOptionById(OptionId2); option = tool.getOptionById(OptionId2);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.STRING)); assertEquals(option.getValueType(), (IOption.STRING));
assertEquals(option.getName(), (expectedOptionIdName2)); assertEquals(option.getName(), (expectedOptionIdName2));
assertEquals(option.getCommand(), (expectedOptionIdCmd2)); assertEquals(option.getCommand(), (expectedOptionIdCmd2));
// Fetch the nostartfiles option and verify // Fetch the nostartfiles option and verify
// //
option = tool.getOptionById(OptionId3); option = tool.getOptionById(OptionId3);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.BOOLEAN)); assertEquals(option.getValueType(), (IOption.BOOLEAN));
boolean optionDefaultValueb1 = option.getBooleanValue(); boolean optionDefaultValueb1 = option.getBooleanValue();
assertEquals(optionDefaultValueb1, (expectedOptionIdValue3)); assertEquals(optionDefaultValueb1, (expectedOptionIdValue3));
assertEquals(option.getName(), (expectedOptionIdName3)); assertEquals(option.getName(), (expectedOptionIdName3));
assertEquals(option.getCommand(), (expectedOptionIdCmd3)); assertEquals(option.getCommand(), (expectedOptionIdCmd3));
// Fetch the shared option and verify that it has the proper // Fetch the shared option and verify that it has the proper
// default value, which should overwrite the value set in the abstract // default value, which should overwrite the value set in the abstract
// project that its containing project is derived from // project that its containing project is derived from
// //
option = tool.getOptionById(OptionId4); option = tool.getOptionById(OptionId4);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.BOOLEAN)); assertEquals(option.getValueType(), (IOption.BOOLEAN));
boolean optionDefaultValueb2 = option.getBooleanValue(); boolean optionDefaultValueb2 = option.getBooleanValue();
assertEquals(optionDefaultValueb2, (expectedOptionIdValue4)); assertEquals(optionDefaultValueb2, (expectedOptionIdValue4));
assertEquals(option.getName(), (expectedOptionIdName4)); assertEquals(option.getName(), (expectedOptionIdName4));
assertEquals(option.getCommand(), (expectedOptionIdCmd4)); assertEquals(option.getCommand(), (expectedOptionIdCmd4));
} // end for } // end for
} //end routine } //end routine
/* /*
* Do a sanity check on the testgnu lib project type. * Do a sanity check on the testgnu lib project type.
*/ */
private void checkLibProjectType(IProjectType ptype) throws BuildException { private void checkLibProjectType(IProjectType ptype) throws BuildException {
@ -447,36 +446,36 @@ public class ManagedBuildCoreTests extends TestCase {
String[] expectedArchList = {"all"}; String[] expectedArchList = {"all"};
String expectedBinaryParser = "org.eclipse.cdt.core.ELF"; String expectedBinaryParser = "org.eclipse.cdt.core.ELF";
String[] expectedPlatformName = {"Dbg P", String[] expectedPlatformName = {"Dbg P",
"Rel P"}; "Rel P"};
String expectedCommand = "make"; String expectedCommand = "make";
String expectedArguments = "-k"; String expectedArguments = "-k";
String[] expectedBuilderName = {"Dbg B", String[] expectedBuilderName = {"Dbg B",
"Rel B"}; "Rel B"};
String expectedScannerConfigDiscoveryProfileId = "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile"; String expectedScannerConfigDiscoveryProfileId = "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile";
String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.cpp.compiler.lib.debug", String[] expectedToolId1 = {"cdt.managedbuild.tool.testgnu.cpp.compiler.lib.debug",
"cdt.managedbuild.tool.testgnu.cpp.compiler.lib.release"}; "cdt.managedbuild.tool.testgnu.cpp.compiler.lib.release"};
String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.cpp.compiler"; String expectedSuperToolId1 = "cdt.managedbuild.tool.testgnu.cpp.compiler";
String expectedSuperOutputFlag1 = "-o"; String expectedSuperOutputFlag1 = "-o";
String expectedSuperGetToolCommand1 = "g++"; String expectedSuperGetToolCommand1 = "g++";
String[] expectedSuperInputExt1 = {"c","C","cc","cxx","cpp"}; String[] expectedSuperInputExt1 = {"c","C","cc","cxx","cpp"};
String[] expectedSuperToolInterfaceExt1 = {"h","H","hpp"}; String[] expectedSuperToolInterfaceExt1 = {"h","H","hpp"};
String[] expectedSuperToolOutputExt1 = {"o"}; String[] expectedSuperToolOutputExt1 = {"o"};
String expectedOptionCategory1 = "testgnu.cpp.compiler.category.preprocessor"; String expectedOptionCategory1 = "testgnu.cpp.compiler.category.preprocessor";
String[] OptionId1 = {"testgnu.cpp.compiler.lib.debug.option.optimization.level", String[] OptionId1 = {"testgnu.cpp.compiler.lib.debug.option.optimization.level",
"testgnu.cpp.compiler.lib.release.option.optimization.level"}; "testgnu.cpp.compiler.lib.release.option.optimization.level"};
String[] expectedOptionIdValue1 = {"testgnu.cpp.compiler.optimization.level.none", String[] expectedOptionIdValue1 = {"testgnu.cpp.compiler.optimization.level.none",
"testgnu.cpp.compiler.optimization.level.most"}; "testgnu.cpp.compiler.optimization.level.most"};
String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most"; String expectedEnumList1 = "Posix.Optimize.None, Posix.Optimize.Optimize, Posix.Optimize.More, Posix.Optimize.Most";
int expectedSizeEnumList1 = 4; int expectedSizeEnumList1 = 4;
String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"}; String[] expectedOptionEnumCmd1arr = {"-O0", "-O3"};
String OptionId2 = "testgnu.cpp.compiler.option.other.other"; String OptionId2 = "testgnu.cpp.compiler.option.other.other";
String expectedOptionIdName2 = "OtherFlags"; String expectedOptionIdName2 = "OtherFlags";
String OptionId3 = "testgnu.cpp.compiler.option.other.verbose"; String OptionId3 = "testgnu.cpp.compiler.option.other.verbose";
String expectedOptionIdName3 = "Posix.Verbose"; String expectedOptionIdName3 = "Posix.Verbose";
String expectedOptionIdCmd3 = "-v"; String expectedOptionIdCmd3 = "-v";
boolean expectedOptionIdValue3 = false; boolean expectedOptionIdValue3 = false;
int expecectedNumTools = 4; int expecectedNumTools = 4;
int numOrderCppCompilerTool = 1; int numOrderCppCompilerTool = 1;
int expecectedCCNature = ITool.FILTER_CC; int expecectedCCNature = ITool.FILTER_CC;
@ -497,109 +496,109 @@ public class ManagedBuildCoreTests extends TestCase {
// //
for (int iconfig=0; iconfig < configs.length; iconfig++) { for (int iconfig=0; iconfig < configs.length; iconfig++) {
// Verify configuration attributes // Verify configuration attributes
// //
assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig])); assertEquals(configs[iconfig].getName(), (expectedConfigName[iconfig]));
assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand()); assertEquals(expectedCleanCmd, configs[iconfig].getCleanCommand());
assertEquals(expectedParserId, configs[iconfig].getErrorParserIds()); assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension)); assertEquals(configs[iconfig].getArtifactExtension(), (expectedArtifactExtension));
// Fetch toolchain and verify // Fetch toolchain and verify
// //
IToolChain toolChain = configs[iconfig].getToolChain(); IToolChain toolChain = configs[iconfig].getToolChain();
List<String> expectedOSListarr = new ArrayList<String>(); List<String> expectedOSListarr = new ArrayList<String>();
String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$ String[] expectedOSListTokens = expectedOSList.split(","); //$NON-NLS-1$
for (i = 0; i < expectedOSListTokens.length; ++i) { for (i = 0; i < expectedOSListTokens.length; ++i) {
expectedOSListarr.add(expectedOSListTokens[i].trim()); expectedOSListarr.add(expectedOSListTokens[i].trim());
} }
assertEquals(expectedParserId, configs[iconfig].getErrorParserIds()); assertEquals(expectedParserId, configs[iconfig].getErrorParserIds());
assertTrue(Arrays.equals(toolChain.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList]))); assertTrue(Arrays.equals(toolChain.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList)); assertTrue(Arrays.equals(toolChain.getArchList(), expectedArchList));
assertEquals(expectedScannerConfigDiscoveryProfileId, toolChain.getScannerConfigDiscoveryProfileId()); assertEquals(expectedScannerConfigDiscoveryProfileId, toolChain.getScannerConfigDiscoveryProfileId());
// Fetch and check platform // Fetch and check platform
// //
ITargetPlatform platform = toolChain.getTargetPlatform(); ITargetPlatform platform = toolChain.getTargetPlatform();
assertTrue(Arrays.equals(platform.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList]))); assertTrue(Arrays.equals(platform.getOSList(), expectedOSListarr.toArray(new String[expectedSizeOSList])));
assertTrue(Arrays.equals(platform.getArchList(), expectedArchList)); assertTrue(Arrays.equals(platform.getArchList(), expectedArchList));
String[] binaryParsers = platform.getBinaryParserList(); String[] binaryParsers = platform.getBinaryParserList();
assertEquals(binaryParsers.length, 1); assertEquals(binaryParsers.length, 1);
assertEquals(binaryParsers[0], expectedBinaryParser); assertEquals(binaryParsers[0], expectedBinaryParser);
assertEquals(platform.getName(), expectedPlatformName[iconfig]); assertEquals(platform.getName(), expectedPlatformName[iconfig]);
// Fetch and check builder // Fetch and check builder
// //
IBuilder builder = toolChain.getBuilder(); IBuilder builder = toolChain.getBuilder();
assertEquals(builder.getCommand(), expectedCommand); assertEquals(builder.getCommand(), expectedCommand);
assertEquals(builder.getArguments(), expectedArguments); assertEquals(builder.getArguments(), expectedArguments);
assertEquals(builder.getName(), expectedBuilderName[iconfig]); assertEquals(builder.getName(), expectedBuilderName[iconfig]);
// Fetch and check tools list // Fetch and check tools list
// //
ITool[] tools = toolChain.getTools(); ITool[] tools = toolChain.getTools();
assertEquals(tools.length, expecectedNumTools); assertEquals(tools.length, expecectedNumTools);
// Fetch and check the gnu Cpp compiler tool // Fetch and check the gnu Cpp compiler tool
// //
ITool tool; ITool tool;
ITool superTool; ITool superTool;
tool = tools[numOrderCppCompilerTool]; tool = tools[numOrderCppCompilerTool];
superTool = tool.getSuperClass(); superTool = tool.getSuperClass();
assertEquals(tool.getId(), expectedToolId1[iconfig]); assertEquals(tool.getId(), expectedToolId1[iconfig]);
assertEquals(superTool.getId(), expectedSuperToolId1); assertEquals(superTool.getId(), expectedSuperToolId1);
assertEquals(tool.getNatureFilter(), expecectedCCNature); assertEquals(tool.getNatureFilter(), expecectedCCNature);
assertTrue(Arrays.equals(superTool.getAllInputExtensions(), expectedSuperInputExt1)); assertTrue(Arrays.equals(superTool.getAllInputExtensions(), expectedSuperInputExt1));
assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1); assertEquals(superTool.getOutputFlag(), expectedSuperOutputFlag1);
assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1); assertEquals(superTool.getToolCommand(), expectedSuperGetToolCommand1);
assertTrue(Arrays.equals(superTool.getAllDependencyExtensions(), expectedSuperToolInterfaceExt1)); assertTrue(Arrays.equals(superTool.getAllDependencyExtensions(), expectedSuperToolInterfaceExt1));
assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedSuperToolOutputExt1)); assertTrue(Arrays.equals(superTool.getOutputsAttribute(), expectedSuperToolOutputExt1));
// Fetch and check an option category // Fetch and check an option category
// //
IOptionCategory[] optionCats = superTool.getChildCategories(); IOptionCategory[] optionCats = superTool.getChildCategories();
assertEquals(optionCats[0].getId(), (expectedOptionCategory1)); assertEquals(optionCats[0].getId(), (expectedOptionCategory1));
// Fetch and check options customized for this tool // Fetch and check options customized for this tool
// //
IOption option; IOption option;
// Fetch the optimization level option and verify that it has the proper // Fetch the optimization level option and verify that it has the proper
// default value, which should overwrite the value set in the abstract // default value, which should overwrite the value set in the abstract
// project that its containing project is derived from // project that its containing project is derived from
// //
option = tool.getOptionById(OptionId1[iconfig]); option = tool.getOptionById(OptionId1[iconfig]);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
String optionDefaultValue = (String)option.getDefaultValue(); String optionDefaultValue = (String)option.getDefaultValue();
assertEquals(option.getValueType(), (IOption.ENUMERATED)); assertEquals(option.getValueType(), (IOption.ENUMERATED));
assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig])); assertEquals(optionDefaultValue, (expectedOptionIdValue1[iconfig]));
String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue); String optionEnumCmd1 = option.getEnumCommand(optionDefaultValue);
assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig])); assertEquals(optionEnumCmd1, (expectedOptionEnumCmd1arr[iconfig]));
List<String> expectedEnumList1arr = new ArrayList<String>(); List<String> expectedEnumList1arr = new ArrayList<String>();
String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$ String[] expectedEnumList1Tokens = expectedEnumList1.split(","); //$NON-NLS-1$
for (i = 0; i < expectedEnumList1Tokens.length; ++i) { for (i = 0; i < expectedEnumList1Tokens.length; ++i) {
expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim()); expectedEnumList1arr.add(expectedEnumList1Tokens[i].trim());
} }
assertTrue(Arrays.equals(option.getApplicableValues(), expectedEnumList1arr.toArray(new String[expectedSizeEnumList1]))); assertTrue(Arrays.equals(option.getApplicableValues(), expectedEnumList1arr.toArray(new String[expectedSizeEnumList1])));
// Fetch the other flags option and verify // Fetch the other flags option and verify
// //
option = tool.getOptionById(OptionId2); option = tool.getOptionById(OptionId2);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.STRING)); assertEquals(option.getValueType(), (IOption.STRING));
assertEquals(option.getName(), (expectedOptionIdName2)); assertEquals(option.getName(), (expectedOptionIdName2));
// Fetch the verbose option and verify // Fetch the verbose option and verify
// //
option = tool.getOptionById(OptionId3); option = tool.getOptionById(OptionId3);
assertTrue(option.isExtensionElement()); assertTrue(option.isExtensionElement());
assertEquals(option.getValueType(), (IOption.BOOLEAN)); assertEquals(option.getValueType(), (IOption.BOOLEAN));
boolean optionDefaultValueb = option.getBooleanValue(); boolean optionDefaultValueb = option.getBooleanValue();
assertEquals(optionDefaultValueb, (expectedOptionIdValue3)); assertEquals(optionDefaultValueb, (expectedOptionIdValue3));
assertEquals(option.getName(), (expectedOptionIdName3)); assertEquals(option.getName(), (expectedOptionIdName3));
assertEquals(option.getCommand(), (expectedOptionIdCmd3)); assertEquals(option.getCommand(), (expectedOptionIdCmd3));
} // end for } // end for
} // end routine } // end routine