diff options
author | Marc-Andre Laperle | 2015-03-06 04:13:11 +0000 |
---|---|---|
committer | Marc-Andre Laperle | 2015-03-24 20:41:21 +0000 |
commit | bb69775934ccc1a9a049bcb58ae0e42c4cb24de3 (patch) | |
tree | 9f4159c408905f41bb8993804dd05aecfd9f33f1 /build/org.eclipse.cdt.autotools.tests | |
parent | 3c13a7101757355463d68dfdc626f6cee5b57137 (diff) | |
download | org.eclipse.cdt-bb69775934ccc1a9a049bcb58ae0e42c4cb24de3.tar.gz org.eclipse.cdt-bb69775934ccc1a9a049bcb58ae0e42c4cb24de3.tar.xz org.eclipse.cdt-bb69775934ccc1a9a049bcb58ae0e42c4cb24de3.zip |
Bug 426627 - GCC Build Output Parser doesn't work with libtool
Change-Id: Id1fa62c15c57d84c8a646bb41096c887714d4474
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Diffstat (limited to 'build/org.eclipse.cdt.autotools.tests')
-rw-r--r-- | build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF | 3 | ||||
-rw-r--r-- | build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java | 86 |
2 files changed, 88 insertions, 1 deletions
diff --git a/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF index 8afc5f63fec..2d419f51a30 100644 --- a/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.tests/META-INF/MANIFEST.MF @@ -20,7 +20,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.make.ui, org.eclipse.ui.workbench.texteditor, org.eclipse.cdt.core, - org.eclipse.cdt.autotools.ui;bundle-version="1.0.0" + org.eclipse.cdt.autotools.ui;bundle-version="1.0.0", + org.eclipse.cdt.core.tests Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Export-Package: org.eclipse.cdt.autotools.tests, diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java new file mode 100644 index 00000000000..7263c52892c --- /dev/null +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/LibtoolGCCBuildCommandParserTest.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2005, 2015 IBM 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: + * Marc-Andre Laperle (Ericsson) - initial API and implementation adapted from GCCBuildCommandParserTest + *******************************************************************************/ + +package org.eclipse.cdt.autotools.tests; + +import java.util.List; + +import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.CIncludePathEntry; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICLanguageSetting; +import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; + +/** + * Test cases to test libtool build command parser. + */ +public class LibtoolGCCBuildCommandParserTest extends BaseTestCase { + // ID of the parser taken from the extension point + private static final String BUILD_COMMAND_PARSER_EXT = "org.eclipse.cdt.autotools.core.LibtoolGCCBuildCommandParser"; //$NON-NLS-1$ + + /** + * Helper method to fetch configuration descriptions. + */ + private ICConfigurationDescription[] getConfigurationDescriptions(IProject project) { + CoreModel coreModel = CoreModel.getDefault(); + ICProjectDescriptionManager mngr = coreModel.getProjectDescriptionManager(); + // project description + ICProjectDescription projectDescription = mngr.getProjectDescription(project, false); + assertNotNull(projectDescription); + assertEquals(1, projectDescription.getConfigurations().length); + // configuration description + ICConfigurationDescription[] cfgDescriptions = projectDescription.getConfigurations(); + return cfgDescriptions; + } + + /** + * Test possible variations of libtool/compiler command. + */ + public void testProcessLine() throws Exception { + // Create model project and accompanied descriptions + String projectName = getName(); + IProject project = ResourceHelper.createCDTProjectWithConfig(projectName); + ICConfigurationDescription[] cfgDescriptions = getConfigurationDescriptions(project); + ICConfigurationDescription cfgDescription = cfgDescriptions[0]; + + IFile file1=ResourceHelper.createFile(project, "file1.cpp"); + IFile file2=ResourceHelper.createFile(project, "file2.cpp"); + @SuppressWarnings("deprecation") + ICLanguageSetting ls = cfgDescription.getLanguageSettingForFile(file1.getProjectRelativePath(), true); + String languageId = ls.getLanguageId(); + + // create GCCBuildCommandParser + GCCBuildCommandParser parser = (GCCBuildCommandParser) LanguageSettingsManager.getExtensionProviderCopy(BUILD_COMMAND_PARSER_EXT, true); + + // parse line + parser.startup(cfgDescription, null); + parser.processLine("libtool: compile: gcc -I/path0 file1.cpp"); + parser.processLine("libtool: compile: g++ -I/path0 file2.cpp"); + parser.shutdown(); + { + List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file1, languageId); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); + } + { + List<ICLanguageSettingEntry> entries = parser.getSettingEntries(cfgDescription, file2, languageId); + assertEquals(new CIncludePathEntry("/path0", 0), entries.get(0)); + } + } + +}
\ No newline at end of file |