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

Updated MBS test cases to report when some preconditions fail.

This commit is contained in:
Andrew Gvozdev 2012-12-06 16:46:10 -05:00
parent 84c076ae46
commit 618d199135
3 changed files with 72 additions and 7 deletions

View file

@ -58,6 +58,9 @@ public class AllManagedBuildTests {
TestSuite suite = new TestSuite("Test for org.eclipse.cdt.managedbuild.core.tests"); TestSuite suite = new TestSuite("Test for org.eclipse.cdt.managedbuild.core.tests");
//$JUnit-BEGIN$ //$JUnit-BEGIN$
// Preconditions
suite.addTestSuite(Preconditions.class);
// build.core.scannerconfig.tests // build.core.scannerconfig.tests
suite.addTest(CfgScannerConfigProfileManagerTests.suite()); suite.addTest(CfgScannerConfigProfileManagerTests.suite());
suite.addTestSuite(GCCSpecsConsoleParserTest.class); suite.addTestSuite(GCCSpecsConsoleParserTest.class);

View file

@ -0,0 +1,62 @@
/*******************************************************************************
* Copyright (c) 2012,2012 Andrew Gvozdev 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:
* Andrew Gvozdev - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.tests.suite;
import java.util.Arrays;
import java.util.Set;
import java.util.TreeSet;
import junit.framework.TestCase;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.utils.PathUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
public class Preconditions extends TestCase {
@Override
protected void setUp() throws Exception {
}
/**
* Many MBS tests run make and gcc and will inspect resulting artifacts of the build.
* Make sure GNU tool-chain is available for the tests.
*/
public void testGnu() {
IPath make = PathUtil.findProgramLocation("make");
assertNotNull("Precodition FAILED - program 'make' is not found in path.", make);
IPath gcc = PathUtil.findProgramLocation("gcc");
assertNotNull("Precodition FAILED - program 'gcc' is not found in path.", gcc);
}
/**
* Generated makefiles will often contain dependency lines for all file extension
* corresponding content types set in preferences. Make sure that this set has not been
* changed when the tests are run.
*/
public void testContentTypes() {
Set<String> fileExts = new TreeSet<String>();
IContentTypeManager manager = Platform.getContentTypeManager();
IContentType contentTypeCpp = manager.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
fileExts.addAll(Arrays.asList(contentTypeCpp.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
IContentType contentTypeC = manager.getContentType(CCorePlugin.CONTENT_TYPE_CSOURCE);
fileExts.addAll(Arrays.asList(contentTypeC.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
Set<String> expectedExts = new TreeSet<String>(Arrays.asList(new String[] {"C", "c", "c++", "cc", "cpp", "cxx"}));
assertEquals("Precodition FAILED - Content Types do not match expected defaults.", expectedExts.toString(), fileExts.toString());
}
}

View file

@ -51,8 +51,8 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
private static final String PROVIDER_ID = "provider.id"; private static final String PROVIDER_ID = "provider.id";
private static final String PROVIDER_NAME = "provider name"; private static final String PROVIDER_NAME = "provider name";
private static final String LANGUAGE_ID = "language.test.id"; private static final String LANGUAGE_ID = "language.test.id";
private static final String CUSTOM_PARAMETER = "customParameter"; private static final String CUSTOM_COMMAND_1 = "echo 1";
private static final String CUSTOM_PARAMETER_2 = "customParameter2"; private static final String CUSTOM_COMMAND_2 = "echo 2";
private static final String ELEM_TEST = "test"; private static final String ELEM_TEST = "test";
// those attributes must match that in AbstractBuiltinSpecsDetector // those attributes must match that in AbstractBuiltinSpecsDetector
@ -203,7 +203,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
List<String> languages = new ArrayList<String>(); List<String> languages = new ArrayList<String>();
languages.add(LANGUAGE_ID); languages.add(LANGUAGE_ID);
Map<String, String> properties = new HashMap<String, String>(); Map<String, String> properties = new HashMap<String, String>();
properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER); properties.put(ATTR_PARAMETER, CUSTOM_COMMAND_1);
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>(); List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY); ICLanguageSettingEntry entry = new CMacroEntry("MACRO", "VALUE", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY);
entries.add(entry); entries.add(entry);
@ -213,13 +213,13 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
assertEquals(PROVIDER_NAME, provider.getName()); assertEquals(PROVIDER_NAME, provider.getName());
assertEquals(languages, provider.getLanguageScope()); assertEquals(languages, provider.getLanguageScope());
assertEquals(entries, provider.getSettingEntries(null, null, null)); assertEquals(entries, provider.getSettingEntries(null, null, null));
assertEquals(CUSTOM_PARAMETER, provider.getCommand()); assertEquals(CUSTOM_COMMAND_1, provider.getCommand());
assertEquals(false, provider.isConsoleEnabled()); assertEquals(false, provider.isConsoleEnabled());
assertEquals(false, provider.isExecuted()); assertEquals(false, provider.isExecuted());
// setters // setters
provider.setCommand(CUSTOM_PARAMETER_2); provider.setCommand(CUSTOM_COMMAND_2);
assertEquals(CUSTOM_PARAMETER_2, provider.getCommand()); assertEquals(CUSTOM_COMMAND_2, provider.getCommand());
provider.setConsoleEnabled(true); provider.setConsoleEnabled(true);
assertEquals(true, provider.isConsoleEnabled()); assertEquals(true, provider.isConsoleEnabled());
@ -259,7 +259,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
// configure provider // configure provider
Map<String, String> properties = new HashMap<String, String>(); Map<String, String> properties = new HashMap<String, String>();
properties.put(ATTR_PARAMETER, CUSTOM_PARAMETER); properties.put(ATTR_PARAMETER, CUSTOM_COMMAND_1);
provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties); provider.configureProvider(PROVIDER_ID, PROVIDER_NAME, languages, entries, properties);
assertEquals(false, provider.isConsoleEnabled()); assertEquals(false, provider.isConsoleEnabled());
provider.setConsoleEnabled(true); provider.setConsoleEnabled(true);