From 9e303185f96303b772b5c3d3a3a8de7b7ee9e358 Mon Sep 17 00:00:00 2001 From: Martin Weber Date: Tue, 30 Jun 2020 20:00:23 +0200 Subject: Bug 564002: Restore the default pattern of the surefire-plugin Sets the pattern to the default of upcoming tycho 2.0 in advance. Signed-off-by: Martin Weber Change-Id: I31b3fc733d0cb888fbf6f566995ce2043f6cd621 --- .../autotools/tests/AutomatedIntegrationSuite.java | 8 +- .../cdt/autotools/tests/AutotoolsProject0Test.java | 86 + .../cdt/autotools/tests/AutotoolsProject1Test.java | 89 + .../cdt/autotools/tests/AutotoolsProject2Test.java | 104 ++ .../cdt/autotools/tests/AutotoolsProjectTest0.java | 86 - .../cdt/autotools/tests/AutotoolsProjectTest1.java | 89 - .../cdt/autotools/tests/AutotoolsProjectTest2.java | 104 -- .../autotools/tests/editors/EditorTestSuite.java | 22 + .../cdt/autotools/tests/editors/EditorTests.java | 22 - .../ui/tests/AutomatedIntegrationSuite.java | 27 +- .../ui/tests/SetConfigurationParameter.java | 485 ----- .../ui/tests/SetConfigurationParameterTest.java | 487 +++++ .../autotools/ui/tests/TestEnvironmentVars.java | 2 + .../cdt/autotools/ui/tests/TestMakeTargets.java | 2 + .../cdt/autotools/ui/tests/TestToolActions.java | 2 + .../ui/tests/autoconf/AutoconfTestSuite.java | 23 + .../autotools/ui/tests/autoconf/AutoconfTests.java | 23 - .../ui/tests/autoconf/BaseParserTest.java | 20 + .../autotools/ui/tests/autoconf/TestTokenizer.java | 20 + .../make/core/tests/AutomatedIntegrationSuite.java | 4 +- .../ScannerDiscoveryTestSuite.java | 32 + .../scannerdiscovery/ScannerDiscoveryTests.java | 32 - .../tests/suite/AutomatedIntegrationSuite.java | 22 +- .../suite/ManagedBuilderPreconditionsTests.java | 70 + .../managedbuilder/tests/suite/Preconditions.java | 66 - .../core/regressions/Bug_303953.java | 82 - .../core/regressions/Bug_303953Test.java | 82 + .../core/regressions/RegressionTestSuite.java | 41 + .../core/regressions/RegressionTests.java | 41 - .../core/tests/ManagedBuildCore20Tests.java | 1950 ++++++++++++++++++++ .../core/tests/ManagedBuildCoreTests20.java | 1950 -------------------- .../ManagedBuildCoreTests_SharedToolOptions.java | 566 ------ .../ManagedBuildCore_SharedToolOptionsTests.java | 566 ++++++ .../AllLanguageSettingsProvidersMBSTestSuite.java | 37 + .../AllLanguageSettingsProvidersMBSTests.java | 37 - .../tests/AllTemplateEngineTestSuite.java | 50 + .../tests/AllTemplateEngineTests.java | 50 - 37 files changed, 3705 insertions(+), 3674 deletions(-) create mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject0Test.java create mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject1Test.java create mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject2Test.java delete mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest0.java delete mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest1.java delete mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest2.java create mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTestSuite.java delete mode 100644 build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTests.java delete mode 100644 build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java create mode 100644 build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java create mode 100644 build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTestSuite.java delete mode 100644 build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTests.java create mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTestSuite.java delete mode 100644 build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/Preconditions.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953Test.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTestSuite.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTests.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore20Tests.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests_SharedToolOptions.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTestSuite.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTests.java create mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTestSuite.java delete mode 100644 build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTests.java (limited to 'build') diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutomatedIntegrationSuite.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutomatedIntegrationSuite.java index c234c492750..d73d172b525 100644 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutomatedIntegrationSuite.java +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutomatedIntegrationSuite.java @@ -13,14 +13,14 @@ *******************************************************************************/ package org.eclipse.cdt.autotools.tests; -import org.eclipse.cdt.autotools.tests.editors.EditorTests; +import org.eclipse.cdt.autotools.tests.editors.EditorTestSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; /** On Windows requires either Cygwin or MinGW to be in PATH */ @RunWith(Suite.class) -@Suite.SuiteClasses({ AutotoolsProjectTest0.class, AutotoolsProjectNatureTest.class, AutotoolsProjectTest1.class, - AutotoolsProjectTest2.class, AutotoolsVirtualFolderTest.class, AutotoolsEnvironmentVarTest.class, - LibtoolGCCBuildCommandParserTest.class, UpdateConfigureTest.class, EditorTests.class }) +@Suite.SuiteClasses({ AutotoolsProject0Test.class, AutotoolsProjectNatureTest.class, AutotoolsProject1Test.class, + AutotoolsProject2Test.class, AutotoolsVirtualFolderTest.class, AutotoolsEnvironmentVarTest.class, + LibtoolGCCBuildCommandParserTest.class, UpdateConfigureTest.class, EditorTestSuite.class }) public class AutomatedIntegrationSuite { } diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject0Test.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject0Test.java new file mode 100644 index 00000000000..cb3a95b6459 --- /dev/null +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject0Test.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (c) 2008, 2015 Red Hat Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Incorporated - initial API and implementation + * Marc-Andre Laperle - Fix failing test on Windows + *******************************************************************************/ +package org.eclipse.cdt.autotools.tests; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class AutotoolsProject0Test { + + private IProject testProject; + + @Before + public void setUp() throws Exception { + if (!ProjectTools.setup()) + fail("could not perform basic project workspace setup"); + testProject = ProjectTools.createProject("testProject0"); + if (testProject == null) { + fail("Unable to create test project"); + } + testProject.open(new NullProgressMonitor()); + } + + /** + * Test sample project which has a hello world program. The top-level + * configure is found in the top-level directory. The hello world source + * is found in sample/hello.c. + * @throws Exception + */ + @Test + public void testAutotoolsProject0() throws Exception { + Path p = new Path("zip/project1.zip"); + ProjectTools.addSourceContainerWithImport(testProject, null, p, true); + assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); + org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("ChangeLog"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("configure"); + ProjectTools.markExecutable(testProject, "configure"); + ProjectTools.markExecutable(testProject, "config.guess"); + ProjectTools.markExecutable(testProject, "config.sub"); + ProjectTools.markExecutable(testProject, "missing"); + ProjectTools.markExecutable(testProject, "mkinstalldirs"); + ProjectTools.markExecutable(testProject, "install-sh"); + assertTrue(ProjectTools.build()); + x = new org.eclipse.core.runtime.Path("config.status"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("Makefile"); + assertTrue(testProject.exists(x)); + String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; + x = new org.eclipse.core.runtime.Path("sample/a.out" + extension); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("sample/Makefile"); + assertTrue(testProject.exists(x)); + } + + @After + public void tearDown() throws Exception { + testProject.refreshLocal(IResource.DEPTH_INFINITE, null); + try { + testProject.delete(true, true, null); + } catch (Exception e) { + //FIXME: Why does a ResourceException occur when deleting the project?? + } + } +} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject1Test.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject1Test.java new file mode 100644 index 00000000000..07fb1dba23e --- /dev/null +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject1Test.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2008, 2015 Red Hat Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Incorporated - initial API and implementation + * Marc-Andre Laperle - Fix failing test on Windows + *******************************************************************************/ +package org.eclipse.cdt.autotools.tests; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class AutotoolsProject1Test { + + private IProject testProject; + + @Before + public void setUp() throws Exception { + if (!ProjectTools.setup()) + fail("could not perform basic project workspace setup"); + testProject = ProjectTools.createProject("testProject1"); + if (testProject == null) { + fail("Unable to create test project"); + } + testProject.open(new NullProgressMonitor()); + } + + /** + * Test sample project which has a hello world program. The top-level + * configure is found in the subdirectory src which also contains the + * subdirectory sample. The hello world source is found in + * src/sample/hello.c so configuration must create multiple + * Makefiles. + * @throws Exception + */ + @Test + public void testAutotoolsProject1() throws Exception { + Path p = new Path("zip/project1.zip"); + ProjectTools.addSourceContainerWithImport(testProject, "src", p, true); + assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); + org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/configure"); + ProjectTools.setConfigDir(testProject, "src"); + ProjectTools.markExecutable(testProject, "src/configure"); + ProjectTools.markExecutable(testProject, "src/config.guess"); + ProjectTools.markExecutable(testProject, "src/config.sub"); + ProjectTools.markExecutable(testProject, "src/missing"); + ProjectTools.markExecutable(testProject, "src/mkinstalldirs"); + ProjectTools.markExecutable(testProject, "src/install-sh"); + assertTrue(ProjectTools.build()); + x = new org.eclipse.core.runtime.Path("config.status"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("Makefile"); + assertTrue(testProject.exists(x)); + String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; + x = new org.eclipse.core.runtime.Path("sample/a.out" + extension); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("sample/Makefile"); + assertTrue(testProject.exists(x)); + } + + @After + public void tearDown() throws Exception { + testProject.refreshLocal(IResource.DEPTH_INFINITE, null); + try { + testProject.delete(true, true, null); + } catch (Exception e) { + //FIXME: Why does a ResourceException occur when deleting the project?? + } + } +} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject2Test.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject2Test.java new file mode 100644 index 00000000000..832fa41b852 --- /dev/null +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProject2Test.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2008, 2015 Red Hat Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Incorporated - initial API and implementation + * Marc-Andre Laperle - Fix failing test on Windows + *******************************************************************************/ +package org.eclipse.cdt.autotools.tests; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +// This test verifies an autogen.sh project that builds configure, but +// does not run it. +public class AutotoolsProject2Test { + + private IProject testProject; + + @Before + public void setUp() throws Exception { + if (!ProjectTools.setup()) + fail("could not perform basic project workspace setup"); + testProject = ProjectTools.createProject("testProject2"); + if (testProject == null) { + fail("Unable to create test project"); + } + testProject.open(new NullProgressMonitor()); + } + + /** + * Test sample project which has a hello world program. The top-level + * contains autogen.sh which will build configure, but not run it. + * The hello world source is found in + * src/sample/hello.c so configuration must create multiple + * Makefiles. + * @throws Exception + */ + @Test + public void testAutotoolsProject2() throws Exception { + Path p = new Path("zip/project2.zip"); + ProjectTools.addSourceContainerWithImport(testProject, "src", p); + assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); + org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/configure"); + ProjectTools.setConfigDir(testProject, "src"); + ProjectTools.markExecutable(testProject, "src/autogen.sh"); + x = new org.eclipse.core.runtime.Path("src/configure"); + assertFalse(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/Makefile.in"); + assertFalse(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/sample/Makefile.in"); + assertFalse(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/aclocal.m4"); + assertFalse(testProject.exists(x)); + assertTrue(ProjectTools.build()); + x = new org.eclipse.core.runtime.Path("src/configure"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/Makefile.in"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/sample/Makefile.in"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("src/aclocal.m4"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("config.status"); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("Makefile"); + assertTrue(testProject.exists(x)); + String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; + x = new org.eclipse.core.runtime.Path("sample/a.out" + extension); + assertTrue(testProject.exists(x)); + x = new org.eclipse.core.runtime.Path("sample/Makefile"); + assertTrue(testProject.exists(x)); + } + + @After + public void tearDown() throws Exception { + testProject.refreshLocal(IResource.DEPTH_INFINITE, null); + try { + testProject.delete(true, true, null); + } catch (Exception e) { + //FIXME: Why does a ResourceException occur when deleting the project?? + } + } + +} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest0.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest0.java deleted file mode 100644 index 7fcbbbce0b5..00000000000 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest0.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Red Hat Inc. and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat Incorporated - initial API and implementation - * Marc-Andre Laperle - Fix failing test on Windows - *******************************************************************************/ -package org.eclipse.cdt.autotools.tests; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class AutotoolsProjectTest0 { - - private IProject testProject; - - @Before - public void setUp() throws Exception { - if (!ProjectTools.setup()) - fail("could not perform basic project workspace setup"); - testProject = ProjectTools.createProject("testProject0"); - if (testProject == null) { - fail("Unable to create test project"); - } - testProject.open(new NullProgressMonitor()); - } - - /** - * Test sample project which has a hello world program. The top-level - * configure is found in the top-level directory. The hello world source - * is found in sample/hello.c. - * @throws Exception - */ - @Test - public void testAutotoolsProject0() throws Exception { - Path p = new Path("zip/project1.zip"); - ProjectTools.addSourceContainerWithImport(testProject, null, p, true); - assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); - org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("ChangeLog"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("configure"); - ProjectTools.markExecutable(testProject, "configure"); - ProjectTools.markExecutable(testProject, "config.guess"); - ProjectTools.markExecutable(testProject, "config.sub"); - ProjectTools.markExecutable(testProject, "missing"); - ProjectTools.markExecutable(testProject, "mkinstalldirs"); - ProjectTools.markExecutable(testProject, "install-sh"); - assertTrue(ProjectTools.build()); - x = new org.eclipse.core.runtime.Path("config.status"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("Makefile"); - assertTrue(testProject.exists(x)); - String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; - x = new org.eclipse.core.runtime.Path("sample/a.out" + extension); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("sample/Makefile"); - assertTrue(testProject.exists(x)); - } - - @After - public void tearDown() throws Exception { - testProject.refreshLocal(IResource.DEPTH_INFINITE, null); - try { - testProject.delete(true, true, null); - } catch (Exception e) { - //FIXME: Why does a ResourceException occur when deleting the project?? - } - } -} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest1.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest1.java deleted file mode 100644 index 44b99e9a190..00000000000 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest1.java +++ /dev/null @@ -1,89 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Red Hat Inc. and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat Incorporated - initial API and implementation - * Marc-Andre Laperle - Fix failing test on Windows - *******************************************************************************/ -package org.eclipse.cdt.autotools.tests; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class AutotoolsProjectTest1 { - - private IProject testProject; - - @Before - public void setUp() throws Exception { - if (!ProjectTools.setup()) - fail("could not perform basic project workspace setup"); - testProject = ProjectTools.createProject("testProject1"); - if (testProject == null) { - fail("Unable to create test project"); - } - testProject.open(new NullProgressMonitor()); - } - - /** - * Test sample project which has a hello world program. The top-level - * configure is found in the subdirectory src which also contains the - * subdirectory sample. The hello world source is found in - * src/sample/hello.c so configuration must create multiple - * Makefiles. - * @throws Exception - */ - @Test - public void testAutotoolsProject1() throws Exception { - Path p = new Path("zip/project1.zip"); - ProjectTools.addSourceContainerWithImport(testProject, "src", p, true); - assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); - org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/configure"); - ProjectTools.setConfigDir(testProject, "src"); - ProjectTools.markExecutable(testProject, "src/configure"); - ProjectTools.markExecutable(testProject, "src/config.guess"); - ProjectTools.markExecutable(testProject, "src/config.sub"); - ProjectTools.markExecutable(testProject, "src/missing"); - ProjectTools.markExecutable(testProject, "src/mkinstalldirs"); - ProjectTools.markExecutable(testProject, "src/install-sh"); - assertTrue(ProjectTools.build()); - x = new org.eclipse.core.runtime.Path("config.status"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("Makefile"); - assertTrue(testProject.exists(x)); - String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; - x = new org.eclipse.core.runtime.Path("sample/a.out" + extension); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("sample/Makefile"); - assertTrue(testProject.exists(x)); - } - - @After - public void tearDown() throws Exception { - testProject.refreshLocal(IResource.DEPTH_INFINITE, null); - try { - testProject.delete(true, true, null); - } catch (Exception e) { - //FIXME: Why does a ResourceException occur when deleting the project?? - } - } -} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest2.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest2.java deleted file mode 100644 index 99c1ef2cd8f..00000000000 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/AutotoolsProjectTest2.java +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Red Hat Inc. and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat Incorporated - initial API and implementation - * Marc-Andre Laperle - Fix failing test on Windows - *******************************************************************************/ -package org.eclipse.cdt.autotools.tests; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.eclipse.cdt.autotools.core.AutotoolsNewProjectNature; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -// This test verifies an autogen.sh project that builds configure, but -// does not run it. -public class AutotoolsProjectTest2 { - - private IProject testProject; - - @Before - public void setUp() throws Exception { - if (!ProjectTools.setup()) - fail("could not perform basic project workspace setup"); - testProject = ProjectTools.createProject("testProject2"); - if (testProject == null) { - fail("Unable to create test project"); - } - testProject.open(new NullProgressMonitor()); - } - - /** - * Test sample project which has a hello world program. The top-level - * contains autogen.sh which will build configure, but not run it. - * The hello world source is found in - * src/sample/hello.c so configuration must create multiple - * Makefiles. - * @throws Exception - */ - @Test - public void testAutotoolsProject2() throws Exception { - Path p = new Path("zip/project2.zip"); - ProjectTools.addSourceContainerWithImport(testProject, "src", p); - assertTrue(testProject.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)); - org.eclipse.core.runtime.Path x = new org.eclipse.core.runtime.Path("src/ChangeLog"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/configure"); - ProjectTools.setConfigDir(testProject, "src"); - ProjectTools.markExecutable(testProject, "src/autogen.sh"); - x = new org.eclipse.core.runtime.Path("src/configure"); - assertFalse(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/Makefile.in"); - assertFalse(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/sample/Makefile.in"); - assertFalse(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/aclocal.m4"); - assertFalse(testProject.exists(x)); - assertTrue(ProjectTools.build()); - x = new org.eclipse.core.runtime.Path("src/configure"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/Makefile.in"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/sample/Makefile.in"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("src/aclocal.m4"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("config.status"); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("Makefile"); - assertTrue(testProject.exists(x)); - String extension = Platform.getOS().equals(Platform.OS_WIN32) ? ".exe" : ""; - x = new org.eclipse.core.runtime.Path("sample/a.out" + extension); - assertTrue(testProject.exists(x)); - x = new org.eclipse.core.runtime.Path("sample/Makefile"); - assertTrue(testProject.exists(x)); - } - - @After - public void tearDown() throws Exception { - testProject.refreshLocal(IResource.DEPTH_INFINITE, null); - try { - testProject.delete(true, true, null); - } catch (Exception e) { - //FIXME: Why does a ResourceException occur when deleting the project?? - } - } - -} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTestSuite.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTestSuite.java new file mode 100644 index 00000000000..6647e5de52c --- /dev/null +++ b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTestSuite.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2008, 2015 Red Hat Inc.. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Incorporated - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.autotools.tests.editors; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ AutomakeColourizationTests.class, AutomakeTextHoverTest.class, AutomakeEditorTests.class }) +public class EditorTestSuite { +} diff --git a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTests.java b/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTests.java deleted file mode 100644 index 0a41b9b1968..00000000000 --- a/build/org.eclipse.cdt.autotools.tests/src/org/eclipse/cdt/autotools/tests/editors/EditorTests.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Red Hat Inc.. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat Incorporated - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.autotools.tests.editors; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ AutomakeColourizationTests.class, AutomakeTextHoverTest.class, AutomakeEditorTests.class }) -public class EditorTests { -} diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AutomatedIntegrationSuite.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AutomatedIntegrationSuite.java index 23582ac83c5..57740306baa 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AutomatedIntegrationSuite.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/AutomatedIntegrationSuite.java @@ -14,12 +14,7 @@ *******************************************************************************/ package org.eclipse.cdt.autotools.ui.tests; -import java.io.IOException; - -import org.eclipse.cdt.autotools.ui.tests.autoconf.AutoconfTests; -import org.eclipse.cdt.utils.spawner.ProcessFactory; -import org.junit.Assume; -import org.junit.BeforeClass; +import org.eclipse.cdt.autotools.ui.tests.autoconf.AutoconfTestSuite; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -30,25 +25,9 @@ import org.junit.runners.Suite; * TestToolActions.class, * TestEnvironmentVars.class, * TestMakeTargets.class, - * SetConfigurationParameter.class, + * SetConfigurationParameterTest.class, */ - AutoconfTests.class }) + AutoconfTestSuite.class }) public class AutomatedIntegrationSuite { - // needed for this class to compile - @BeforeClass - public static void beforeClassMethod() { - // Verify that the necessary binaries are available, and if they are not, - // the tests will be ignored. - String[] testBinaryCommands = { "libtool --version", "autoconf --version", "automake --version" }; - try { - for (String cmd : testBinaryCommands) { - Process process = ProcessFactory.getFactory().exec(cmd); - process.destroy(); - } - } catch (IOException e) { - // If we cannot find any binary, just ignore the tests. - Assume.assumeNoException(e); - } - } } diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java deleted file mode 100644 index fcf978d3718..00000000000 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameter.java +++ /dev/null @@ -1,485 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2016 Red Hat Inc. and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat Incorporated - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.autotools.ui.tests; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; -import org.eclipse.swtbot.swt.finder.waits.Conditions; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; -import org.junit.BeforeClass; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -@RunWith(SWTBotJunit4ClassRunner.class) -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class SetConfigurationParameter extends AbstractTest { - - @BeforeClass - public static void initClass() { - initConfigParm(); - } - - // Prepare initial settings that will be tested. - private static void initConfigParm() { - // Set the configure parameters to be --enable-jeff via user-defined - // options - SWTBotShell shell = openProperties("Autotools", "Configure Settings"); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - SWTBotText text = bot.textWithLabel("Additional command-line options"); - text.typeText("--enable-jeff"); - bot.button("OK").click(); - bot.waitUntil(Conditions.shellCloses(shell), 120000); - - // Create new build configurations that will be used throughout tests - projectExplorer.bot().tree().select(projectName); - clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - bot.button("New...").click(); - shell = bot.shell("Create New Configuration"); - shell.activate(); - SWTBotText t = bot.textWithLabel("Name:"); - t.setText("debug"); - AbstractTest.clickRadioButtonInGroup("Existing configuration", "Copy settings from"); - bot.button("OK").click(); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - bot.button("New...").click(); - shell = bot.shell("Create New Configuration"); - shell.activate(); - t = bot.textWithLabel("Name:"); - t.setText("default"); - AbstractTest.clickRadioButtonInGroup("Default configuration", "Copy settings from"); - bot.button("OK").click(); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - bot.button("OK").click(); - bot.waitUntil(Conditions.shellCloses(shell)); - } - - // Verify we can set a configuration parameter and that it is recorded in - // the .autotools file for the project - @Test - public void t1canSetConfigParm() throws Exception { - IProject project = checkProject(); - assertNotNull(project); - IPath path = project.getLocation(); - path = path.append(".autotools"); - File f = new File(path.toOSString()); - assertTrue(f.exists()); - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document d = db.parse(f); - Element e = d.getDocumentElement(); - // Get the stored configuration data - NodeList cfgs = e.getElementsByTagName("configuration"); //$NON-NLS-1$ - assertTrue(cfgs.getLength() > 0); - Node n = cfgs.item(0); - NodeList l = n.getChildNodes(); - // Verify user field in .autotools file is set to --enable-jeff - boolean foundUser = false; - for (int y = 0; y < l.getLength(); ++y) { - Node child = l.item(y); - if (child.getNodeName().equals("option")) { //$NON-NLS-1$ - NamedNodeMap optionAttrs = child.getAttributes(); - Node idNode = optionAttrs.getNamedItem("id"); //$NON-NLS-1$ - Node valueNode = optionAttrs.getNamedItem("value"); //$NON-NLS-1$ - assertNotNull(idNode); - assertNotNull(valueNode); - String id = idNode.getNodeValue(); - String value = valueNode.getNodeValue(); - if (id.equals("user")) { - foundUser = true; - assertEquals(value, "--enable-jeff"); - } - } - } - assertTrue(foundUser); - } - - // Verify we can build the project with a configuration parameter and that - // the configuration parameter can be found in the config.status file. - @Test - public void t2canBuildWithConfigParm() throws Exception { - projectExplorer.bot().tree().select(projectName); - clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); - - // Wait until the project is built - SWTBotShell shell = bot.shell("Build Project"); - bot.waitUntil(Conditions.shellCloses(shell), 120000); - - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - assertNotNull(workspace); - IWorkspaceRoot root = workspace.getRoot(); - assertNotNull(root); - IProject project = root.getProject(projectName); - assertNotNull(project); - IPath path = project.getLocation(); - File f = new File(path.append("src/a.out").toOSString()); - assertTrue(f.exists()); - f = new File(path.append("config.status").toOSString()); - assertTrue(f.exists()); - - try (BufferedReader r = new BufferedReader(new FileReader(f))) { - int ch; - boolean optionFound = false; - // Read config.status and look for the string --enable-jeff - // which is a simple verification that the option was used in the - // configure step. - while ((ch = r.read()) != -1) { - if (ch == '-') { - char[] buf = new char[12]; - r.mark(100); - int count = r.read(buf); - if (count < 12) { - break; - } - String s = new String(buf); - if (s.equals("-enable-jeff")) { - optionFound = true; - break; - } else { - r.reset(); - } - } - } - assertTrue(optionFound); - } - - String output = viewConsole("Configure").bot().styledText().getText(); - // Verify we got some help output to the console - Pattern p = Pattern.compile(".*WARNING:.*unrecognized.*--enable-jeff.*", Pattern.DOTALL); - Matcher m = p.matcher(output); - assertTrue(m.matches()); - - // Verify that if we build again, we don't reconfigure. - // Verifies fix for bug: #308261 - long oldDate = f.lastModified(); - projectExplorer.bot().tree().select(projectName); - clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); - path = project.getLocation(); - // We need to wait until the a.out file is created so - // sleep a bit and look for it...give up after 120 seconds - for (int i = 0; i < 240; ++i) { - bot.sleep(500); - f = new File(path.append("src/a.out").toOSString()); - if (f.exists()) { - break; - } - } - assertTrue(f.exists()); - f = new File(path.append("config.status").toOSString()); - assertTrue(f.exists()); - long newDate = f.lastModified(); - assertEquals(newDate, oldDate); - } - - // Verify a new configuration will copy the configuration parameters - // of its base configuration. - @Test - public void t3newConfigCopiesParms() throws Exception { - projectExplorer.bot().tree().select(projectName); - clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); - SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - SWTBotTable table = bot.table(); - assertTrue(table.containsItem("debug")); - table.getTableItem("debug").select(); - bot.button("Set Active").click(); - bot.button("OK").click(); - // Verify the debug configuration is active and has a user parameter: - // --enable-jeff - openProperties("Autotools", "Configure Settings"); - SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); - configs.setFocus(); - String[] items = configs.items(); - for (int i = 0; i < items.length; ++i) { - if (items[i].contains("debug") && items[i].contains("Active")) { - configs.setSelection(i); - } - } - assertTrue(configs.getText().contains("debug")); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - SWTBotText text = bot.textWithLabel("Additional command-line options"); - String val = text.getText(); - assertEquals("--enable-jeff", val); - // Verify that the build directory for the new configuration has been - // switched to build-debug - shell = bot.shell("Properties for " + projectName); - shell.activate(); - bot.text().setText(""); - - bot.tree().select("C/C++ Build"); - String buildDir = bot.textWithLabel("Build directory:").getText(); - assertTrue(buildDir.endsWith("build-debug")); - // Verify the default configuration has no user setting - bot.tree().expandNode("Autotools").select("Configure Settings"); - configs = bot.comboBoxWithLabel("Configuration: "); - configs.setSelection("default"); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - text = bot.textWithLabel("Additional command-line options"); - val = text.getText(); - assertEquals("", val); - bot.button("OK").click(); - // Build the project again and verify we get a build-debug directory - projectExplorer.bot().tree().select(projectName); - clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - assertNotNull(workspace); - IWorkspaceRoot root = workspace.getRoot(); - assertNotNull(root); - IProject project = root.getProject(projectName); - assertNotNull(project); - IPath path = project.getLocation(); - // We need to wait until the config.status file is created so - // sleep a bit and look for it...give up after 20 seconds - File f = null; - for (int i = 0; i < 40; ++i) { - bot.sleep(500); - f = new File(path.append("build-debug/src/a.out").toOSString()); - if (f.exists()) { - break; - } - } - assertTrue(f.exists()); - f = new File(path.append("build-debug/config.status").toOSString()); - assertTrue(f.exists()); - try (BufferedReader r = new BufferedReader(new FileReader(f))) { - int ch; - boolean optionFound = false; - // Read config.status and look for the string --enable-jeff - // which is a simple verification that the option was used in the - // configure step. - while ((ch = r.read()) != -1) { - if (ch == '-') { - char[] buf = new char[12]; - r.mark(100); - int count = r.read(buf); - if (count < 12) { - break; - } - String s = new String(buf); - if (s.equals("-enable-jeff")) { - optionFound = true; - break; - } else { - r.reset(); - } - } - } - assertTrue(optionFound); - } - // Verify we cleaned out the top-level build directory (i.e. that there - // is no config.status there anymore). - path = project.getLocation().append("config.status"); - f = new File(path.toOSString()); - assertTrue(!f.exists()); - path = project.getLocation().append(".autotools"); - f = new File(path.toOSString()); - assertTrue(f.exists()); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document d = db.parse(f); - Element e = d.getDocumentElement(); - // Get the stored configuration data - NodeList cfgs = e.getElementsByTagName("configuration"); //$NON-NLS-1$ - assertEquals(4, cfgs.getLength()); - int foundUser = 0; - for (int x = 0; x < cfgs.getLength(); ++x) { - Node n = cfgs.item(x); - NodeList l = n.getChildNodes(); - // Verify two of the user fields in .autotools file are set to - // --enable-jeff - for (int y = 0; y < l.getLength(); ++y) { - Node child = l.item(y); - if (child.getNodeName().equals("option")) { //$NON-NLS-1$ - NamedNodeMap optionAttrs = child.getAttributes(); - Node idNode = optionAttrs.getNamedItem("id"); //$NON-NLS-1$ - Node valueNode = optionAttrs.getNamedItem("value"); //$NON-NLS-1$ - assertNotNull(idNode); - assertNotNull(valueNode); - String id = idNode.getNodeValue(); - String value = valueNode.getNodeValue(); - if (id.equals("user")) { - if (value.equals("--enable-jeff")) { - ++foundUser; - } - } - } - } - } - assertEquals(2, foundUser); - - clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - table = bot.table(); - assertTrue(table.containsItem("Build (GNU)")); - table.getTableItem("Build (GNU)").select(); - bot.button("Set Active").click(); - bot.button("OK").click(); - bot.waitUntil(Conditions.shellCloses(shell)); - } - - // Verify we can do a double rename of configurations, renaming one - // configuration to - // another and then cancel without changing configuration settings. - @Test - public void t4doubleRenameCancel() throws Exception { - openProperties("Autotools", "Configure Settings"); - SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); - bot.button("Manage Configurations...").click(); - // Rename "debug" to "release" and rename "default" to "debug". - // The settings should follow the rename operation. - renameConfiguration("debug", "release"); - renameConfiguration("default", "debug"); - bot.button("OK").click(); - // Verify that "release" has --enable-jeff set and that - // the new "debug" configuration has no user setting. - SWTBotShell shell = bot.shell("Properties for " + projectName); - shell.activate(); - configs = bot.comboBoxWithLabel("Configuration: "); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - SWTBotText text = bot.textWithLabel("Additional command-line options"); - String setting = text.getText(); - assertEquals("--enable-jeff", setting); - configs.setFocus(); - configs.setSelection("debug"); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - text = bot.textWithLabel("Additional command-line options"); - setting = text.getText(); - assertEquals("", setting); - bot.button("Cancel").click(); - // Cancel and then verify that "debug" is back to normal with - // --enable-jeff set and that "default" is back to normal with - // no user setting. - openProperties("Autotools", "Configure Settings"); - configs = bot.comboBoxWithLabel("Configuration: "); - configs.setSelection("debug"); - assertTrue(configs.getText().contains("debug")); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - text = bot.textWithLabel("Additional command-line options"); - setting = text.getText(); - assertEquals("--enable-jeff", setting); - configs.setFocus(); - configs.setSelection("default"); - assertTrue(configs.getText().contains("default")); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - text = bot.textWithLabel("Additional command-line options"); - setting = text.getText(); - assertEquals("", setting); - bot.button("OK").click(); - bot.waitUntil(Conditions.shellCloses(shell)); - } - - // Verify we can do a double rename of configurations, renaming one - // configuration to - // another and inheriting the settings properly. - @Test - public void t5doubleRenameOk() throws Exception { - openProperties("Autotools", "Configure Settings"); - SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); - bot.button("Manage Configurations...").click(); - SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - bot.table().select("debug"); - bot.button("Set Active").click(); - // Rename "debug" to "release" and rename "default" to "debug". - // The settings should follow the rename operation. - renameConfiguration("debug", "release"); - renameConfiguration("default", "debug"); - bot.button("OK").click(); - shell = bot.shell("Properties for " + projectName); - shell.activate(); - bot.button("OK").click(); - - // Verify changes have taken effect permanently - openProperties("Autotools", "Configure Settings"); - configs = bot.comboBoxWithLabel("Configuration: "); - assertTrue(configs.getText().contains("release")); - assertTrue(configs.getText().contains("Active")); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - SWTBotText text = bot.textWithLabel("Additional command-line options"); - String setting = text.getText(); - assertEquals("--enable-jeff", setting); - configs.setFocus(); - configs.setSelection("debug"); - assertTrue(configs.getText().contains("debug")); - bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); - text = bot.textWithLabel("Additional command-line options"); - setting = text.getText(); - assertEquals("", setting); - - // Undo the changes made by this test - configs = bot.comboBoxWithLabel("Configuration: "); - bot.button("Manage Configurations...").click(); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - bot.table().select("Build (GNU)"); - bot.button("Set Active").click(); - renameConfiguration("debug", "default"); - renameConfiguration("release", "debug"); - bot.button("OK").click(); - shell = bot.shell("Properties for " + projectName); - shell.activate(); - bot.button("OK").click(); - bot.waitUntil(Conditions.shellCloses(shell)); - } - - // Renames a configuration. Assumes the "Manage Configurations" dialog will - // be open. - private void renameConfiguration(String original, String newname) { - SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - bot.table().select(original); - bot.button("Rename...").click(); - shell = bot.shell("Rename Configuration"); - shell.activate(); - bot.textWithLabel("Name:").setText(newname); - bot.button("OK").click(); - shell = bot.shell(projectName + ": Manage Configurations"); - shell.activate(); - } - -} diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java new file mode 100644 index 00000000000..19ca5536edf --- /dev/null +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/SetConfigurationParameterTest.java @@ -0,0 +1,487 @@ +/******************************************************************************* + * Copyright (c) 2010, 2016 Red Hat Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Incorporated - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.autotools.ui.tests; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.waits.Conditions; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +@Ignore("Unstable tests exluded from build. See Bug 509248 and Bug 564002") +@RunWith(SWTBotJunit4ClassRunner.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class SetConfigurationParameterTest extends AbstractTest { + + @BeforeClass + public static void initClass() { + initConfigParm(); + } + + // Prepare initial settings that will be tested. + private static void initConfigParm() { + // Set the configure parameters to be --enable-jeff via user-defined + // options + SWTBotShell shell = openProperties("Autotools", "Configure Settings"); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + SWTBotText text = bot.textWithLabel("Additional command-line options"); + text.typeText("--enable-jeff"); + bot.button("OK").click(); + bot.waitUntil(Conditions.shellCloses(shell), 120000); + + // Create new build configurations that will be used throughout tests + projectExplorer.bot().tree().select(projectName); + clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + bot.button("New...").click(); + shell = bot.shell("Create New Configuration"); + shell.activate(); + SWTBotText t = bot.textWithLabel("Name:"); + t.setText("debug"); + AbstractTest.clickRadioButtonInGroup("Existing configuration", "Copy settings from"); + bot.button("OK").click(); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + bot.button("New...").click(); + shell = bot.shell("Create New Configuration"); + shell.activate(); + t = bot.textWithLabel("Name:"); + t.setText("default"); + AbstractTest.clickRadioButtonInGroup("Default configuration", "Copy settings from"); + bot.button("OK").click(); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + bot.button("OK").click(); + bot.waitUntil(Conditions.shellCloses(shell)); + } + + // Verify we can set a configuration parameter and that it is recorded in + // the .autotools file for the project + @Test + public void t1canSetConfigParm() throws Exception { + IProject project = checkProject(); + assertNotNull(project); + IPath path = project.getLocation(); + path = path.append(".autotools"); + File f = new File(path.toOSString()); + assertTrue(f.exists()); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document d = db.parse(f); + Element e = d.getDocumentElement(); + // Get the stored configuration data + NodeList cfgs = e.getElementsByTagName("configuration"); //$NON-NLS-1$ + assertTrue(cfgs.getLength() > 0); + Node n = cfgs.item(0); + NodeList l = n.getChildNodes(); + // Verify user field in .autotools file is set to --enable-jeff + boolean foundUser = false; + for (int y = 0; y < l.getLength(); ++y) { + Node child = l.item(y); + if (child.getNodeName().equals("option")) { //$NON-NLS-1$ + NamedNodeMap optionAttrs = child.getAttributes(); + Node idNode = optionAttrs.getNamedItem("id"); //$NON-NLS-1$ + Node valueNode = optionAttrs.getNamedItem("value"); //$NON-NLS-1$ + assertNotNull(idNode); + assertNotNull(valueNode); + String id = idNode.getNodeValue(); + String value = valueNode.getNodeValue(); + if (id.equals("user")) { + foundUser = true; + assertEquals(value, "--enable-jeff"); + } + } + } + assertTrue(foundUser); + } + + // Verify we can build the project with a configuration parameter and that + // the configuration parameter can be found in the config.status file. + @Test + public void t2canBuildWithConfigParm() throws Exception { + projectExplorer.bot().tree().select(projectName); + clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); + + // Wait until the project is built + SWTBotShell shell = bot.shell("Build Project"); + bot.waitUntil(Conditions.shellCloses(shell), 120000); + + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + assertNotNull(workspace); + IWorkspaceRoot root = workspace.getRoot(); + assertNotNull(root); + IProject project = root.getProject(projectName); + assertNotNull(project); + IPath path = project.getLocation(); + File f = new File(path.append("src/a.out").toOSString()); + assertTrue(f.exists()); + f = new File(path.append("config.status").toOSString()); + assertTrue(f.exists()); + + try (BufferedReader r = new BufferedReader(new FileReader(f))) { + int ch; + boolean optionFound = false; + // Read config.status and look for the string --enable-jeff + // which is a simple verification that the option was used in the + // configure step. + while ((ch = r.read()) != -1) { + if (ch == '-') { + char[] buf = new char[12]; + r.mark(100); + int count = r.read(buf); + if (count < 12) { + break; + } + String s = new String(buf); + if (s.equals("-enable-jeff")) { + optionFound = true; + break; + } else { + r.reset(); + } + } + } + assertTrue(optionFound); + } + + String output = viewConsole("Configure").bot().styledText().getText(); + // Verify we got some help output to the console + Pattern p = Pattern.compile(".*WARNING:.*unrecognized.*--enable-jeff.*", Pattern.DOTALL); + Matcher m = p.matcher(output); + assertTrue(m.matches()); + + // Verify that if we build again, we don't reconfigure. + // Verifies fix for bug: #308261 + long oldDate = f.lastModified(); + projectExplorer.bot().tree().select(projectName); + clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); + path = project.getLocation(); + // We need to wait until the a.out file is created so + // sleep a bit and look for it...give up after 120 seconds + for (int i = 0; i < 240; ++i) { + bot.sleep(500); + f = new File(path.append("src/a.out").toOSString()); + if (f.exists()) { + break; + } + } + assertTrue(f.exists()); + f = new File(path.append("config.status").toOSString()); + assertTrue(f.exists()); + long newDate = f.lastModified(); + assertEquals(newDate, oldDate); + } + + // Verify a new configuration will copy the configuration parameters + // of its base configuration. + @Test + public void t3newConfigCopiesParms() throws Exception { + projectExplorer.bot().tree().select(projectName); + clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); + SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + SWTBotTable table = bot.table(); + assertTrue(table.containsItem("debug")); + table.getTableItem("debug").select(); + bot.button("Set Active").click(); + bot.button("OK").click(); + // Verify the debug configuration is active and has a user parameter: + // --enable-jeff + openProperties("Autotools", "Configure Settings"); + SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); + configs.setFocus(); + String[] items = configs.items(); + for (int i = 0; i < items.length; ++i) { + if (items[i].contains("debug") && items[i].contains("Active")) { + configs.setSelection(i); + } + } + assertTrue(configs.getText().contains("debug")); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + SWTBotText text = bot.textWithLabel("Additional command-line options"); + String val = text.getText(); + assertEquals("--enable-jeff", val); + // Verify that the build directory for the new configuration has been + // switched to build-debug + shell = bot.shell("Properties for " + projectName); + shell.activate(); + bot.text().setText(""); + + bot.tree().select("C/C++ Build"); + String buildDir = bot.textWithLabel("Build directory:").getText(); + assertTrue(buildDir.endsWith("build-debug")); + // Verify the default configuration has no user setting + bot.tree().expandNode("Autotools").select("Configure Settings"); + configs = bot.comboBoxWithLabel("Configuration: "); + configs.setSelection("default"); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + text = bot.textWithLabel("Additional command-line options"); + val = text.getText(); + assertEquals("", val); + bot.button("OK").click(); + // Build the project again and verify we get a build-debug directory + projectExplorer.bot().tree().select(projectName); + clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + assertNotNull(workspace); + IWorkspaceRoot root = workspace.getRoot(); + assertNotNull(root); + IProject project = root.getProject(projectName); + assertNotNull(project); + IPath path = project.getLocation(); + // We need to wait until the config.status file is created so + // sleep a bit and look for it...give up after 20 seconds + File f = null; + for (int i = 0; i < 40; ++i) { + bot.sleep(500); + f = new File(path.append("build-debug/src/a.out").toOSString()); + if (f.exists()) { + break; + } + } + assertTrue(f.exists()); + f = new File(path.append("build-debug/config.status").toOSString()); + assertTrue(f.exists()); + try (BufferedReader r = new BufferedReader(new FileReader(f))) { + int ch; + boolean optionFound = false; + // Read config.status and look for the string --enable-jeff + // which is a simple verification that the option was used in the + // configure step. + while ((ch = r.read()) != -1) { + if (ch == '-') { + char[] buf = new char[12]; + r.mark(100); + int count = r.read(buf); + if (count < 12) { + break; + } + String s = new String(buf); + if (s.equals("-enable-jeff")) { + optionFound = true; + break; + } else { + r.reset(); + } + } + } + assertTrue(optionFound); + } + // Verify we cleaned out the top-level build directory (i.e. that there + // is no config.status there anymore). + path = project.getLocation().append("config.status"); + f = new File(path.toOSString()); + assertTrue(!f.exists()); + path = project.getLocation().append(".autotools"); + f = new File(path.toOSString()); + assertTrue(f.exists()); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document d = db.parse(f); + Element e = d.getDocumentElement(); + // Get the stored configuration data + NodeList cfgs = e.getElementsByTagName("configuration"); //$NON-NLS-1$ + assertEquals(4, cfgs.getLength()); + int foundUser = 0; + for (int x = 0; x < cfgs.getLength(); ++x) { + Node n = cfgs.item(x); + NodeList l = n.getChildNodes(); + // Verify two of the user fields in .autotools file are set to + // --enable-jeff + for (int y = 0; y < l.getLength(); ++y) { + Node child = l.item(y); + if (child.getNodeName().equals("option")) { //$NON-NLS-1$ + NamedNodeMap optionAttrs = child.getAttributes(); + Node idNode = optionAttrs.getNamedItem("id"); //$NON-NLS-1$ + Node valueNode = optionAttrs.getNamedItem("value"); //$NON-NLS-1$ + assertNotNull(idNode); + assertNotNull(valueNode); + String id = idNode.getNodeValue(); + String value = valueNode.getNodeValue(); + if (id.equals("user")) { + if (value.equals("--enable-jeff")) { + ++foundUser; + } + } + } + } + } + assertEquals(2, foundUser); + + clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + table = bot.table(); + assertTrue(table.containsItem("Build (GNU)")); + table.getTableItem("Build (GNU)").select(); + bot.button("Set Active").click(); + bot.button("OK").click(); + bot.waitUntil(Conditions.shellCloses(shell)); + } + + // Verify we can do a double rename of configurations, renaming one + // configuration to + // another and then cancel without changing configuration settings. + @Test + public void t4doubleRenameCancel() throws Exception { + openProperties("Autotools", "Configure Settings"); + SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); + bot.button("Manage Configurations...").click(); + // Rename "debug" to "release" and rename "default" to "debug". + // The settings should follow the rename operation. + renameConfiguration("debug", "release"); + renameConfiguration("default", "debug"); + bot.button("OK").click(); + // Verify that "release" has --enable-jeff set and that + // the new "debug" configuration has no user setting. + SWTBotShell shell = bot.shell("Properties for " + projectName); + shell.activate(); + configs = bot.comboBoxWithLabel("Configuration: "); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + SWTBotText text = bot.textWithLabel("Additional command-line options"); + String setting = text.getText(); + assertEquals("--enable-jeff", setting); + configs.setFocus(); + configs.setSelection("debug"); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + text = bot.textWithLabel("Additional command-line options"); + setting = text.getText(); + assertEquals("", setting); + bot.button("Cancel").click(); + // Cancel and then verify that "debug" is back to normal with + // --enable-jeff set and that "default" is back to normal with + // no user setting. + openProperties("Autotools", "Configure Settings"); + configs = bot.comboBoxWithLabel("Configuration: "); + configs.setSelection("debug"); + assertTrue(configs.getText().contains("debug")); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + text = bot.textWithLabel("Additional command-line options"); + setting = text.getText(); + assertEquals("--enable-jeff", setting); + configs.setFocus(); + configs.setSelection("default"); + assertTrue(configs.getText().contains("default")); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + text = bot.textWithLabel("Additional command-line options"); + setting = text.getText(); + assertEquals("", setting); + bot.button("OK").click(); + bot.waitUntil(Conditions.shellCloses(shell)); + } + + // Verify we can do a double rename of configurations, renaming one + // configuration to + // another and inheriting the settings properly. + @Test + public void t5doubleRenameOk() throws Exception { + openProperties("Autotools", "Configure Settings"); + SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); + bot.button("Manage Configurations...").click(); + SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + bot.table().select("debug"); + bot.button("Set Active").click(); + // Rename "debug" to "release" and rename "default" to "debug". + // The settings should follow the rename operation. + renameConfiguration("debug", "release"); + renameConfiguration("default", "debug"); + bot.button("OK").click(); + shell = bot.shell("Properties for " + projectName); + shell.activate(); + bot.button("OK").click(); + + // Verify changes have taken effect permanently + openProperties("Autotools", "Configure Settings"); + configs = bot.comboBoxWithLabel("Configuration: "); + assertTrue(configs.getText().contains("release")); + assertTrue(configs.getText().contains("Active")); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + SWTBotText text = bot.textWithLabel("Additional command-line options"); + String setting = text.getText(); + assertEquals("--enable-jeff", setting); + configs.setFocus(); + configs.setSelection("debug"); + assertTrue(configs.getText().contains("debug")); + bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); + text = bot.textWithLabel("Additional command-line options"); + setting = text.getText(); + assertEquals("", setting); + + // Undo the changes made by this test + configs = bot.comboBoxWithLabel("Configuration: "); + bot.button("Manage Configurations...").click(); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + bot.table().select("Build (GNU)"); + bot.button("Set Active").click(); + renameConfiguration("debug", "default"); + renameConfiguration("release", "debug"); + bot.button("OK").click(); + shell = bot.shell("Properties for " + projectName); + shell.activate(); + bot.button("OK").click(); + bot.waitUntil(Conditions.shellCloses(shell)); + } + + // Renames a configuration. Assumes the "Manage Configurations" dialog will + // be open. + private void renameConfiguration(String original, String newname) { + SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + bot.table().select(original); + bot.button("Rename...").click(); + shell = bot.shell("Rename Configuration"); + shell.activate(); + bot.textWithLabel("Name:").setText(newname); + bot.button("OK").click(); + shell = bot.shell(projectName + ": Manage Configurations"); + shell.activate(); + } + +} diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java index 945753a967f..d5dca2a894e 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestEnvironmentVars.java @@ -29,10 +29,12 @@ import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotText; import org.junit.FixMethodOrder; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; +@Ignore("Unstable tests exluded from build. See Bug 509248 and Bug 564002") @RunWith(SWTBotJunit4ClassRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestEnvironmentVars extends AbstractTest { diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java index 3c3cf0be8b1..bb89f85a905 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestMakeTargets.java @@ -29,10 +29,12 @@ import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.junit.FixMethodOrder; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; +@Ignore("Unstable tests exluded from build. See Bug 509248 and Bug 564002") @RunWith(SWTBotJunit4ClassRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestMakeTargets extends AbstractTest { diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java index ace227104b6..66e67582be9 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/TestToolActions.java @@ -24,10 +24,12 @@ import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.junit.FixMethodOrder; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.MethodSorters; +@Ignore("Unstable tests exluded from build. See Bug 509248 and Bug 564002") @RunWith(SWTBotJunit4ClassRunner.class) @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestToolActions extends AbstractTest { diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTestSuite.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTestSuite.java new file mode 100644 index 00000000000..bc987881a0c --- /dev/null +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTestSuite.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2008, 2015 Red Hat Inc.. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Incorporated - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.autotools.ui.tests.autoconf; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses({ TestMacroParser.class, TestTokenizer.class, TestShellParser.class }) +public class AutoconfTestSuite { + +} diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTests.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTests.java deleted file mode 100644 index 88e0a34a242..00000000000 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/AutoconfTests.java +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2015 Red Hat Inc.. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Red Hat Incorporated - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.autotools.ui.tests.autoconf; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ TestMacroParser.class, TestTokenizer.class, TestShellParser.class }) -public class AutoconfTests { - -} diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java index 6f6e87b6638..864da2fad67 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/BaseParserTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -30,9 +31,12 @@ import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfParser; import org.eclipse.cdt.autotools.ui.editors.parser.IAutoconfErrorHandler; import org.eclipse.cdt.autotools.ui.editors.parser.IAutoconfMacroValidator; import org.eclipse.cdt.autotools.ui.editors.parser.ParseException; +import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; +import org.junit.Assume; import org.junit.Before; +import org.junit.BeforeClass; public abstract class BaseParserTest { @@ -42,6 +46,22 @@ public abstract class BaseParserTest { private Set macroNames; private AutoconfMacroDetector macroDetector; + @BeforeClass + public static void beforeClassMethod() { + // Verify that the necessary binaries are available, and if they are not, + // the tests will be ignored. + String[] testBinaryCommands = { "libtool --version", "autoconf --version", "automake --version" }; + try { + for (String cmd : testBinaryCommands) { + Process process = ProcessFactory.getFactory().exec(cmd); + process.destroy(); + } + } catch (IOException e) { + // If we cannot find any binary, just ignore the tests. + Assume.assumeNoException(e); + } + } + @Before public void setUp() { errors = new ArrayList<>(); diff --git a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java index b75d58f7be7..f498ad8b59b 100644 --- a/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java +++ b/build/org.eclipse.cdt.autotools.ui.tests/src/org/eclipse/cdt/autotools/ui/tests/autoconf/TestTokenizer.java @@ -19,6 +19,7 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -26,8 +27,11 @@ import org.eclipse.cdt.autotools.ui.editors.parser.AutoconfTokenizer; import org.eclipse.cdt.autotools.ui.editors.parser.ITokenConstants; import org.eclipse.cdt.autotools.ui.editors.parser.ParseException; import org.eclipse.cdt.autotools.ui.editors.parser.Token; +import org.eclipse.cdt.utils.spawner.ProcessFactory; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; +import org.junit.Assume; +import org.junit.BeforeClass; import org.junit.Test; /** @@ -40,6 +44,22 @@ public class TestTokenizer { private ArrayList tokenizerErrors; + @BeforeClass + public static void beforeClassMethod() { + // Verify that the necessary binaries are available, and if they are not, + // the tests will be ignored. + String[] testBinaryCommands = { "libtool --version", "autoconf --version", "automake --version" }; + try { + for (String cmd : testBinaryCommands) { + Process process = ProcessFactory.getFactory().exec(cmd); + process.destroy(); + } + } catch (IOException e) { + // If we cannot find any binary, just ignore the tests. + Assume.assumeNoException(e); + } + } + protected IDocument createDocument(String text) { return new Document(text); } diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java index be00630f21a..e5fbbf3e410 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/core/tests/AutomatedIntegrationSuite.java @@ -15,7 +15,7 @@ package org.eclipse.cdt.make.core.tests; import org.eclipse.cdt.make.builder.tests.StandardBuildTests; -import org.eclipse.cdt.make.scannerdiscovery.ScannerDiscoveryTests; +import org.eclipse.cdt.make.scannerdiscovery.ScannerDiscoveryTestSuite; import junit.framework.Test; import junit.framework.TestCase; @@ -42,7 +42,7 @@ public class AutomatedIntegrationSuite extends TestSuite { final AutomatedIntegrationSuite suite = new AutomatedIntegrationSuite(); suite.addTest(StandardBuildTests.suite()); - suite.addTest(ScannerDiscoveryTests.suite()); + suite.addTest(ScannerDiscoveryTestSuite.suite()); suite.addTest(MakefileReaderProviderTests.suite()); return suite; } diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTestSuite.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTestSuite.java new file mode 100644 index 00000000000..780c02936d1 --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTestSuite.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.make.scannerdiscovery; + +import junit.framework.TestSuite; + +public class ScannerDiscoveryTestSuite extends TestSuite { + + public static TestSuite suite() { + return new ScannerDiscoveryTestSuite(); + } + + public ScannerDiscoveryTestSuite() { + super(ScannerDiscoveryTestSuite.class.getName()); + addTestSuite(ScannerConfigDiscoveryTests.class); + addTest(GCCScannerInfoConsoleParserTests.suite()); + addTest(GCCPerFileBOPConsoleParserTests.suite()); + addTestSuite(ScannerConfigProfileTests.class); + } +} diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java deleted file mode 100644 index 30fb0266122..00000000000 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerDiscoveryTests.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Markus Schorn - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.make.scannerdiscovery; - -import junit.framework.TestSuite; - -public class ScannerDiscoveryTests extends TestSuite { - - public static TestSuite suite() { - return new ScannerDiscoveryTests(); - } - - public ScannerDiscoveryTests() { - super(ScannerDiscoveryTests.class.getName()); - addTestSuite(ScannerConfigDiscoveryTests.class); - addTest(GCCScannerInfoConsoleParserTests.suite()); - addTest(GCCPerFileBOPConsoleParserTests.suite()); - addTestSuite(ScannerConfigProfileTests.class); - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AutomatedIntegrationSuite.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AutomatedIntegrationSuite.java index 9be71132fd4..df8a5912c8a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AutomatedIntegrationSuite.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/AutomatedIntegrationSuite.java @@ -19,12 +19,12 @@ import org.eclipse.cdt.build.core.scannerconfig.tests.CfgScannerConfigProfileMan import org.eclipse.cdt.build.core.scannerconfig.tests.GCCSpecsConsoleParserTest; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; -import org.eclipse.cdt.managedbuilder.core.regressions.RegressionTests; +import org.eclipse.cdt.managedbuilder.core.regressions.RegressionTestSuite; import org.eclipse.cdt.managedbuilder.core.tests.BuildDescriptionModelTests; import org.eclipse.cdt.managedbuilder.core.tests.BuildSystem40Tests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests; -import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests20; -import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCoreTests_SharedToolOptions; +import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCore20Tests; +import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildCore_SharedToolOptionsTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyCalculatorTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildDependencyLibsTests; import org.eclipse.cdt.managedbuilder.core.tests.ManagedBuildEnvironmentTests; @@ -39,8 +39,8 @@ import org.eclipse.cdt.managedbuilder.core.tests.OptionCategoryEnablementTests; import org.eclipse.cdt.managedbuilder.core.tests.OptionEnablementTests; import org.eclipse.cdt.managedbuilder.core.tests.PathConverterTest; import org.eclipse.cdt.managedbuilder.core.tests.ResourceBuildCoreTests; -import org.eclipse.cdt.managedbuilder.language.settings.providers.tests.AllLanguageSettingsProvidersMBSTests; -import org.eclipse.cdt.managedbuilder.templateengine.tests.AllTemplateEngineTests; +import org.eclipse.cdt.managedbuilder.language.settings.providers.tests.AllLanguageSettingsProvidersMBSTestSuite; +import org.eclipse.cdt.managedbuilder.templateengine.tests.AllTemplateEngineTestSuite; import org.eclipse.cdt.projectmodel.tests.BackwardCompatiblityTests; import org.eclipse.cdt.projectmodel.tests.CProjectDescriptionSerializationTests; import org.eclipse.cdt.projectmodel.tests.OptionStringListValueTests; @@ -64,18 +64,18 @@ public class AutomatedIntegrationSuite { TestSuite suite = new TestSuite("Test for org.eclipse.cdt.managedbuild.core.tests"); //$JUnit-BEGIN$ // Preconditions - suite.addTestSuite(Preconditions.class); + suite.addTestSuite(ManagedBuilderPreconditionsTests.class); // build.core.scannerconfig.tests suite.addTest(CfgScannerConfigProfileManagerTests.suite()); suite.addTestSuite(GCCSpecsConsoleParserTest.class); // language settings providers tests - suite.addTest(AllLanguageSettingsProvidersMBSTests.suite()); + suite.addTest(AllLanguageSettingsProvidersMBSTestSuite.suite()); // managedbuilder.core.tests suite.addTest(ManagedBuildDependencyLibsTests.suite()); - suite.addTest(ManagedBuildCoreTests20.suite()); + suite.addTest(ManagedBuildCore20Tests.suite()); suite.addTest(ManagedBuildCoreTests.suite()); suite.addTest(ManagedProjectUpdateTests.suite()); suite.addTest(ManagedCommandLineGeneratorTest.suite()); @@ -83,7 +83,7 @@ public class AutomatedIntegrationSuite { suite.addTest(ManagedProject21MakefileTests.suite()); suite.addTest(ManagedProject30MakefileTests.suite()); suite.addTest(BuildSystem40Tests.suite()); - suite.addTest(ManagedBuildCoreTests_SharedToolOptions.suite()); + suite.addTest(ManagedBuildCore_SharedToolOptionsTests.suite()); suite.addTest(ManagedBuildEnvironmentTests.suite()); suite.addTest(ManagedBuildMacrosTests.suite()); suite.addTest(ManagedBuildTCSupportedTest.suite()); @@ -95,7 +95,7 @@ public class AutomatedIntegrationSuite { suite.addTest(PathConverterTest.suite()); // managedbuilder.templateengine.tests - suite.addTest(AllTemplateEngineTests.suite()); + suite.addTest(AllTemplateEngineTestSuite.suite()); // projectmodel.tests suite.addTest(BackwardCompatiblityTests.suite()); @@ -104,7 +104,7 @@ public class AutomatedIntegrationSuite { suite.addTest(ProjectModelTests.suite()); // regression tests - suite.addTest(RegressionTests.suite()); + suite.addTest(RegressionTestSuite.suite()); //$JUnit-END$ return suite; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java new file mode 100644 index 00000000000..3a99f2e9b84 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2012,2012 Andrew Gvozdev and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * 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 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; + +import junit.framework.TestCase; + +/** + * Check that preconditions for running managed builder tests are in place, + * see individual tests in this class for details. + */ +public class ManagedBuilderPreconditionsTests 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 fileExts = new TreeSet<>(); + 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 expectedExts = new TreeSet<>(Arrays.asList(new String[] { "C", "c", "c++", "cc", "cpp", "cxx" })); + assertEquals("Precodition FAILED - Content Types do not match expected defaults.", expectedExts.toString(), + fileExts.toString()); + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/Preconditions.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/Preconditions.java deleted file mode 100644 index 68094517dae..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/Preconditions.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012,2012 Andrew Gvozdev and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * 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 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; - -import junit.framework.TestCase; - -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 fileExts = new TreeSet<>(); - 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 expectedExts = new TreeSet<>(Arrays.asList(new String[] { "C", "c", "c++", "cc", "cpp", "cxx" })); - assertEquals("Precodition FAILED - Content Types do not match expected defaults.", expectedExts.toString(), - fileExts.toString()); - } - -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953.java deleted file mode 100644 index d032b63ecdd..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Broadcom Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Broadcom Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.core.regressions; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest; -import org.eclipse.cdt.managedbuilder.testplugin.ResourceDeltaVerifier; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; - -/** - * Tests that removing the last source file from a directory - * causes the subdir.mk to be regenerated, and associated dervied - * files should be deleted. - */ -public class Bug_303953 extends AbstractBuilderTest { - - public void testBuildAfterSourcefileDelete() throws CoreException { - setWorkspace("regressions"); - final IProject app = loadProject("helloworldC"); - - List buildOutputResources = new ArrayList<>(); - buildOutputResources.addAll(getProjectBuildExeResources("helloworldC", "Debug", "src/helloworldC")); - - // Ensure Debug is the active configuration - setActiveConfigurationByName(app, "Debug"); - - ResourceDeltaVerifier verifier = new ResourceDeltaVerifier(); - verifier.addExpectedChange(buildOutputResources.toArray(new IResource[buildOutputResources.size()]), - IResourceDelta.ADDED, IResourceDelta.NO_CHANGE); - verifier.addIgnore(new IResource[] { getWorkspace().getRoot(), app, app.getFile(".project") }); - verifyBuild(app, IncrementalProjectBuilder.FULL_BUILD, verifier); - - // Delete helloworldC - IFile srcFile = app.getFile("src/helloworldC.c"); - assertTrue("1.1", srcFile.exists()); - srcFile.delete(false, null); - - // Build again - // - derived files from helloworldC.c should be removed - // - subdir.mk should be changed - // - ignore other changes in the build tree (not the subject of this bug...) - - verifier = new ResourceDeltaVerifier(); - // These files should be removed - IResource[] removed = new IResource[] { app.getFile("Debug/src/helloworldC.o"), - app.getFile("Debug/src/helloworldC.d") }; - verifier.addExpectedChange(removed, IResourceDelta.REMOVED, IResourceDelta.NO_CHANGE); - // subdir.mk has been updated - IResource[] expected = new IResource[] { app.getFile("Debug/src/subdir.mk") }; - verifier.addExpectedChange(expected, IResourceDelta.CHANGED, IResourceDelta.CONTENT); - - // Ignore other resources - Collection ignored = getProjectBuildExeResources("helloworldC", "Debug", "src/helloworldC"); - ignored.removeAll(Arrays.asList(removed)); - ignored.removeAll(Arrays.asList(expected)); - ignored.add(getWorkspace().getRoot()); - ignored.add(app); - verifier.addIgnore(ignored.toArray(new IResource[ignored.size()])); - verifyBuild(app, IncrementalProjectBuilder.INCREMENTAL_BUILD, verifier); - } - -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953Test.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953Test.java new file mode 100644 index 00000000000..70f1554f63d --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/Bug_303953Test.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (c) 2011 Broadcom Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Broadcom Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.core.regressions; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest; +import org.eclipse.cdt.managedbuilder.testplugin.ResourceDeltaVerifier; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.runtime.CoreException; + +/** + * Tests that removing the last source file from a directory + * causes the subdir.mk to be regenerated, and associated dervied + * files should be deleted. + */ +public class Bug_303953Test extends AbstractBuilderTest { + + public void testBuildAfterSourcefileDelete() throws CoreException { + setWorkspace("regressions"); + final IProject app = loadProject("helloworldC"); + + List buildOutputResources = new ArrayList<>(); + buildOutputResources.addAll(getProjectBuildExeResources("helloworldC", "Debug", "src/helloworldC")); + + // Ensure Debug is the active configuration + setActiveConfigurationByName(app, "Debug"); + + ResourceDeltaVerifier verifier = new ResourceDeltaVerifier(); + verifier.addExpectedChange(buildOutputResources.toArray(new IResource[buildOutputResources.size()]), + IResourceDelta.ADDED, IResourceDelta.NO_CHANGE); + verifier.addIgnore(new IResource[] { getWorkspace().getRoot(), app, app.getFile(".project") }); + verifyBuild(app, IncrementalProjectBuilder.FULL_BUILD, verifier); + + // Delete helloworldC + IFile srcFile = app.getFile("src/helloworldC.c"); + assertTrue("1.1", srcFile.exists()); + srcFile.delete(false, null); + + // Build again + // - derived files from helloworldC.c should be removed + // - subdir.mk should be changed + // - ignore other changes in the build tree (not the subject of this bug...) + + verifier = new ResourceDeltaVerifier(); + // These files should be removed + IResource[] removed = new IResource[] { app.getFile("Debug/src/helloworldC.o"), + app.getFile("Debug/src/helloworldC.d") }; + verifier.addExpectedChange(removed, IResourceDelta.REMOVED, IResourceDelta.NO_CHANGE); + // subdir.mk has been updated + IResource[] expected = new IResource[] { app.getFile("Debug/src/subdir.mk") }; + verifier.addExpectedChange(expected, IResourceDelta.CHANGED, IResourceDelta.CONTENT); + + // Ignore other resources + Collection ignored = getProjectBuildExeResources("helloworldC", "Debug", "src/helloworldC"); + ignored.removeAll(Arrays.asList(removed)); + ignored.removeAll(Arrays.asList(expected)); + ignored.add(getWorkspace().getRoot()); + ignored.add(app); + verifier.addIgnore(ignored.toArray(new IResource[ignored.size()])); + verifyBuild(app, IncrementalProjectBuilder.INCREMENTAL_BUILD, verifier); + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTestSuite.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTestSuite.java new file mode 100644 index 00000000000..55af3fcb28a --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTestSuite.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2011 Broadcom Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Broadcom Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.core.regressions; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Regression tests for builder bugs + */ +public class RegressionTestSuite extends TestCase { + + public static Test suite() { + TestSuite suite = new TestSuite(RegressionTestSuite.class.getName()); + + // Test that common builder does the correct amount of work. + suite.addTestSuite(Bug_303953Test.class); + + return suite; + } + + public RegressionTestSuite() { + super(null); + } + + public RegressionTestSuite(String name) { + super(name); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTests.java deleted file mode 100644 index 026d1055d7f..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/regressions/RegressionTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011 Broadcom Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Broadcom Corporation - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.core.regressions; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Regression tests for builder bugs - */ -public class RegressionTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(RegressionTests.class.getName()); - - // Test that common builder does the correct amount of work. - suite.addTestSuite(Bug_303953.class); - - return suite; - } - - public RegressionTests() { - super(null); - } - - public RegressionTests(String name) { - super(name); - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore20Tests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore20Tests.java new file mode 100644 index 00000000000..b92fdb2db5c --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore20Tests.java @@ -0,0 +1,1950 @@ +/******************************************************************************* + * Copyright (c) 2003, 2013 IBM Corporation and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * IBM - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.core.tests; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Map; +import java.util.Properties; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.parser.IScannerInfo; +import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; +import org.eclipse.cdt.core.parser.IScannerInfoProvider; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.managedbuilder.core.BuildException; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.IOptionCategory; +import org.eclipse.cdt.managedbuilder.core.IProjectType; +import org.eclipse.cdt.managedbuilder.core.ITargetPlatform; +import org.eclipse.cdt.managedbuilder.core.ITool; +import org.eclipse.cdt.managedbuilder.core.IToolChain; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; +import org.eclipse.cdt.managedbuilder.internal.core.Option; +import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper; +import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/* + * These tests exercise CDT 2.0 manifest file functionality + */ +public class ManagedBuildCore20Tests extends TestCase { + private static final boolean boolVal = true; + private static final String testConfigId = "test.config.override"; + private static final String testConfigName = "Tester"; + private static final String enumVal = "Another Enum"; + private static final String[] listVal = { "_DEBUG", "/usr/include", "libglade.a" }; + private static final String newExt = "wen"; + private static final String projectName = "ManagedBuildTest"; + private static final String projectName2 = "ManagedBuildTest2"; + private static final String projectRename = "ManagedBuildRedux"; + private static final String rootExt = "toor"; + private static final String stringVal = "-c -Wall"; + private static final String anotherStringVal = "thevalue"; + private static final String subExt = "bus"; + + public ManagedBuildCore20Tests(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite = new TestSuite(ManagedBuildCore20Tests.class.getName()); + + // Note that some of the tests are dependent on others so run the suite as a whole + suite.addTest(new ManagedBuildCore20Tests("testExtensions")); + suite.addTest(new ManagedBuildCore20Tests("testProjectCreation")); + suite.addTest(new ManagedBuildCore20Tests("testConfigurations")); + suite.addTest(new ManagedBuildCore20Tests("testConfigurationReset")); + suite.addTest(new ManagedBuildCore20Tests("testConfigBuildArtifact")); + suite.addTest(new ManagedBuildCore20Tests("testMakeCommandManipulation")); + suite.addTest(new ManagedBuildCore20Tests("testScannerInfoInterface")); + suite.addTest(new ManagedBuildCore20Tests("testProjectRename")); + suite.addTest(new ManagedBuildCore20Tests("testErrorParsers")); + suite.addTest(new ManagedBuildCore20Tests("cleanup")); + + return suite; + } + + /** + * Convert path to OS specific representation + */ + private String toOSLocation(String path) { + java.io.File file = new java.io.File(path); + try { + path = file.getCanonicalPath(); + } catch (IOException e) { + } + + return path; + } + + /** + * Convert path to OS specific representation + */ + private String toOSString(String path) { + return new Path(path).toOSString(); + } + + /** + * Navigates through the build info as defined in the extensions + * defined in this plugin + */ + public void testExtensions() throws Exception { + IProjectType testRoot = null; + IProjectType testSub = null; + IProjectType testSubSub = null; + IProjectType testForwardChild = null; + IProjectType testForwardParent = null; + IProjectType testForwardGrandchild = null; + int numTypes = 0; + + // Note secret null parameter which means just extensions + IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); + + for (int i = 0; i < projTypes.length; ++i) { + IProjectType type = projTypes[i]; + + if (type.getName().equals("Test Root")) { + testRoot = type; + checkRootProjectType(testRoot); + } else if (type.getName().equals("Test Sub")) { + testSub = type; + checkSubProjectType(testSub); + } else if (type.getName().equals("Test Sub Sub")) { + testSubSub = type; + checkSubSubProjectType(testSubSub); + } else if (type.getName().equals("Forward Child")) { + testForwardChild = type; + } else if (type.getName().equals("Forward Parent")) { + testForwardParent = type; + } else if (type.getName().equals("Forward Grandchild")) { + testForwardGrandchild = type; + } else if (type.getId().startsWith("test.provider.Test_")) { + numTypes++; + checkProviderProjectType(type); + } + } + // check that the forward references are properly resolved. + assertNotNull(testForwardChild); + assertNotNull(testForwardParent); + assertNotNull(testForwardGrandchild); + checkForwardProjectTypes(testForwardParent, testForwardChild, testForwardGrandchild); + + // check that the proper number of projectTypes were dynamically provided + assertEquals(3, numTypes); + + // All these project types are defines in the plugin files, so none + // of them should be null at this point + assertNotNull(testRoot); + assertNotNull(testSub); + assertNotNull(testSubSub); + } + + /** + * This test exercises the interface the IConfiguration exposes to manipulate + * its make command. + */ + public void testMakeCommandManipulation() { + String oldMakeCmd = "make"; + String newMakeCmd = "Ant"; + + // Open the test project + IProject project = null; + try { + project = createProject(projectName); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage()); + } + assertNotNull(project); + + // Now get the default configuration + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + assertNotNull(info); + IManagedProject managedProj = info.getManagedProject(); + assertNotNull(managedProj); + IConfiguration defaultConfig = info.getDefaultConfiguration(); + assertNotNull(defaultConfig); + + // Does it have a default build command + assertFalse(defaultConfig.hasOverriddenBuildCommand()); + assertEquals(oldMakeCmd, defaultConfig.getBuildCommand()); + + // Change it + defaultConfig.setBuildCommand(newMakeCmd); + assertEquals(newMakeCmd, defaultConfig.getBuildCommand()); + assertTrue(defaultConfig.hasOverriddenBuildCommand()); + + // Reset it + defaultConfig.setBuildCommand(null); + assertFalse(defaultConfig.hasOverriddenBuildCommand()); + assertEquals(oldMakeCmd, defaultConfig.getBuildCommand()); + + ManagedBuildManager.saveBuildInfo(project, false); + } + + /** + * The purpose of this test is to exercise the build path info interface. + * To get to that point, a new project/config has to be created in the test + * project and the default configuration changed. + */ + public void testScannerInfoInterface() { + // Open the test project + IProject project = null; + try { + project = createProject(projectName); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage()); + } + + //These are the expected path settings + IPath buildCWD = project.getLocation().append("Sub Config"); + final String[] expectedPaths; + if (new Path("C:\\home\\tester/include").isAbsolute()) { + // Windows + expectedPaths = new String[] { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), + toOSLocation("C:\\home\\tester/include"), + // relative paths from MBS will make 3 entries + project.getLocation().append("includes").toOSString(), buildCWD.append("includes").toOSString(), + toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED + }; + } else { + // Unix + expectedPaths = new String[] { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), + // on unix "C:\\home\\tester/include" is relative path + // looks like nonsense but it this way due to MBS converting entry to keep "Sub Config/C:\\home\\tester/include" in its storage + project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(), + buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(), + toOSString("Sub Config/C:\\home\\tester/include"), + // relative paths from MBS will make 3 entries + project.getLocation().append("includes").toOSString(), buildCWD.append("includes").toOSString(), + toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED + }; + } + + // Create a new managed project based on the sub project type + IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub"); + assertNotNull(projType); + + // Create the managed-project for our project + IManagedProject newProject = null; + try { + newProject = ManagedBuildManager.createManagedProject(project, projType); + } catch (BuildException e) { + fail("Failed creating new project: " + e.getLocalizedMessage()); + } + assertNotNull(newProject); + ManagedBuildManager.setNewProjectVersion(project); + + // Copy over the configs + IConfiguration[] baseConfigs = projType.getConfigurations(); + for (int i = 0; i < baseConfigs.length; ++i) { + newProject.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i); + } + + // Change the default configuration to the sub config + IConfiguration[] configs = newProject.getConfigurations(); + assertEquals(4, configs.length); + IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project); + buildInfo.setDefaultConfiguration(newProject.getConfiguration(configs[0].getId())); + buildInfo.setValid(true); + // Save, close, reopen + ManagedBuildManager.saveBuildInfo(project, true); + ManagedBuildManager.removeBuildInfo(project); + try { + ResourceHelper.joinIndexerBeforeCleanup(getName()); + project.close(null); + } catch (CoreException e) { + fail("Failed on project close: " + e.getLocalizedMessage()); + } + try { + project.open(null); + } catch (CoreException e) { + fail("Failed on project open: " + e.getLocalizedMessage()); + } + buildInfo = ManagedBuildManager.getBuildInfo(project); + + // Use the plugin mechanism to discover the supplier of the path information + IExtensionPoint extensionPoint = Platform.getExtensionRegistry() + .getExtensionPoint(CCorePlugin.PLUGIN_ID + ".ScannerInfoProvider"); + if (extensionPoint == null) { + fail("Failed to retrieve the extension point ScannerInfoProvider."); + } + + // Find the first IScannerInfoProvider that supplies build info for the project + IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); + assertNotNull(provider); + + // Now subscribe (note that the method will be called after a change + provider.subscribe(project, new IScannerInfoChangeListener() { + @Override + public void changeNotification(IResource project, IScannerInfo info) { + // Test the symbols: expect "BUILTIN" from the manifest, and "DEBUG" and "GNOME=ME" + // from the overidden settings + Map definedSymbols = info.getDefinedSymbols(); + assertTrue(definedSymbols.containsKey("BUILTIN")); + assertTrue(definedSymbols.containsKey("DEBUG")); + assertTrue(definedSymbols.containsKey("GNOME")); + assertTrue(definedSymbols.containsValue("ME")); + assertEquals(definedSymbols.get("BUILTIN"), ""); + assertEquals(definedSymbols.get("DEBUG"), ""); + assertEquals(definedSymbols.get("GNOME"), "ME"); + // Test the includes path + String[] actualPaths = info.getIncludePaths(); + BuildSystemTestHelper.checkDiff(expectedPaths, actualPaths); + } + }); + + // Check the build information before we change it + IScannerInfo currentSettings = provider.getScannerInformation(project); + + Map currentSymbols = currentSettings.getDefinedSymbols(); + // It should simply contain the built-in + assertTrue(currentSymbols.containsKey("BUILTIN")); + assertEquals(currentSymbols.get("BUILTIN"), ""); + + String[] currentPaths = currentSettings.getIncludePaths(); + BuildSystemTestHelper.checkDiff(expectedPaths, currentPaths); + + // Add some defined symbols programmatically + String[] expectedSymbols = { "DEBUG", "GNOME = ME " }; + IConfiguration defaultConfig = buildInfo.getDefaultConfiguration(); + ITool[] tools = defaultConfig.getTools(); + ITool subTool = null; + for (int i = 0; i < tools.length; i++) { + ITool tool = tools[i]; + if ("tool.sub".equalsIgnoreCase(tool.getSuperClass().getId())) { + subTool = tool; + break; + } + } + assertNotNull(subTool); + IOption symbolOpt = null; + IOption[] opts = subTool.getOptions(); + for (int i = 0; i < opts.length; i++) { + IOption option = opts[i]; + try { + if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) { + symbolOpt = option; + break; + } + } catch (BuildException e) { + fail("Failed getting option value-type: " + e.getLocalizedMessage()); + } + } + assertNotNull(symbolOpt); + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + assertFalse(info.isDirty()); + ManagedBuildManager.setOption(defaultConfig, subTool, symbolOpt, expectedSymbols); + assertTrue(info.isDirty()); + info.setDirty(false); + assertFalse(info.isDirty()); + } + + /** + * Create a new configuration based on one defined in the plugin file. + * Overrides all of the configuration settings. Saves, closes, and reopens + * the project. Then calls a method to check the overridden options. + * + * Tests creating a new configuration. + * Tests setting options. + * Tests persisting overridden options between project sessions. + * + */ + public void testConfigurations() throws CoreException, BuildException { + final String rootName = "Root Config"; + final String overrideName = "Root Override Config"; + final String completeOverrideName = "Complete Override Config"; + final String toolCmd = "doIt"; + final String newCmd = "never"; + + // Open the test project + IProject project = createProject(projectName); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + + // Make sure there is a ManagedProject with 3 configs + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + IManagedProject managedProj = info.getManagedProject(); + IConfiguration[] definedConfigs = managedProj.getConfigurations(); + assertEquals(3, definedConfigs.length); + IConfiguration baseConfig = definedConfigs[0]; + assertEquals(definedConfigs[0].getName(), rootName); + assertEquals(definedConfigs[1].getName(), overrideName); + assertEquals(definedConfigs[2].getName(), completeOverrideName); + + // Create a new configuration and test the rename function + IConfiguration newConfig = managedProj.createConfigurationClone(baseConfig, testConfigId); + assertEquals(4, managedProj.getConfigurations().length); + newConfig.setName(testConfigName); + assertEquals(newConfig.getId(), testConfigId); + assertEquals(newConfig.getName(), testConfigName); + + // There is only one tool + ITool[] definedTools = newConfig.getTools(); + assertEquals(1, definedTools.length); + ITool rootTool = definedTools[0]; + + // Test changing its command + assertEquals(rootTool.getToolCommand(), toolCmd); + newConfig.setToolCommand(rootTool, newCmd); + assertEquals(rootTool.getToolCommand(), newCmd); + + // Override options in the new configuration + IOptionCategory topCategory = rootTool.getTopOptionCategory(); + assertEquals("Root Tool", topCategory.getName()); + Object[][] options = topCategory.getOptions(newConfig); + int i; + for (i = 0; i < options.length; i++) + if (options[i][0] == null) + break; + assertEquals(2, i); + ITool tool = (ITool) options[0][0]; + IOption option = (IOption) options[0][1]; + ManagedBuildManager.setOption(newConfig, tool, option, listVal); + option = (IOption) options[1][1]; + ManagedBuildManager.setOption(newConfig, tool, option, boolVal); + + IOptionCategory[] categories = topCategory.getChildCategories(); + assertEquals(1, categories.length); + options = categories[0].getOptions(newConfig); + for (i = 0; i < options.length; i++) + if (options[i][0] == null) + break; + assertEquals(4, i); + tool = (ITool) options[0][0]; + option = (IOption) options[0][1]; + ManagedBuildManager.setOption(newConfig, tool, option, stringVal); + option = (IOption) options[1][1]; + ManagedBuildManager.setOption(newConfig, tool, option, anotherStringVal); + option = (IOption) options[2][1]; + ManagedBuildManager.setOption(newConfig, tool, option, enumVal); + option = (IOption) options[3][1]; + ManagedBuildManager.setOption(newConfig, tool, option, "False"); + + // Save, close, reopen and test again + ManagedBuildManager.saveBuildInfo(project, false); + ManagedBuildManager.removeBuildInfo(project); + ResourceHelper.joinIndexerBeforeCleanup(getName()); + project.close(null); + project.open(null); + + // Test the values in the new configuration + checkOptionReferences(project); + + // Now delete the new configuration and test the managed project + info = ManagedBuildManager.getBuildInfo(project); + managedProj = info.getManagedProject(); + definedConfigs = managedProj.getConfigurations(); + assertEquals(4, definedConfigs.length); + managedProj.removeConfiguration(testConfigId); + definedConfigs = managedProj.getConfigurations(); + assertEquals(3, definedConfigs.length); + assertEquals(definedConfigs[0].getName(), rootName); + assertEquals(definedConfigs[1].getName(), overrideName); + ManagedBuildManager.saveBuildInfo(project, false); + } + + public void testConfigurationReset() { + // Open the test project + IProject project = null; + try { + project = createProject(projectName); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Failed to open project: " + e.getLocalizedMessage()); + } + + // Get the default configuration + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + assertNotNull(info); + IManagedProject managedProj = info.getManagedProject(); + assertNotNull(managedProj); + IConfiguration defaultConfig = info.getDefaultConfiguration(); + assertNotNull(defaultConfig); + + // See if it still contains the overridden values (see testProjectCreation()) + try { + checkRootManagedProject(managedProj, "z"); + } catch (BuildException e1) { + fail("Overridden root managed project check failed: " + e1.getLocalizedMessage()); + } + + // Reset the config and retest + ManagedBuildManager.resetConfiguration(project, defaultConfig); + ManagedBuildManager.saveBuildInfo(project, false); + try { + checkRootManagedProject(managedProj, "x"); + } catch (BuildException e2) { + fail("Reset root managed project check failed: " + e2.getLocalizedMessage()); + } + } + + /** + * @throws BuildException + */ + public void testProjectCreation() throws BuildException { + // Create new project + IProject project = null; + try { + project = createProject(projectName); + // Now associate the builder with the project + ManagedBuildTestHelper.addManagedBuildNature(project); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + + } catch (CoreException e) { + fail("Test failed on project creation: " + e.getLocalizedMessage()); + } + + // Find the base project type definition + IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.root"); + assertNotNull(projType); + + // Create the managed-project for our project that builds a dummy executable + IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType); + assertEquals(newProject.getName(), projType.getName()); + assertFalse(newProject.equals(projType)); + ManagedBuildManager.setNewProjectVersion(project); + + // Copy over the configs + IConfiguration defaultConfig = null; + IConfiguration[] configs = projType.getConfigurations(); + for (int i = 0; i < configs.length; ++i) { + // Make the first configuration the default + if (i == 0) { + defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i); + } else { + newProject.createConfiguration(configs[i], projType.getId() + "." + i); + } + } + ManagedBuildManager.setDefaultConfiguration(project, defaultConfig); + + String buildArtifactName = projectName; + defaultConfig.setArtifactName(buildArtifactName); + defaultConfig.setArtifactExtension(newExt); + + ManagedBuildManager.getBuildInfo(project).setValid(true); + + // Initialize the path entry container + IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); + if (initResult.getCode() != IStatus.OK) { + fail("Initializing build information failed for: " + project.getName() + " because: " + + initResult.getMessage()); + } + + // Now test the results out + checkRootManagedProject(newProject, "x"); + + // Override the "String Option in Category" option value + configs = newProject.getConfigurations(); + ITool[] tools = configs[0].getTools(); + IOptionCategory topCategory = tools[0].getTopOptionCategory(); + IOptionCategory[] categories = topCategory.getChildCategories(); + Object[][] options = categories[0].getOptions(configs[0]); + ITool tool = (ITool) options[0][0]; + IOption option = (IOption) options[0][1]; + configs[0].setOption(tool, option, "z"); + options = categories[0].getOptions((IConfiguration) null); + tool = (ITool) options[0][0]; + option = (IOption) options[0][1]; + assertEquals("x", option.getStringValue()); + options = categories[0].getOptions(configs[0]); + tool = (ITool) options[0][0]; + option = (IOption) options[0][1]; + assertEquals("z", option.getStringValue()); + + // Save, close, reopen and test again + ManagedBuildManager.saveBuildInfo(project, true); + ManagedBuildManager.removeBuildInfo(project); + try { + ResourceHelper.joinIndexerBeforeCleanup(getName()); + project.close(null); + } catch (CoreException e) { + fail("Failed on project close: " + e.getLocalizedMessage()); + } + try { + project.open(null); + } catch (CoreException e) { + fail("Failed on project open: " + e.getLocalizedMessage()); + } + + // Test that the default config was remembered + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + assertEquals(defaultConfig.getId(), info.getDefaultConfiguration().getId()); + + // Check the rest of the default information + checkRootManagedProject(newProject, "z"); + + // Now test the information the makefile builder needs + checkBuildTestSettings(info); + ManagedBuildManager.removeBuildInfo(project); + } + + /** + * Tests that bugzilla 44159 has been addressed. After a project was renamed, the + * build information mistakenly referred to the old project as its owner. This + * caused a number of searches on the information to fail. In this bug, it was the + * list of tools that could not be determined. In other cases, the information + * retrieval caused NPEs because the old owner no longer existed. + */ + public void testProjectRename() { + // Open the test project + IProject project = null; + try { + project = createProject(projectName); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Failed to open project: " + e.getLocalizedMessage()); + } + + // Rename the project + IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); + IResource newResource = workspaceRoot.findMember(projectRename); + if (newResource != null) { + try { + newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor()); + } catch (CoreException e) { + fail("Failed to delete old project " + projectRename + ": " + e.getLocalizedMessage()); + } + } + IProjectDescription description = null; + try { + description = project.getDescription(); + } catch (CoreException e) { + fail("Failed to find project descriptor for " + projectName + ": " + e.getLocalizedMessage()); + } + description.setName(projectRename); + try { + project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor()); + } catch (CoreException e) { + fail("Failed to rename project: " + e.getLocalizedMessage()); + } + try { + project = createProject(projectRename); + description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Failed to open renamed project: " + e.getLocalizedMessage()); + } + + // By now the project should have 3 configs + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + IManagedProject managedProj = info.getManagedProject(); + IConfiguration[] definedConfigs = managedProj.getConfigurations(); + assertEquals(4, definedConfigs.length); + IConfiguration baseConfig = definedConfigs[1]; + + // There is only one tool + ITool[] definedTools = baseConfig.getTools(); + assertEquals(1, definedTools.length); + ITool rootTool = definedTools[0]; + + // Get the options (2) in top category and (4) in its child + IOptionCategory topCategory = rootTool.getTopOptionCategory(); + assertEquals("Root Tool", topCategory.getName()); + Object[][] options = topCategory.getOptions(baseConfig); + int i; + for (i = 0; i < options.length; i++) + if (options[i][0] == null) + break; + assertEquals(2, i); + IOptionCategory[] categories = topCategory.getChildCategories(); + assertEquals(1, categories.length); + options = categories[0].getOptions(baseConfig); + for (i = 0; i < options.length; i++) + if (options[i][0] == null) + break; + assertEquals(4, i); + + // Set the name back + newResource = workspaceRoot.findMember(projectName); + if (newResource != null) { + try { + newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor()); + } catch (CoreException e) { + fail("Failed to delete old project " + projectName + ": " + e.getLocalizedMessage()); + } + } + try { + description = project.getDescription(); + } catch (CoreException e) { + fail("Failed to find project descriptor for " + projectRename + ": " + e.getLocalizedMessage()); + } + description.setName(projectName); + try { + project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor()); + } catch (CoreException e) { + fail("Failed to re-rename project: " + e.getLocalizedMessage()); + } + try { + project = createProject(projectName); + description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Failed to open re-renamed project: " + e.getLocalizedMessage()); + } + + // Do it all again + info = ManagedBuildManager.getBuildInfo(project); + managedProj = info.getManagedProject(); + definedConfigs = managedProj.getConfigurations(); + assertEquals(4, definedConfigs.length); + baseConfig = definedConfigs[1]; + definedTools = baseConfig.getTools(); + assertEquals(1, definedTools.length); + rootTool = definedTools[0]; + topCategory = rootTool.getTopOptionCategory(); + assertEquals("Root Tool", topCategory.getName()); + options = topCategory.getOptions(baseConfig); + for (i = 0; i < options.length; i++) + if (options[i][0] == null) + break; + assertEquals(2, i); + categories = topCategory.getChildCategories(); + assertEquals(1, categories.length); + options = categories[0].getOptions(baseConfig); + for (i = 0; i < options.length; i++) + if (options[i][0] == null) + break; + assertEquals(4, i); + } + + /** + * Tests the tool settings through the interface the makefile generator + * uses. + * + * @param project + */ + private void checkBuildTestSettings(IManagedBuildInfo info) { + String ext1 = "foo"; + String ext2 = "bar"; + String badExt = "cpp"; + String expectedOutput = "toor"; + String expectedCmd = "doIt"; + + assertNotNull(info); + assertEquals(info.getBuildArtifactName(), projectName); + + // There should be a default configuration defined for the project + IManagedProject managedProj = info.getManagedProject(); + assertNotNull(managedProj); + IConfiguration buildConfig = info.getDefaultConfiguration(); + assertNotNull(buildConfig); + + // Check that tool handles resources with extensions foo and bar by building a baz + assertEquals(info.getOutputExtension(ext1), expectedOutput); + assertEquals(info.getOutputExtension(ext2), expectedOutput); + + // Check that it ignores others based on filename extensions + assertNull(info.getOutputExtension(badExt)); + + // Now see what the tool command line invocation is for foo and bar + assertEquals(info.getToolForSource(ext1), expectedCmd); + assertEquals(info.getToolForSource(ext2), expectedCmd); + // Make sure that there is no tool to build files of type foo and bar + assertNull(info.getToolForConfiguration(ext1)); + assertNull(info.getToolForConfiguration(ext2)); + + // There is no tool that builds toor + assertNull(info.getToolForSource(expectedOutput)); + // but there is one that produces it + assertEquals(info.getToolForConfiguration(expectedOutput), expectedCmd); + + // Now check the build flags + assertEquals(info.getFlagsForSource(ext1), "-La -Lb z -e1 -nob"); + assertEquals(info.getFlagsForSource(ext1), info.getFlagsForSource(ext2)); + + } + + /** + * Tests that overridden options are properly read into build model. + * Test that option values that are not overridden remain the same. + * + * @param project The project to get build model information for. + * @throws BuildException + */ + private void checkOptionReferences(IProject project) throws BuildException { + // Get the configs + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + IManagedProject managedProj = info.getManagedProject(); + IConfiguration[] definedConfigs = managedProj.getConfigurations(); + assertEquals(4, definedConfigs.length); + IConfiguration newConfig = managedProj.getConfiguration(testConfigId); + assertNotNull(newConfig); + + // Now get the tool options and make sure the values are correct + ITool[] definedTools = newConfig.getTools(); + assertEquals(1, definedTools.length); + ITool rootTool = definedTools[0]; + + // Check that the options in the new config contain overridden values + IOption[] rootOptions = rootTool.getOptions(); + assertEquals(6, rootOptions.length); + // First is the new list + assertEquals("List Option in Top", rootOptions[0].getName()); + assertEquals(IOption.STRING_LIST, rootOptions[0].getValueType()); + String[] list = rootOptions[0].getStringListValue(); + assertEquals(3, list.length); + assertTrue(Arrays.equals(listVal, list)); + assertEquals(rootOptions[0].getCommand(), "-L"); + // Next option is a boolean in top + assertEquals("Boolean Option in Top", rootOptions[1].getName()); + assertEquals(IOption.BOOLEAN, rootOptions[1].getValueType()); + assertEquals(boolVal, rootOptions[1].getBooleanValue()); + assertEquals("-b", rootOptions[1].getCommand()); + // Next option is a string in category + assertEquals("String Option in Category", rootOptions[2].getName()); + assertEquals(IOption.STRING, rootOptions[2].getValueType()); + assertEquals(stringVal, rootOptions[2].getStringValue()); + // Next option is a another string in category + assertEquals("Another String Option in Category", rootOptions[3].getName()); + assertEquals(IOption.STRING, rootOptions[3].getValueType()); + assertEquals(anotherStringVal, rootOptions[3].getStringValue()); + assertEquals("-str", rootOptions[3].getCommand()); + // Next option is an enumerated in category + assertEquals("Enumerated Option in Category", rootOptions[4].getName()); + assertEquals(IOption.ENUMERATED, rootOptions[4].getValueType()); + String selEnum = rootOptions[4].getSelectedEnum(); + assertEquals(enumVal, selEnum); + String[] enums = rootOptions[4].getApplicableValues(); + assertEquals(2, enums.length); + assertEquals("Default Enum", enums[0]); + assertEquals("Another Enum", enums[1]); + assertEquals("-e1", rootOptions[4].getEnumCommand(enums[0])); + assertEquals("-e2", rootOptions[4].getEnumCommand(enums[1])); + assertEquals("-e2", rootOptions[4].getEnumCommand(selEnum)); + // Final option is a boolean in Category + assertEquals("Boolean Option in Category", rootOptions[5].getName()); + assertEquals(IOption.BOOLEAN, rootOptions[5].getValueType()); + assertEquals(false, rootOptions[5].getBooleanValue()); + assertEquals("-nob", rootOptions[5].getCommandFalse()); + } + + /* + * Do a full sanity check on the root project type. + */ + private void checkRootProjectType(IProjectType type) throws BuildException { + // Project stuff + String expectedCleanCmd = "del /myworld"; + String expectedParserId = "org.eclipse.cdt.core.PE64"; + String[] expectedOSList = { "win32" }; + String[] expectedArchList = { "all" }; + assertTrue(type.isTestProjectType()); + IConfiguration[] configs = type.getConfigurations(); + if (configs[0].getArtifactName().equals("ManagedBuildTest")) { + assertEquals(configs[0].getArtifactExtension(), newExt); + } else { + assertEquals(configs[0].getArtifactExtension(), rootExt); + } + assertEquals(expectedCleanCmd, configs[0].getCleanCommand()); + assertEquals("make", configs[0].getBuildCommand()); + IToolChain toolChain = configs[0].getToolChain(); + ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); + String[] binaryParsers = targetPlatform.getBinaryParserList(); + assertEquals(binaryParsers.length, 1); + assertEquals(binaryParsers[0], expectedParserId); + assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); + assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); + // This configuration defines no errors parsers. + assertNull(configs[0].getErrorParserIds()); + assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs())); + + // Tools + ITool[] tools = toolChain.getTools(); + // Root Tool + ITool rootTool = tools[0]; + assertEquals("Root Tool", rootTool.getName()); + // 6 Options are defined in the root tool + IOption[] options = rootTool.getOptions(); + assertEquals(6, options.length); + // First option is a 3-element list with 1 built-in + assertEquals("List Option in Top", options[0].getName()); + assertEquals(IOption.STRING_LIST, options[0].getValueType()); + String[] valueList = options[0].getStringListValue(); + assertEquals(2, valueList.length); + assertEquals("a", valueList[0]); + assertEquals("b", valueList[1]); + String[] builtInList = options[0].getBuiltIns(); + assertEquals(1, builtInList.length); + assertEquals("c", builtInList[0]); + assertEquals(options[0].getCommand(), "-L"); + // Next option is a boolean in top + assertEquals("Boolean Option in Top", options[1].getName()); + assertEquals(IOption.BOOLEAN, options[1].getValueType()); + assertEquals(false, options[1].getBooleanValue()); + assertEquals("-b", options[1].getCommand()); + // Next option is a string category + assertEquals("String Option in Category", options[2].getName()); + assertEquals(IOption.STRING, options[2].getValueType()); + assertEquals("x", options[2].getStringValue()); + // Next option is another string category + assertEquals("Another String Option in Category", options[3].getName()); + assertEquals(IOption.STRING, options[3].getValueType()); + assertEquals("", options[3].getStringValue()); + assertEquals("-str", options[3].getCommand()); + // Next option is an enumerated + assertEquals("Enumerated Option in Category", options[4].getName()); + assertEquals(IOption.ENUMERATED, options[4].getValueType()); + // Post-2.0 enums store the ID, not the string value + assertEquals("default.enum.option", options[4].getSelectedEnum()); + assertEquals("-e1", options[4].getEnumCommand("default.enum.option")); + // Need this methof to populate the UI selection widget + valueList = options[4].getApplicableValues(); + assertEquals(2, valueList.length); + assertEquals("Default Enum", valueList[0]); + assertEquals("Another Enum", valueList[1]); + // Test compatability with 1.2 scheme of getting the command from the name + assertEquals("-e1", options[4].getEnumCommand(valueList[0])); + assertEquals("-e2", options[4].getEnumCommand(valueList[1])); + // Final option is another boolean + assertEquals("Boolean Option in Category", options[5].getName()); + assertEquals(IOption.BOOLEAN, options[5].getValueType()); + assertEquals(false, options[5].getBooleanValue()); + assertEquals("", options[5].getCommand()); + assertEquals("-nob", options[5].getCommandFalse()); + + // Option Categories + IOptionCategory topCategory = rootTool.getTopOptionCategory(); + assertEquals("Root Tool", topCategory.getName()); + Object[][] catoptions = topCategory.getOptions(configs[0]); + int i; + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(2, i); + assertEquals("List Option in Top", ((IOption) catoptions[0][1]).getName()); + assertEquals("Boolean Option in Top", ((IOption) catoptions[1][1]).getName()); + IOptionCategory[] categories = topCategory.getChildCategories(); + assertEquals(1, categories.length); + assertEquals("Category", categories[0].getName()); + catoptions = categories[0].getOptions(configs[0]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(4, i); + assertEquals("String Option in Category", ((IOption) catoptions[0][1]).getName()); + assertEquals("Another String Option in Category", ((IOption) catoptions[1][1]).getName()); + assertEquals("Enumerated Option in Category", ((IOption) catoptions[2][1]).getName()); + assertEquals("Boolean Option in Category", ((IOption) catoptions[3][1]).getName()); + + // There should be 3 defined configs + configs = type.getConfigurations(); + assertEquals(3, configs.length); + + // Root Config + IConfiguration rootConfig = configs[0]; + assertEquals("Root Config", rootConfig.getName()); + + // Tool elements + tools = rootConfig.getTools(); + assertEquals(1, tools.length); + assertEquals("Root Tool", tools[0].getName()); + assertEquals("-r", tools[0].getOutputFlag()); + assertTrue(tools[0].buildsFileType("foo")); + assertTrue(tools[0].buildsFileType("bar")); + assertTrue(tools[0].producesFileType("toor")); + assertEquals("doIt", tools[0].getToolCommand()); + assertEquals("", tools[0].getOutputPrefix()); + // The root tool defines one valid header file extension + assertTrue(rootTool.isHeaderFile("baz")); + assertTrue(tools[0].isHeaderFile("baz")); + assertEquals(ITool.FILTER_C, rootTool.getNatureFilter()); + + // Partially Overriden Configuration + assertEquals("Root Override Config", configs[1].getName()); + tools = configs[1].getTools(); + assertEquals(1, tools.length); + assertEquals("Root Tool", tools[0].getName()); + topCategory = tools[0].getTopOptionCategory(); + catoptions = topCategory.getOptions(configs[1]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(2, i); + assertEquals("List Option in Top", ((IOption) catoptions[0][1]).getName()); + valueList = ((IOption) catoptions[0][1]).getStringListValue(); + assertEquals("a", valueList[0]); + assertEquals("b", valueList[1]); + assertEquals("Boolean Option in Top", ((IOption) catoptions[1][1]).getName()); + assertEquals(true, ((IOption) catoptions[1][1]).getBooleanValue()); + assertEquals("-b", ((IOption) catoptions[1][1]).getCommand()); + categories = topCategory.getChildCategories(); + catoptions = categories[0].getOptions(configs[1]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(4, i); + assertEquals("String Option in Category", ((IOption) catoptions[0][1]).getName()); + assertEquals("y", ((IOption) catoptions[0][1]).getStringValue()); + assertEquals("Another String Option in Category", ((IOption) catoptions[1][1]).getName()); + assertEquals("", ((IOption) catoptions[1][1]).getStringValue()); + assertEquals("Enumerated Option in Category", ((IOption) catoptions[2][1]).getName()); + valueList = ((IOption) catoptions[2][1]).getApplicableValues(); + assertEquals(2, valueList.length); + assertEquals("Default Enum", valueList[0]); + assertEquals("Another Enum", valueList[1]); + assertEquals("-e1", ((IOption) catoptions[2][1]).getEnumCommand(valueList[0])); + assertEquals("-e2", ((IOption) catoptions[2][1]).getEnumCommand(valueList[1])); + assertEquals(1, tools.length); + assertEquals("Boolean Option in Category", ((IOption) catoptions[3][1]).getName()); + assertEquals(false, ((IOption) catoptions[3][1]).getBooleanValue()); + assertEquals("", ((IOption) catoptions[3][1]).getCommand()); + assertEquals("-nob", ((IOption) catoptions[3][1]).getCommandFalse()); + assertEquals(1, tools.length); + ITool tool = tools[0]; + assertNotNull(tool); + assertEquals("Root Tool", tool.getName()); + assertEquals("-r", tool.getOutputFlag()); + assertTrue(tool.buildsFileType("foo")); + assertTrue(tool.buildsFileType("bar")); + assertTrue(tool.producesFileType("toor")); + assertTrue(tool.isHeaderFile("baz")); + assertEquals("doIt", tool.getToolCommand()); + assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags()); + + // Completely Overridden configuration + assertEquals("Complete Override Config", configs[2].getName()); + tools = configs[2].getTools(); + assertEquals(1, tools.length); + assertEquals("Root Tool", tools[0].getName()); + topCategory = tools[0].getTopOptionCategory(); + catoptions = topCategory.getOptions(configs[2]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(2, i); + // Check that there's an string list with totally new values + assertEquals("List Option in Top", ((IOption) catoptions[0][1]).getName()); + assertEquals(IOption.STRING_LIST, ((IOption) catoptions[0][1]).getValueType()); + valueList = ((IOption) catoptions[0][1]).getStringListValue(); + assertTrue(valueList.length == 3); + assertEquals("d", valueList[0]); + assertEquals("e", valueList[1]); + assertEquals("f", valueList[2]); + assertEquals("-L", ((IOption) catoptions[0][1]).getCommand()); + // and a true boolean (commands should not have changed) + assertEquals("Boolean Option in Top", ((IOption) catoptions[1][1]).getName()); + assertEquals(IOption.BOOLEAN, ((IOption) catoptions[1][1]).getValueType()); + assertEquals(true, ((IOption) catoptions[1][1]).getBooleanValue()); + assertEquals("-b", ((IOption) catoptions[1][1]).getCommand()); + // Check that there's an overridden enumeration and string + categories = topCategory.getChildCategories(); + catoptions = categories[0].getOptions(configs[2]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(4, i); + assertEquals("String Option in Category", ((IOption) catoptions[0][1]).getName()); + assertEquals(IOption.STRING, ((IOption) catoptions[0][1]).getValueType()); + assertEquals("overridden", ((IOption) catoptions[0][1]).getStringValue()); + assertEquals("Another String Option in Category", ((IOption) catoptions[1][1]).getName()); + assertEquals(IOption.STRING, ((IOption) catoptions[1][1]).getValueType()); + assertEquals("alsooverridden", ((IOption) catoptions[1][1]).getStringValue()); + assertEquals("Enumerated Option in Category", ((IOption) catoptions[2][1]).getName()); + assertEquals(IOption.ENUMERATED, ((IOption) catoptions[2][1]).getValueType()); + assertEquals("another.enum.option", ((IOption) catoptions[2][1]).getSelectedEnum()); + assertEquals("Boolean Option in Category", ((IOption) catoptions[3][1]).getName()); + assertEquals(IOption.BOOLEAN, ((IOption) catoptions[3][1]).getValueType()); + assertEquals(true, ((IOption) catoptions[3][1]).getBooleanValue()); + tool = tools[0]; + assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags()); + + // Make sure that the build manager returns the default makefile generator (not null) + assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0])); + } + + /* + * Do a full sanity check on the root managed project. + */ + private void checkRootManagedProject(IManagedProject managedProj, String testValue) throws BuildException { + String expectedCleanCmd = "del /myworld"; + String expectedParserId = "org.eclipse.cdt.core.PE64"; + String[] expectedOSList = { "win32" }; + String[] expectedArchList = { "all" }; + assertTrue(managedProj.getProjectType().isTestProjectType()); + IConfiguration[] configs = managedProj.getConfigurations(); + if (configs[0].getArtifactName().equals("ManagedBuildTest")) { + assertEquals(configs[0].getArtifactExtension(), newExt); + } else { + assertEquals(configs[0].getArtifactExtension(), rootExt); + } + assertEquals(expectedCleanCmd, configs[0].getCleanCommand()); + assertEquals("make", configs[0].getBuildCommand()); + IToolChain toolChain = configs[0].getToolChain(); + ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); + String[] binaryParsers = targetPlatform.getBinaryParserList(); + assertEquals(binaryParsers.length, 1); + assertEquals(binaryParsers[0], expectedParserId); + assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); + assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); + // This configuration defines no errors parsers. + assertNull(configs[0].getErrorParserIds()); + assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs())); + + // Tools + ITool[] tools = configs[0].getTools(); + // Root Tool + ITool rootTool = tools[0]; + assertEquals("Root Tool", rootTool.getName()); + // 6 Options are defined in the root tool + IOption[] options = rootTool.getOptions(); + assertEquals(6, options.length); + // First option is a 3-element list with 1 built-in + assertEquals("List Option in Top", options[0].getName()); + assertEquals(IOption.STRING_LIST, options[0].getValueType()); + String[] valueList = options[0].getStringListValue(); + assertEquals(2, valueList.length); + assertEquals("a", valueList[0]); + assertEquals("b", valueList[1]); + String[] builtInList = options[0].getBuiltIns(); + assertEquals(1, builtInList.length); + assertEquals("c", builtInList[0]); + assertEquals(options[0].getCommand(), "-L"); + // Next option is a boolean in top + assertEquals("Boolean Option in Top", options[1].getName()); + assertEquals(IOption.BOOLEAN, options[1].getValueType()); + assertEquals(false, options[1].getBooleanValue()); + assertEquals("-b", options[1].getCommand()); + // Next option is a string category + assertEquals("String Option in Category", options[2].getName()); + assertEquals(IOption.STRING, options[2].getValueType()); + assertEquals(testValue, options[2].getStringValue()); + // Next option is another string category + assertEquals("Another String Option in Category", options[3].getName()); + assertEquals(IOption.STRING, options[3].getValueType()); + assertEquals("", options[3].getStringValue()); + assertEquals("-str", options[3].getCommand()); + // Next option is an enumerated + assertEquals("Enumerated Option in Category", options[4].getName()); + assertEquals(IOption.ENUMERATED, options[4].getValueType()); + // Post-2.0 enums store the ID, not the string value + assertEquals("default.enum.option", options[4].getSelectedEnum()); + assertEquals("-e1", options[4].getEnumCommand("default.enum.option")); + // Need this methof to populate the UI selection widget + valueList = options[4].getApplicableValues(); + assertEquals(2, valueList.length); + assertEquals("Default Enum", valueList[0]); + assertEquals("Another Enum", valueList[1]); + // Test compatability with 1.2 scheme of getting the command from the name + assertEquals("-e1", options[4].getEnumCommand(valueList[0])); + assertEquals("-e2", options[4].getEnumCommand(valueList[1])); + // Final option is another boolean + assertEquals("Boolean Option in Category", options[5].getName()); + assertEquals(IOption.BOOLEAN, options[5].getValueType()); + assertEquals(false, options[5].getBooleanValue()); + assertEquals("", options[5].getCommand()); + assertEquals("-nob", options[5].getCommandFalse()); + + // Option Categories + IOptionCategory topCategory = rootTool.getTopOptionCategory(); + assertEquals("Root Tool", topCategory.getName()); + Object[][] catoptions = topCategory.getOptions(configs[0]); + int i; + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(2, i); + IOption catOption = (IOption) catoptions[0][1]; + assertEquals("List Option in Top", catOption.getName()); + catOption = (IOption) catoptions[1][1]; + assertEquals("Boolean Option in Top", catOption.getName()); + IOptionCategory[] categories = topCategory.getChildCategories(); + assertEquals(1, categories.length); + assertEquals("Category", categories[0].getName()); + catoptions = categories[0].getOptions(configs[0]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(4, i); + catOption = (IOption) catoptions[0][1]; + assertEquals("String Option in Category", catOption.getName()); + catOption = (IOption) catoptions[1][1]; + assertEquals("Another String Option in Category", catOption.getName()); + catOption = (IOption) catoptions[2][1]; + assertEquals("Enumerated Option in Category", catOption.getName()); + catOption = (IOption) catoptions[3][1]; + assertEquals("Boolean Option in Category", catOption.getName()); + + // There should be 3 defined configs + assertEquals(3, configs.length); + + // Root Config + IConfiguration rootConfig = configs[0]; + assertEquals("Root Config", rootConfig.getName()); + + // Tool elements + tools = rootConfig.getTools(); + assertEquals(1, tools.length); + assertEquals("Root Tool", tools[0].getName()); + assertEquals("-r", tools[0].getOutputFlag()); + assertTrue(tools[0].buildsFileType("foo")); + assertTrue(tools[0].buildsFileType("bar")); + assertTrue(tools[0].producesFileType("toor")); + assertEquals("doIt", tools[0].getToolCommand()); + assertEquals("", tools[0].getOutputPrefix()); + // The root tool defines one valid header file extension + assertTrue(rootTool.isHeaderFile("baz")); + assertTrue(tools[0].isHeaderFile("baz")); + assertEquals(ITool.FILTER_C, rootTool.getNatureFilter()); + + // Partially Overriden Configuration + assertEquals("Root Override Config", configs[1].getName()); + tools = configs[1].getTools(); + assertEquals(1, tools.length); + assertEquals("Root Tool", tools[0].getName()); + topCategory = tools[0].getTopOptionCategory(); + catoptions = topCategory.getOptions(configs[1]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(2, i); + catOption = (IOption) catoptions[0][1]; + assertEquals("List Option in Top", catOption.getName()); + valueList = catOption.getStringListValue(); + assertEquals("a", valueList[0]); + assertEquals("b", valueList[1]); + catOption = (IOption) catoptions[1][1]; + assertEquals("Boolean Option in Top", catOption.getName()); + assertEquals(true, catOption.getBooleanValue()); + assertEquals("-b", catOption.getCommand()); + categories = topCategory.getChildCategories(); + catoptions = categories[0].getOptions(configs[1]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(4, i); + catOption = (IOption) catoptions[0][1]; + assertEquals("String Option in Category", catOption.getName()); + assertEquals("y", catOption.getStringValue()); + catOption = (IOption) catoptions[1][1]; + assertEquals("Another String Option in Category", catOption.getName()); + assertEquals("", catOption.getStringValue()); + catOption = (IOption) catoptions[2][1]; + assertEquals("Enumerated Option in Category", catOption.getName()); + valueList = catOption.getApplicableValues(); + assertEquals(2, valueList.length); + assertEquals("Default Enum", valueList[0]); + assertEquals("Another Enum", valueList[1]); + catOption = (IOption) catoptions[2][1]; + assertEquals("-e1", catOption.getEnumCommand(valueList[0])); + assertEquals("-e2", catOption.getEnumCommand(valueList[1])); + assertEquals(1, tools.length); + catOption = (IOption) catoptions[3][1]; + assertEquals("Boolean Option in Category", catOption.getName()); + assertEquals(false, catOption.getBooleanValue()); + assertEquals("", catOption.getCommand()); + assertEquals("-nob", catOption.getCommandFalse()); + assertEquals(1, tools.length); + ITool tool = tools[0]; + assertNotNull(tool); + assertEquals("Root Tool", tool.getName()); + assertEquals("-r", tool.getOutputFlag()); + assertTrue(tool.buildsFileType("foo")); + assertTrue(tool.buildsFileType("bar")); + assertTrue(tool.producesFileType("toor")); + assertTrue(tool.isHeaderFile("baz")); + assertEquals("doIt", tool.getToolCommand()); + assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags()); + + // Completely Overridden configuration + assertEquals("Complete Override Config", configs[2].getName()); + tools = configs[2].getTools(); + assertEquals(1, tools.length); + assertEquals("Root Tool", tools[0].getName()); + topCategory = tools[0].getTopOptionCategory(); + catoptions = topCategory.getOptions(configs[2]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(2, i); + // Check that there's an string list with totally new values + catOption = (IOption) catoptions[0][1]; + assertEquals("List Option in Top", catOption.getName()); + assertEquals(IOption.STRING_LIST, catOption.getValueType()); + valueList = catOption.getStringListValue(); + assertTrue(valueList.length == 3); + assertEquals("d", valueList[0]); + assertEquals("e", valueList[1]); + assertEquals("f", valueList[2]); + assertEquals("-L", catOption.getCommand()); + // and a true boolean (commands should not have changed) + catOption = (IOption) catoptions[1][1]; + assertEquals("Boolean Option in Top", catOption.getName()); + assertEquals(IOption.BOOLEAN, catOption.getValueType()); + assertEquals(true, catOption.getBooleanValue()); + assertEquals("-b", catOption.getCommand()); + // Check that there's an overridden enumeration and string + categories = topCategory.getChildCategories(); + catoptions = categories[0].getOptions(configs[2]); + for (i = 0; i < catoptions.length; i++) + if (catoptions[i][0] == null) + break; + assertEquals(4, i); + catOption = (IOption) catoptions[0][1]; + assertEquals("String Option in Category", catOption.getName()); + assertEquals(IOption.STRING, catOption.getValueType()); + assertEquals("overridden", catOption.getStringValue()); + catOption = (IOption) catoptions[1][1]; + assertEquals("Another String Option in Category", catOption.getName()); + assertEquals(IOption.STRING, catOption.getValueType()); + assertEquals("alsooverridden", catOption.getStringValue()); + catOption = (IOption) catoptions[2][1]; + assertEquals("Enumerated Option in Category", catOption.getName()); + assertEquals(IOption.ENUMERATED, catOption.getValueType()); + assertEquals("another.enum.option", catOption.getSelectedEnum()); + catOption = (IOption) catoptions[3][1]; + assertEquals("Boolean Option in Category", catOption.getName()); + assertEquals(IOption.BOOLEAN, catOption.getValueType()); + assertEquals(true, catOption.getBooleanValue()); + tool = tools[0]; + assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags()); + + // Make sure that the build manager returns the default makefile generator (not null) + assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0])); + } + + /* + * The Sub Sub project type has a reference to a tool that is defined + * independently from the project type itself. This is a common pattern + * for tools that are shared between many project types. + * + * The tool itself is defined as having two option categories, with + * one option in each category. To test that the reference is properly + * inheritted, the project type overrides the default value of the boolean + * option. + * + * The test confirms that the basic settings are inheritted through the + * reference, and that the overridden value is used instead of the + * default. It also tests that the command can be overidden through a + * tool reference. + * + * Finally, the string option in the configuration is overridden and the + * test confirms that it contains both the overridden boolean that the + * project type provides, and the overridden string that it provides. + * + * @param testSubSub + */ + private void checkSubSubProjectType(IProjectType projType) { + final String indyToolName = "Target Independent Tool"; + final String indyToolCommand = "RC.EXE"; + final String indyToolInputExt = "rc"; + final String indyToolOutputExt = "free"; + final String indyToolOutFlag = "/fo"; + final String indyToolHeader = "h"; + final String indyToolHeaderNot = "j"; + final String indyCatOne = "Free"; + final String indyCatTwo = "Chained"; + final String freeOptName = "String in Free"; + final String chainedOptName = "Boolean in Chained"; + final String freeOptValue = "Live free or die"; + final String newCmd = "Let the Wookie win"; + final String stringOverride = "The future language of slaves"; + + IConfiguration[] configs = projType.getConfigurations(); + // Check the inherited clean command + assertEquals("rm -yourworld", configs[0].getCleanCommand()); + // Check that the make command is overridden from parent + assertEquals("nmake", configs[0].getBuildCommand()); + // Make sure we get the proper binary parser + IToolChain toolChain = configs[0].getToolChain(); + ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); + assertEquals("org.eclipse.cdt.core.ELF", targetPlatform.getBinaryParserList()[0]); + // Make sure the os list is inherited + String[] expectedOSList = { "win32", "linux", "solaris" }; + assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); + // Make sure the arch list is inherited + String[] expectedArchList = { "x86", "ppc" }; + assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); + + // Get the 5 configurations (3 from test, 1 from test sub and 1 from this) + assertEquals(5, configs.length); + + // Check the tools. We should have 3 (1 from each parent and the one referenced). + ITool[] tools = configs[0].getTools(); + assertEquals(3, tools.length); + ITool toolRef = tools[0]; + + // Make sure we get all the tool settings + assertEquals(toolRef.getName(), indyToolName); + assertEquals(toolRef.getToolCommand(), indyToolCommand); + assertTrue(toolRef.buildsFileType(indyToolInputExt)); + assertEquals(toolRef.getOutputExtension(indyToolInputExt), indyToolOutputExt); + assertEquals(toolRef.getOutputFlag(), indyToolOutFlag); + assertTrue(toolRef.isHeaderFile(indyToolHeader)); + assertFalse(toolRef.isHeaderFile(indyToolHeaderNot)); + assertEquals(toolRef.getNatureFilter(), ITool.FILTER_BOTH); + // Check out the referenced tool and make sure we get all option categories + IOptionCategory topCategory = toolRef.getTopOptionCategory(); + IOptionCategory[] categories = topCategory.getChildCategories(); + assertEquals(1, categories.length); + assertEquals(categories[0].getName(), indyCatOne); + IOptionCategory[] subCategories = categories[0].getChildCategories(); + // Is the chained category a subcategory + assertEquals(1, subCategories.length); + assertEquals(subCategories[0].getName(), indyCatTwo); + // Make sure the option in the top category is correct + Object[][] optsInCat = categories[0].getOptions(configs[0]); + int i; + for (i = 0; i < optsInCat.length; i++) + if (optsInCat[i][0] == null) + break; + assertEquals(1, i); + IOption optCat = (IOption) optsInCat[0][1]; + assertEquals(freeOptName, optCat.getName()); + try { + // We get the option categories and options from the tool itself, but the + // tool reference will have a set of 0 to n option references that contain + // overridden settings. In this case, the string is inheritted and should + // not be reference + assertEquals(IOption.STRING, optCat.getValueType()); + IOption stringOpt = toolRef.getOptionById(optCat.getId()); + assertTrue(stringOpt instanceof Option); + assertEquals(freeOptValue, stringOpt.getStringValue()); + } catch (BuildException e1) { + fail("Failed getting string value in subsub :" + e1.getLocalizedMessage()); + } + + // Do the same for the options in the child cat + Object[][] optsInSubCat = subCategories[0].getOptions(configs[0]); + for (i = 0; i < optsInSubCat.length; i++) + if (optsInSubCat[i][0] == null) + break; + assertEquals(1, i); + IOption booleanRef = toolRef.getOptionById(((IOption) optsInSubCat[0][1]).getId()); + assertEquals(chainedOptName, booleanRef.getName()); + try { + assertEquals(IOption.BOOLEAN, booleanRef.getValueType()); + assertTrue(booleanRef.getBooleanValue()); + } catch (BuildException e) { + fail("Failure getting boolean value in subsub: " + e.getLocalizedMessage()); + } + + // Test that the tool command can be changed through the reference + toolRef.setToolCommand(newCmd); + assertEquals(toolRef.getToolCommand(), newCmd); + + // Muck about with the options in the local config + IConfiguration subSubConfig = projType.getConfiguration("sub.sub.config"); + assertNotNull(subSubConfig); + ITool[] configTools = subSubConfig.getTools(); + // This tool ref is inherited from parent, so it does not belong to the config + ITool configToolRef = configTools[0]; + assertNotNull(configToolRef); + optCat = (IOption) optsInCat[0][1]; + IOption configStringOpt = configToolRef.getOptionById(optCat.getId()); + assertNotNull(configStringOpt); + // Override the string option + try { + subSubConfig.setOption(configToolRef, configStringOpt, stringOverride); + } catch (BuildException e) { + fail("Failure setting string value in subsubconfiguration: " + e.getLocalizedMessage()); + } + // Now the config should have a tool ref to the independent tool + configTools = subSubConfig.getTools(); + configToolRef = configTools[0]; + assertNotNull(configToolRef); + + // Test that the string option is overridden in the configuration + optsInCat = categories[0].getOptions(configs[0]); + for (i = 0; i < optsInCat.length; i++) + if (optsInCat[i][0] == null) + break; + assertEquals(1, i); + optCat = (IOption) optsInCat[0][1]; + assertEquals(freeOptName, optCat.getName()); + configStringOpt = configToolRef.getOptionById(optCat.getId()); + try { + assertEquals(stringOverride, configStringOpt.getStringValue()); + } catch (BuildException e) { + fail("Failure getting string value in subsubconfiguration: " + e.getLocalizedMessage()); + } + // The tool should also contain the boolean option set to true + IOption optSubCat = (IOption) optsInSubCat[0][1]; + IOption configBoolOpt = configToolRef.getOptionById(optSubCat.getId()); + assertNotNull(configBoolOpt); + try { + assertTrue(configBoolOpt.getBooleanValue()); + } catch (BuildException e) { + fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage()); + } + + // Override it in config and retest + try { + subSubConfig.setOption(configToolRef, configBoolOpt, false); + } catch (BuildException e) { + fail("Failure setting boolean value in subsubconfiguration: " + e.getLocalizedMessage()); + } + optsInSubCat = subCategories[0].getOptions(configs[0]); + for (i = 0; i < optsInSubCat.length; i++) + if (optsInSubCat[i][0] == null) + break; + assertEquals(1, i); + configBoolOpt = configToolRef.getOptionById(((IOption) optsInSubCat[0][1]).getId()); + assertEquals(chainedOptName, booleanRef.getName()); + try { + assertFalse(configBoolOpt.getBooleanValue()); + } catch (BuildException e) { + fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage()); + } + } + + /* + * Do a sanity check on the values in the sub-project type. Most of the + * sanity on the how build model entries are read is performed in + * the root project type check, so these tests just verify that the the sub + * project type properly inherits from its parent. For the new options + * in the sub project type, the test does a sanity check just to be complete. + */ + private void checkSubProjectType(IProjectType projType) throws BuildException { + final String expectedFlags = "-I/usr/include -I/opt/gnome/include -IC:\\home\\tester/include -I\"../includes\" x y z"; + + IConfiguration[] configs = projType.getConfigurations(); + // Check the overridden clean command + assertEquals("rm -yourworld", configs[0].getCleanCommand()); + // Make sure the projType inherits the make command + assertEquals("make", configs[0].getBuildCommand()); + // Make sure the binary parser is hard-coded and available + IToolChain toolChain = configs[0].getToolChain(); + ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); + assertEquals("org.eclipse.cdt.core.PE64", targetPlatform.getBinaryParserList()[0]); + String[] expectedOSList = { "win32", "linux", "solaris" }; + assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); + // Make sure the list is overridden + String[] expectedArchList = { "x86", "ppc" }; + assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); + + // Make sure this is a test projType + assertTrue(projType.isTestProjectType()); + // Make sure the build artifact extension is there + assertEquals(configs[0].getArtifactExtension(), subExt); + + // Get the tools for this projType + ITool[] tools = configs[0].getTools(); + // Do we inherit properly from parent + ITool rootTool = tools[0]; + assertEquals("Root Tool", rootTool.getName()); + // Now get the tool defined for this projType + ITool subTool = tools[1]; + assertEquals("Sub Tool", subTool.getName()); + // Confirm that it has four options + IOption[] subOpts = subTool.getOptions(); + assertEquals(5, subOpts.length); + assertEquals("", subTool.getOutputFlag()); + assertTrue(subTool.buildsFileType("yarf")); + assertTrue(subTool.producesFileType("bus")); + assertEquals("", subTool.getToolCommand()); + assertEquals("lib", subTool.getOutputPrefix()); + assertTrue(subTool.isHeaderFile("arf")); + assertTrue(subTool.isHeaderFile("barf")); + assertEquals(ITool.FILTER_BOTH, subTool.getNatureFilter()); + + // Do a sanity check on the options + assertEquals("Include Paths", subOpts[0].getName()); + assertEquals(IOption.INCLUDE_PATH, subOpts[0].getValueType()); + String[] incPath = subOpts[0].getIncludePaths(); + assertEquals(2, incPath.length); + assertEquals("/usr/include", incPath[0]); + assertEquals("/opt/gnome/include", incPath[1]); + String[] builtInPaths = subOpts[0].getBuiltIns(); + assertEquals(1, builtInPaths.length); + assertEquals("/usr/gnu/include", builtInPaths[0]); + assertEquals("-I", subOpts[0].getCommand()); + assertEquals(IOption.BROWSE_DIR, subOpts[0].getBrowseType()); + + // There are no user-defined preprocessor symbols + assertEquals("Defined Symbols", subOpts[1].getName()); + assertEquals(IOption.PREPROCESSOR_SYMBOLS, subOpts[1].getValueType()); + String[] defdSymbols = subOpts[1].getDefinedSymbols(); + assertEquals(0, defdSymbols.length); + assertEquals("-D", subOpts[1].getCommand()); + // But there is a builtin + String[] builtInSymbols = subOpts[1].getBuiltIns(); + assertEquals(1, builtInSymbols.length); + assertEquals("BUILTIN", builtInSymbols[0]); + // Broswe type should be none + assertEquals(IOption.BROWSE_NONE, subOpts[1].getBrowseType()); + + assertEquals("More Includes", subOpts[2].getName()); + assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType()); + String[] moreIncPath = subOpts[2].getIncludePaths(); + assertEquals(2, moreIncPath.length); + assertEquals("C:\\home\\tester/include", moreIncPath[0]); + assertEquals("-I", subOpts[2].getCommand()); + assertEquals(IOption.BROWSE_DIR, subOpts[2].getBrowseType()); + + // Check the user object option + assertEquals("User Objects", subOpts[3].getName()); + assertEquals(IOption.OBJECTS, subOpts[3].getValueType()); + String[] objs = subOpts[3].getUserObjects(); + assertEquals(2, objs.length); + assertEquals("obj1.o", objs[0]); + assertEquals("obj2.o", objs[1]); + assertEquals(IOption.BROWSE_FILE, subOpts[3].getBrowseType()); + assertEquals("", subOpts[3].getCommand()); + + // There should be a string list with no command + assertEquals("No Command StringList", subOpts[4].getName()); + assertEquals(IOption.STRING_LIST, subOpts[4].getValueType()); + + // Make sure the tool flags look right + assertEquals(subTool.getToolFlags(), expectedFlags); + + // Get the configs for this projType; it should inherit all the configs defined for the parent + assertEquals(4, configs.length); + assertEquals("Sub Config", configs[0].getName()); + assertEquals("Root Config", configs[1].getName()); + assertEquals("Root Override Config", configs[2].getName()); + assertEquals("Complete Override Config", configs[3].getName()); + } + + private void checkForwardProjectTypes(IProjectType parent, IProjectType child, IProjectType grandchild) { + // check that the projType parent reference has been resolved. + assertEquals(parent, child.getSuperClass()); + assertEquals(child, grandchild.getSuperClass()); + + // get the parent tool + IConfiguration[] parentConfigs = parent.getConfigurations(); + ITool[] parentTools = parentConfigs[0].getTools(); + assertEquals(1, parentTools.length); + ITool parentTool = parentTools[0]; + assertNotNull(parentTool); + + // check option categories + IOption option = parentTool.getOptionById("test.forward.option"); + assertNotNull(option); + IOptionCategory[] firstLevel = parentTool.getTopOptionCategory().getChildCategories(); + assertEquals(1, firstLevel.length); + IOptionCategory[] secondLevel = firstLevel[0].getChildCategories(); + assertEquals(1, secondLevel.length); + assertEquals(0, secondLevel[0].getChildCategories().length); + Object[][] optList = secondLevel[0].getOptions(parentConfigs[0]); + int i; + for (i = 0; i < optList.length; i++) + if (optList[i][0] == null) + break; + assertEquals(1, i); + assertEquals(option, optList[0][1]); + + // get the tool reference from the child + IConfiguration[] childConfigs = child.getConfigurations(); + ITool[] childTools = childConfigs[0].getTools(); + assertEquals(1, childTools.length); + ITool childToolRef = childTools[0]; + assertEquals(parentTool.getSuperClass(), childToolRef.getSuperClass()); + + // get and check the option reference + IOption optRef = childToolRef.getOptionById("test.forward.option"); + assertEquals(option, optRef); + + // get the tool reference from the grandchild + IConfiguration[] grandConfigs = grandchild.getConfigurations(); + ITool[] grandTools = grandConfigs[0].getTools(); + assertEquals(1, grandTools.length); + ITool grandToolRef = grandTools[0]; + assertEquals(parentTool.getSuperClass(), grandToolRef.getSuperClass()); + + } + + public void checkProviderProjectType(IProjectType projType) throws Exception { + Properties props = new Properties(); + props.load(getClass().getResourceAsStream("test_commands")); + + // check that this projType is in the file + String command = props.getProperty(projType.getId()); + assertNotNull(command); + + IProjectType parent = projType.getSuperClass(); + assertNotNull(parent); + assertEquals("test.forward.parent.target", parent.getId()); + + IConfiguration[] configs = projType.getConfigurations(); + ITool toolRef = configs[0].getFilteredTools()[0]; + assertEquals(command, toolRef.getToolCommand()); + } + + /** + * Remove all the project information associated with the project used during test. + */ + public void cleanup() throws CoreException, IOException { + ResourceHelper.cleanUp(getName()); + removeProject(projectName); + removeProject(projectName2); + } + + /* (non-Javadoc) + * Create a new project named name or return the project in + * the workspace of the same name if it exists. + * + * @param name The name of the project to create or retrieve. + * @return + * @throws CoreException + */ + private IProject createProject(String name) throws CoreException { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + final IProject newProjectHandle = root.getProject(name); + IProject project = null; + + if (!newProjectHandle.exists()) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceDescription workspaceDesc = workspace.getDescription(); + workspaceDesc.setAutoBuilding(false); + workspace.setDescription(workspaceDesc); + IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); + //description.setLocation(root.getLocation()); + project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), + /*MakeCorePlugin.MAKE_PROJECT_ID*/ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); + + // Now associate the builder with the project + ManagedBuildTestHelper.addManagedBuildNature(project); + } else { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + @Override + public void run(IProgressMonitor monitor) throws CoreException { + newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); + } + }; + NullProgressMonitor monitor = new NullProgressMonitor(); + workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor); + project = newProjectHandle; + } + + // Open the project if we have to + if (!project.isOpen()) { + project.open(new NullProgressMonitor()); + } + + return project; + } + + /** + * Remove the IProject with the name specified in the argument from the + * receiver's workspace. + * + * @param name + */ + private void removeProject(String name) { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject project = root.getProject(name); + if (project.exists()) { + try { + Thread.sleep(1000); + } catch (InterruptedException e1) { + } finally { + try { + System.gc(); + System.runFinalization(); + project.delete(true, true, null); + } catch (CoreException e2) { + assertTrue(false); + } + } + } + } + + /** + * @throws BuildException + */ + public void testErrorParsers() throws BuildException { + // Create new project + IProject project = null; + try { + project = createProject(projectName2); + // Now associate the builder with the project + ManagedBuildTestHelper.addManagedBuildNature(project); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + } catch (CoreException e) { + fail("Test failed on error parser project creation: " + e.getLocalizedMessage()); + } + + // Find the base project Type definition + IProjectType projType = ManagedBuildManager.getProjectType("test.error.parsers"); + assertNotNull(projType); + + // Create the target for our project that builds a dummy executable + IManagedProject newProj = ManagedBuildManager.createManagedProject(project, projType); + assertEquals(newProj.getName(), projType.getName()); + ManagedBuildManager.setNewProjectVersion(project); + + ManagedBuildManager.getBuildInfo(project).setValid(true); + // Initialize the path entry container + IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); + if (initResult.getCode() != IStatus.OK) { + fail("Initializing build information failed for: " + project.getName() + " because: " + + initResult.getMessage()); + } + + // Copy over the configs + IConfiguration[] baseConfigs = projType.getConfigurations(); + for (int i = 0; i < baseConfigs.length; ++i) { + newProj.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i); + } + + // Test this out + checkErrorParsersProject(newProj); + + // Save, close, reopen and test again + ManagedBuildManager.saveBuildInfo(project, true); + ManagedBuildManager.removeBuildInfo(project); + try { + ResourceHelper.joinIndexerBeforeCleanup(getName()); + project.close(null); + } catch (CoreException e) { + fail("Failed on error parser project close: " + e.getLocalizedMessage()); + } + try { + project.open(null); + } catch (CoreException e) { + fail("Failed on error parser project open: " + e.getLocalizedMessage()); + } + + // Test that the default config was remembered + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + + // Check the rest of the default information + checkErrorParsersProject(info.getManagedProject()); + ManagedBuildManager.removeBuildInfo(project); + } + + /* + * Do a sanity check on the error parsers target. + */ + private void checkErrorParsersProject(IManagedProject proj) throws BuildException { + // Target stuff + String expectedBinParserId = "org.eclipse.cdt.core.PE64"; + IConfiguration[] configs = proj.getConfigurations(); + IToolChain toolChain = configs[0].getToolChain(); + ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); + assertEquals(expectedBinParserId, targetPlatform.getBinaryParserList()[0]); + // This target defines errors parsers. Check that the error parsers + // have been assigned. + assertEquals( + "org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GmakeErrorParser", + configs[0].getErrorParserIds()); + + // Tool + ITool[] tools = configs[0].getTools(); + ITool rootTool = tools[0]; + assertEquals(1, tools.length); + assertEquals("EP Tool", tools[0].getName()); + assertEquals("-o", tools[0].getOutputFlag()); + assertTrue(tools[0].buildsFileType("y")); + assertTrue(tools[0].buildsFileType("x")); + assertTrue(tools[0].producesFileType("xy")); + assertEquals("EP", tools[0].getToolCommand()); + assertEquals(ITool.FILTER_C, rootTool.getNatureFilter()); + + // There should be one defined configs + assertEquals(1, configs.length); + } + + /** + * Test that the build artifact of a ITarget can be modified + * programmatically. + */ + public void testConfigBuildArtifact() throws CoreException { + // Open the test project + IProject project = createProject(projectName); + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + assertNotNull(info); + IManagedProject managedProj = info.getManagedProject(); + assertNotNull(managedProj); + IConfiguration defaultConfig = info.getDefaultConfiguration(); + assertNotNull(defaultConfig); + + // Set the build artifact of the configuration + String ext = defaultConfig.getArtifactExtension(); + String name = project.getName() + "." + ext; + defaultConfig.setArtifactName(name); + + // Save, close, reopen and test again + ManagedBuildManager.saveBuildInfo(project, false); + ManagedBuildManager.removeBuildInfo(project); + ResourceHelper.joinIndexerBeforeCleanup(getName()); + project.close(null); + project.open(null); + + // Check the artifact name + info = ManagedBuildManager.getBuildInfo(project); + assertNotNull(info); + managedProj = info.getManagedProject(); + assertNotNull(managedProj); + defaultConfig = info.getDefaultConfiguration(); + assertNotNull(defaultConfig); + assertEquals(name, defaultConfig.getArtifactName()); + } + + public void testThatAlwaysFails() { + assertTrue(false); + } + +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java deleted file mode 100644 index 70e2d552418..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ /dev/null @@ -1,1950 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2013 IBM Corporation and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * IBM - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.core.tests; - -import java.io.IOException; -import java.util.Arrays; -import java.util.Map; -import java.util.Properties; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.parser.IScannerInfo; -import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; -import org.eclipse.cdt.core.parser.IScannerInfoProvider; -import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.managedbuilder.core.BuildException; -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; -import org.eclipse.cdt.managedbuilder.core.IManagedProject; -import org.eclipse.cdt.managedbuilder.core.IOption; -import org.eclipse.cdt.managedbuilder.core.IOptionCategory; -import org.eclipse.cdt.managedbuilder.core.IProjectType; -import org.eclipse.cdt.managedbuilder.core.ITargetPlatform; -import org.eclipse.cdt.managedbuilder.core.ITool; -import org.eclipse.cdt.managedbuilder.core.IToolChain; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; -import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; -import org.eclipse.cdt.managedbuilder.internal.core.Option; -import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper; -import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/* - * These tests exercise CDT 2.0 manifest file functionality - */ -public class ManagedBuildCoreTests20 extends TestCase { - private static final boolean boolVal = true; - private static final String testConfigId = "test.config.override"; - private static final String testConfigName = "Tester"; - private static final String enumVal = "Another Enum"; - private static final String[] listVal = { "_DEBUG", "/usr/include", "libglade.a" }; - private static final String newExt = "wen"; - private static final String projectName = "ManagedBuildTest"; - private static final String projectName2 = "ManagedBuildTest2"; - private static final String projectRename = "ManagedBuildRedux"; - private static final String rootExt = "toor"; - private static final String stringVal = "-c -Wall"; - private static final String anotherStringVal = "thevalue"; - private static final String subExt = "bus"; - - public ManagedBuildCoreTests20(String name) { - super(name); - } - - public static Test suite() { - TestSuite suite = new TestSuite(ManagedBuildCoreTests20.class.getName()); - - // Note that some of the tests are dependent on others so run the suite as a whole - suite.addTest(new ManagedBuildCoreTests20("testExtensions")); - suite.addTest(new ManagedBuildCoreTests20("testProjectCreation")); - suite.addTest(new ManagedBuildCoreTests20("testConfigurations")); - suite.addTest(new ManagedBuildCoreTests20("testConfigurationReset")); - suite.addTest(new ManagedBuildCoreTests20("testConfigBuildArtifact")); - suite.addTest(new ManagedBuildCoreTests20("testMakeCommandManipulation")); - suite.addTest(new ManagedBuildCoreTests20("testScannerInfoInterface")); - suite.addTest(new ManagedBuildCoreTests20("testProjectRename")); - suite.addTest(new ManagedBuildCoreTests20("testErrorParsers")); - suite.addTest(new ManagedBuildCoreTests20("cleanup")); - - return suite; - } - - /** - * Convert path to OS specific representation - */ - private String toOSLocation(String path) { - java.io.File file = new java.io.File(path); - try { - path = file.getCanonicalPath(); - } catch (IOException e) { - } - - return path; - } - - /** - * Convert path to OS specific representation - */ - private String toOSString(String path) { - return new Path(path).toOSString(); - } - - /** - * Navigates through the build info as defined in the extensions - * defined in this plugin - */ - public void testExtensions() throws Exception { - IProjectType testRoot = null; - IProjectType testSub = null; - IProjectType testSubSub = null; - IProjectType testForwardChild = null; - IProjectType testForwardParent = null; - IProjectType testForwardGrandchild = null; - int numTypes = 0; - - // Note secret null parameter which means just extensions - IProjectType[] projTypes = ManagedBuildManager.getDefinedProjectTypes(); - - for (int i = 0; i < projTypes.length; ++i) { - IProjectType type = projTypes[i]; - - if (type.getName().equals("Test Root")) { - testRoot = type; - checkRootProjectType(testRoot); - } else if (type.getName().equals("Test Sub")) { - testSub = type; - checkSubProjectType(testSub); - } else if (type.getName().equals("Test Sub Sub")) { - testSubSub = type; - checkSubSubProjectType(testSubSub); - } else if (type.getName().equals("Forward Child")) { - testForwardChild = type; - } else if (type.getName().equals("Forward Parent")) { - testForwardParent = type; - } else if (type.getName().equals("Forward Grandchild")) { - testForwardGrandchild = type; - } else if (type.getId().startsWith("test.provider.Test_")) { - numTypes++; - checkProviderProjectType(type); - } - } - // check that the forward references are properly resolved. - assertNotNull(testForwardChild); - assertNotNull(testForwardParent); - assertNotNull(testForwardGrandchild); - checkForwardProjectTypes(testForwardParent, testForwardChild, testForwardGrandchild); - - // check that the proper number of projectTypes were dynamically provided - assertEquals(3, numTypes); - - // All these project types are defines in the plugin files, so none - // of them should be null at this point - assertNotNull(testRoot); - assertNotNull(testSub); - assertNotNull(testSubSub); - } - - /** - * This test exercises the interface the IConfiguration exposes to manipulate - * its make command. - */ - public void testMakeCommandManipulation() { - String oldMakeCmd = "make"; - String newMakeCmd = "Ant"; - - // Open the test project - IProject project = null; - try { - project = createProject(projectName); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Failed to open project in 'testMakeCommandManipulation': " + e.getLocalizedMessage()); - } - assertNotNull(project); - - // Now get the default configuration - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - assertNotNull(info); - IManagedProject managedProj = info.getManagedProject(); - assertNotNull(managedProj); - IConfiguration defaultConfig = info.getDefaultConfiguration(); - assertNotNull(defaultConfig); - - // Does it have a default build command - assertFalse(defaultConfig.hasOverriddenBuildCommand()); - assertEquals(oldMakeCmd, defaultConfig.getBuildCommand()); - - // Change it - defaultConfig.setBuildCommand(newMakeCmd); - assertEquals(newMakeCmd, defaultConfig.getBuildCommand()); - assertTrue(defaultConfig.hasOverriddenBuildCommand()); - - // Reset it - defaultConfig.setBuildCommand(null); - assertFalse(defaultConfig.hasOverriddenBuildCommand()); - assertEquals(oldMakeCmd, defaultConfig.getBuildCommand()); - - ManagedBuildManager.saveBuildInfo(project, false); - } - - /** - * The purpose of this test is to exercise the build path info interface. - * To get to that point, a new project/config has to be created in the test - * project and the default configuration changed. - */ - public void testScannerInfoInterface() { - // Open the test project - IProject project = null; - try { - project = createProject(projectName); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Failed to open project in 'testScannerInfoInterface': " + e.getLocalizedMessage()); - } - - //These are the expected path settings - IPath buildCWD = project.getLocation().append("Sub Config"); - final String[] expectedPaths; - if (new Path("C:\\home\\tester/include").isAbsolute()) { - // Windows - expectedPaths = new String[] { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), - toOSLocation("C:\\home\\tester/include"), - // relative paths from MBS will make 3 entries - project.getLocation().append("includes").toOSString(), buildCWD.append("includes").toOSString(), - toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED - }; - } else { - // Unix - expectedPaths = new String[] { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), - // on unix "C:\\home\\tester/include" is relative path - // looks like nonsense but it this way due to MBS converting entry to keep "Sub Config/C:\\home\\tester/include" in its storage - project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(), - buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(), - toOSString("Sub Config/C:\\home\\tester/include"), - // relative paths from MBS will make 3 entries - project.getLocation().append("includes").toOSString(), buildCWD.append("includes").toOSString(), - toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED - }; - } - - // Create a new managed project based on the sub project type - IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub"); - assertNotNull(projType); - - // Create the managed-project for our project - IManagedProject newProject = null; - try { - newProject = ManagedBuildManager.createManagedProject(project, projType); - } catch (BuildException e) { - fail("Failed creating new project: " + e.getLocalizedMessage()); - } - assertNotNull(newProject); - ManagedBuildManager.setNewProjectVersion(project); - - // Copy over the configs - IConfiguration[] baseConfigs = projType.getConfigurations(); - for (int i = 0; i < baseConfigs.length; ++i) { - newProject.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i); - } - - // Change the default configuration to the sub config - IConfiguration[] configs = newProject.getConfigurations(); - assertEquals(4, configs.length); - IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project); - buildInfo.setDefaultConfiguration(newProject.getConfiguration(configs[0].getId())); - buildInfo.setValid(true); - // Save, close, reopen - ManagedBuildManager.saveBuildInfo(project, true); - ManagedBuildManager.removeBuildInfo(project); - try { - ResourceHelper.joinIndexerBeforeCleanup(getName()); - project.close(null); - } catch (CoreException e) { - fail("Failed on project close: " + e.getLocalizedMessage()); - } - try { - project.open(null); - } catch (CoreException e) { - fail("Failed on project open: " + e.getLocalizedMessage()); - } - buildInfo = ManagedBuildManager.getBuildInfo(project); - - // Use the plugin mechanism to discover the supplier of the path information - IExtensionPoint extensionPoint = Platform.getExtensionRegistry() - .getExtensionPoint(CCorePlugin.PLUGIN_ID + ".ScannerInfoProvider"); - if (extensionPoint == null) { - fail("Failed to retrieve the extension point ScannerInfoProvider."); - } - - // Find the first IScannerInfoProvider that supplies build info for the project - IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(project); - assertNotNull(provider); - - // Now subscribe (note that the method will be called after a change - provider.subscribe(project, new IScannerInfoChangeListener() { - @Override - public void changeNotification(IResource project, IScannerInfo info) { - // Test the symbols: expect "BUILTIN" from the manifest, and "DEBUG" and "GNOME=ME" - // from the overidden settings - Map definedSymbols = info.getDefinedSymbols(); - assertTrue(definedSymbols.containsKey("BUILTIN")); - assertTrue(definedSymbols.containsKey("DEBUG")); - assertTrue(definedSymbols.containsKey("GNOME")); - assertTrue(definedSymbols.containsValue("ME")); - assertEquals(definedSymbols.get("BUILTIN"), ""); - assertEquals(definedSymbols.get("DEBUG"), ""); - assertEquals(definedSymbols.get("GNOME"), "ME"); - // Test the includes path - String[] actualPaths = info.getIncludePaths(); - BuildSystemTestHelper.checkDiff(expectedPaths, actualPaths); - } - }); - - // Check the build information before we change it - IScannerInfo currentSettings = provider.getScannerInformation(project); - - Map currentSymbols = currentSettings.getDefinedSymbols(); - // It should simply contain the built-in - assertTrue(currentSymbols.containsKey("BUILTIN")); - assertEquals(currentSymbols.get("BUILTIN"), ""); - - String[] currentPaths = currentSettings.getIncludePaths(); - BuildSystemTestHelper.checkDiff(expectedPaths, currentPaths); - - // Add some defined symbols programmatically - String[] expectedSymbols = { "DEBUG", "GNOME = ME " }; - IConfiguration defaultConfig = buildInfo.getDefaultConfiguration(); - ITool[] tools = defaultConfig.getTools(); - ITool subTool = null; - for (int i = 0; i < tools.length; i++) { - ITool tool = tools[i]; - if ("tool.sub".equalsIgnoreCase(tool.getSuperClass().getId())) { - subTool = tool; - break; - } - } - assertNotNull(subTool); - IOption symbolOpt = null; - IOption[] opts = subTool.getOptions(); - for (int i = 0; i < opts.length; i++) { - IOption option = opts[i]; - try { - if (option.getValueType() == IOption.PREPROCESSOR_SYMBOLS) { - symbolOpt = option; - break; - } - } catch (BuildException e) { - fail("Failed getting option value-type: " + e.getLocalizedMessage()); - } - } - assertNotNull(symbolOpt); - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - assertFalse(info.isDirty()); - ManagedBuildManager.setOption(defaultConfig, subTool, symbolOpt, expectedSymbols); - assertTrue(info.isDirty()); - info.setDirty(false); - assertFalse(info.isDirty()); - } - - /** - * Create a new configuration based on one defined in the plugin file. - * Overrides all of the configuration settings. Saves, closes, and reopens - * the project. Then calls a method to check the overridden options. - * - * Tests creating a new configuration. - * Tests setting options. - * Tests persisting overridden options between project sessions. - * - */ - public void testConfigurations() throws CoreException, BuildException { - final String rootName = "Root Config"; - final String overrideName = "Root Override Config"; - final String completeOverrideName = "Complete Override Config"; - final String toolCmd = "doIt"; - final String newCmd = "never"; - - // Open the test project - IProject project = createProject(projectName); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - - // Make sure there is a ManagedProject with 3 configs - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - IManagedProject managedProj = info.getManagedProject(); - IConfiguration[] definedConfigs = managedProj.getConfigurations(); - assertEquals(3, definedConfigs.length); - IConfiguration baseConfig = definedConfigs[0]; - assertEquals(definedConfigs[0].getName(), rootName); - assertEquals(definedConfigs[1].getName(), overrideName); - assertEquals(definedConfigs[2].getName(), completeOverrideName); - - // Create a new configuration and test the rename function - IConfiguration newConfig = managedProj.createConfigurationClone(baseConfig, testConfigId); - assertEquals(4, managedProj.getConfigurations().length); - newConfig.setName(testConfigName); - assertEquals(newConfig.getId(), testConfigId); - assertEquals(newConfig.getName(), testConfigName); - - // There is only one tool - ITool[] definedTools = newConfig.getTools(); - assertEquals(1, definedTools.length); - ITool rootTool = definedTools[0]; - - // Test changing its command - assertEquals(rootTool.getToolCommand(), toolCmd); - newConfig.setToolCommand(rootTool, newCmd); - assertEquals(rootTool.getToolCommand(), newCmd); - - // Override options in the new configuration - IOptionCategory topCategory = rootTool.getTopOptionCategory(); - assertEquals("Root Tool", topCategory.getName()); - Object[][] options = topCategory.getOptions(newConfig); - int i; - for (i = 0; i < options.length; i++) - if (options[i][0] == null) - break; - assertEquals(2, i); - ITool tool = (ITool) options[0][0]; - IOption option = (IOption) options[0][1]; - ManagedBuildManager.setOption(newConfig, tool, option, listVal); - option = (IOption) options[1][1]; - ManagedBuildManager.setOption(newConfig, tool, option, boolVal); - - IOptionCategory[] categories = topCategory.getChildCategories(); - assertEquals(1, categories.length); - options = categories[0].getOptions(newConfig); - for (i = 0; i < options.length; i++) - if (options[i][0] == null) - break; - assertEquals(4, i); - tool = (ITool) options[0][0]; - option = (IOption) options[0][1]; - ManagedBuildManager.setOption(newConfig, tool, option, stringVal); - option = (IOption) options[1][1]; - ManagedBuildManager.setOption(newConfig, tool, option, anotherStringVal); - option = (IOption) options[2][1]; - ManagedBuildManager.setOption(newConfig, tool, option, enumVal); - option = (IOption) options[3][1]; - ManagedBuildManager.setOption(newConfig, tool, option, "False"); - - // Save, close, reopen and test again - ManagedBuildManager.saveBuildInfo(project, false); - ManagedBuildManager.removeBuildInfo(project); - ResourceHelper.joinIndexerBeforeCleanup(getName()); - project.close(null); - project.open(null); - - // Test the values in the new configuration - checkOptionReferences(project); - - // Now delete the new configuration and test the managed project - info = ManagedBuildManager.getBuildInfo(project); - managedProj = info.getManagedProject(); - definedConfigs = managedProj.getConfigurations(); - assertEquals(4, definedConfigs.length); - managedProj.removeConfiguration(testConfigId); - definedConfigs = managedProj.getConfigurations(); - assertEquals(3, definedConfigs.length); - assertEquals(definedConfigs[0].getName(), rootName); - assertEquals(definedConfigs[1].getName(), overrideName); - ManagedBuildManager.saveBuildInfo(project, false); - } - - public void testConfigurationReset() { - // Open the test project - IProject project = null; - try { - project = createProject(projectName); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Failed to open project: " + e.getLocalizedMessage()); - } - - // Get the default configuration - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - assertNotNull(info); - IManagedProject managedProj = info.getManagedProject(); - assertNotNull(managedProj); - IConfiguration defaultConfig = info.getDefaultConfiguration(); - assertNotNull(defaultConfig); - - // See if it still contains the overridden values (see testProjectCreation()) - try { - checkRootManagedProject(managedProj, "z"); - } catch (BuildException e1) { - fail("Overridden root managed project check failed: " + e1.getLocalizedMessage()); - } - - // Reset the config and retest - ManagedBuildManager.resetConfiguration(project, defaultConfig); - ManagedBuildManager.saveBuildInfo(project, false); - try { - checkRootManagedProject(managedProj, "x"); - } catch (BuildException e2) { - fail("Reset root managed project check failed: " + e2.getLocalizedMessage()); - } - } - - /** - * @throws BuildException - */ - public void testProjectCreation() throws BuildException { - // Create new project - IProject project = null; - try { - project = createProject(projectName); - // Now associate the builder with the project - ManagedBuildTestHelper.addManagedBuildNature(project); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - - } catch (CoreException e) { - fail("Test failed on project creation: " + e.getLocalizedMessage()); - } - - // Find the base project type definition - IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.root"); - assertNotNull(projType); - - // Create the managed-project for our project that builds a dummy executable - IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType); - assertEquals(newProject.getName(), projType.getName()); - assertFalse(newProject.equals(projType)); - ManagedBuildManager.setNewProjectVersion(project); - - // Copy over the configs - IConfiguration defaultConfig = null; - IConfiguration[] configs = projType.getConfigurations(); - for (int i = 0; i < configs.length; ++i) { - // Make the first configuration the default - if (i == 0) { - defaultConfig = newProject.createConfiguration(configs[i], projType.getId() + "." + i); - } else { - newProject.createConfiguration(configs[i], projType.getId() + "." + i); - } - } - ManagedBuildManager.setDefaultConfiguration(project, defaultConfig); - - String buildArtifactName = projectName; - defaultConfig.setArtifactName(buildArtifactName); - defaultConfig.setArtifactExtension(newExt); - - ManagedBuildManager.getBuildInfo(project).setValid(true); - - // Initialize the path entry container - IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); - if (initResult.getCode() != IStatus.OK) { - fail("Initializing build information failed for: " + project.getName() + " because: " - + initResult.getMessage()); - } - - // Now test the results out - checkRootManagedProject(newProject, "x"); - - // Override the "String Option in Category" option value - configs = newProject.getConfigurations(); - ITool[] tools = configs[0].getTools(); - IOptionCategory topCategory = tools[0].getTopOptionCategory(); - IOptionCategory[] categories = topCategory.getChildCategories(); - Object[][] options = categories[0].getOptions(configs[0]); - ITool tool = (ITool) options[0][0]; - IOption option = (IOption) options[0][1]; - configs[0].setOption(tool, option, "z"); - options = categories[0].getOptions((IConfiguration) null); - tool = (ITool) options[0][0]; - option = (IOption) options[0][1]; - assertEquals("x", option.getStringValue()); - options = categories[0].getOptions(configs[0]); - tool = (ITool) options[0][0]; - option = (IOption) options[0][1]; - assertEquals("z", option.getStringValue()); - - // Save, close, reopen and test again - ManagedBuildManager.saveBuildInfo(project, true); - ManagedBuildManager.removeBuildInfo(project); - try { - ResourceHelper.joinIndexerBeforeCleanup(getName()); - project.close(null); - } catch (CoreException e) { - fail("Failed on project close: " + e.getLocalizedMessage()); - } - try { - project.open(null); - } catch (CoreException e) { - fail("Failed on project open: " + e.getLocalizedMessage()); - } - - // Test that the default config was remembered - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - assertEquals(defaultConfig.getId(), info.getDefaultConfiguration().getId()); - - // Check the rest of the default information - checkRootManagedProject(newProject, "z"); - - // Now test the information the makefile builder needs - checkBuildTestSettings(info); - ManagedBuildManager.removeBuildInfo(project); - } - - /** - * Tests that bugzilla 44159 has been addressed. After a project was renamed, the - * build information mistakenly referred to the old project as its owner. This - * caused a number of searches on the information to fail. In this bug, it was the - * list of tools that could not be determined. In other cases, the information - * retrieval caused NPEs because the old owner no longer existed. - */ - public void testProjectRename() { - // Open the test project - IProject project = null; - try { - project = createProject(projectName); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Failed to open project: " + e.getLocalizedMessage()); - } - - // Rename the project - IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - IResource newResource = workspaceRoot.findMember(projectRename); - if (newResource != null) { - try { - newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor()); - } catch (CoreException e) { - fail("Failed to delete old project " + projectRename + ": " + e.getLocalizedMessage()); - } - } - IProjectDescription description = null; - try { - description = project.getDescription(); - } catch (CoreException e) { - fail("Failed to find project descriptor for " + projectName + ": " + e.getLocalizedMessage()); - } - description.setName(projectRename); - try { - project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor()); - } catch (CoreException e) { - fail("Failed to rename project: " + e.getLocalizedMessage()); - } - try { - project = createProject(projectRename); - description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Failed to open renamed project: " + e.getLocalizedMessage()); - } - - // By now the project should have 3 configs - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - IManagedProject managedProj = info.getManagedProject(); - IConfiguration[] definedConfigs = managedProj.getConfigurations(); - assertEquals(4, definedConfigs.length); - IConfiguration baseConfig = definedConfigs[1]; - - // There is only one tool - ITool[] definedTools = baseConfig.getTools(); - assertEquals(1, definedTools.length); - ITool rootTool = definedTools[0]; - - // Get the options (2) in top category and (4) in its child - IOptionCategory topCategory = rootTool.getTopOptionCategory(); - assertEquals("Root Tool", topCategory.getName()); - Object[][] options = topCategory.getOptions(baseConfig); - int i; - for (i = 0; i < options.length; i++) - if (options[i][0] == null) - break; - assertEquals(2, i); - IOptionCategory[] categories = topCategory.getChildCategories(); - assertEquals(1, categories.length); - options = categories[0].getOptions(baseConfig); - for (i = 0; i < options.length; i++) - if (options[i][0] == null) - break; - assertEquals(4, i); - - // Set the name back - newResource = workspaceRoot.findMember(projectName); - if (newResource != null) { - try { - newResource.delete(IResource.KEEP_HISTORY, new NullProgressMonitor()); - } catch (CoreException e) { - fail("Failed to delete old project " + projectName + ": " + e.getLocalizedMessage()); - } - } - try { - description = project.getDescription(); - } catch (CoreException e) { - fail("Failed to find project descriptor for " + projectRename + ": " + e.getLocalizedMessage()); - } - description.setName(projectName); - try { - project.move(description, IResource.FORCE | IResource.SHALLOW, new NullProgressMonitor()); - } catch (CoreException e) { - fail("Failed to re-rename project: " + e.getLocalizedMessage()); - } - try { - project = createProject(projectName); - description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Failed to open re-renamed project: " + e.getLocalizedMessage()); - } - - // Do it all again - info = ManagedBuildManager.getBuildInfo(project); - managedProj = info.getManagedProject(); - definedConfigs = managedProj.getConfigurations(); - assertEquals(4, definedConfigs.length); - baseConfig = definedConfigs[1]; - definedTools = baseConfig.getTools(); - assertEquals(1, definedTools.length); - rootTool = definedTools[0]; - topCategory = rootTool.getTopOptionCategory(); - assertEquals("Root Tool", topCategory.getName()); - options = topCategory.getOptions(baseConfig); - for (i = 0; i < options.length; i++) - if (options[i][0] == null) - break; - assertEquals(2, i); - categories = topCategory.getChildCategories(); - assertEquals(1, categories.length); - options = categories[0].getOptions(baseConfig); - for (i = 0; i < options.length; i++) - if (options[i][0] == null) - break; - assertEquals(4, i); - } - - /** - * Tests the tool settings through the interface the makefile generator - * uses. - * - * @param project - */ - private void checkBuildTestSettings(IManagedBuildInfo info) { - String ext1 = "foo"; - String ext2 = "bar"; - String badExt = "cpp"; - String expectedOutput = "toor"; - String expectedCmd = "doIt"; - - assertNotNull(info); - assertEquals(info.getBuildArtifactName(), projectName); - - // There should be a default configuration defined for the project - IManagedProject managedProj = info.getManagedProject(); - assertNotNull(managedProj); - IConfiguration buildConfig = info.getDefaultConfiguration(); - assertNotNull(buildConfig); - - // Check that tool handles resources with extensions foo and bar by building a baz - assertEquals(info.getOutputExtension(ext1), expectedOutput); - assertEquals(info.getOutputExtension(ext2), expectedOutput); - - // Check that it ignores others based on filename extensions - assertNull(info.getOutputExtension(badExt)); - - // Now see what the tool command line invocation is for foo and bar - assertEquals(info.getToolForSource(ext1), expectedCmd); - assertEquals(info.getToolForSource(ext2), expectedCmd); - // Make sure that there is no tool to build files of type foo and bar - assertNull(info.getToolForConfiguration(ext1)); - assertNull(info.getToolForConfiguration(ext2)); - - // There is no tool that builds toor - assertNull(info.getToolForSource(expectedOutput)); - // but there is one that produces it - assertEquals(info.getToolForConfiguration(expectedOutput), expectedCmd); - - // Now check the build flags - assertEquals(info.getFlagsForSource(ext1), "-La -Lb z -e1 -nob"); - assertEquals(info.getFlagsForSource(ext1), info.getFlagsForSource(ext2)); - - } - - /** - * Tests that overridden options are properly read into build model. - * Test that option values that are not overridden remain the same. - * - * @param project The project to get build model information for. - * @throws BuildException - */ - private void checkOptionReferences(IProject project) throws BuildException { - // Get the configs - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - IManagedProject managedProj = info.getManagedProject(); - IConfiguration[] definedConfigs = managedProj.getConfigurations(); - assertEquals(4, definedConfigs.length); - IConfiguration newConfig = managedProj.getConfiguration(testConfigId); - assertNotNull(newConfig); - - // Now get the tool options and make sure the values are correct - ITool[] definedTools = newConfig.getTools(); - assertEquals(1, definedTools.length); - ITool rootTool = definedTools[0]; - - // Check that the options in the new config contain overridden values - IOption[] rootOptions = rootTool.getOptions(); - assertEquals(6, rootOptions.length); - // First is the new list - assertEquals("List Option in Top", rootOptions[0].getName()); - assertEquals(IOption.STRING_LIST, rootOptions[0].getValueType()); - String[] list = rootOptions[0].getStringListValue(); - assertEquals(3, list.length); - assertTrue(Arrays.equals(listVal, list)); - assertEquals(rootOptions[0].getCommand(), "-L"); - // Next option is a boolean in top - assertEquals("Boolean Option in Top", rootOptions[1].getName()); - assertEquals(IOption.BOOLEAN, rootOptions[1].getValueType()); - assertEquals(boolVal, rootOptions[1].getBooleanValue()); - assertEquals("-b", rootOptions[1].getCommand()); - // Next option is a string in category - assertEquals("String Option in Category", rootOptions[2].getName()); - assertEquals(IOption.STRING, rootOptions[2].getValueType()); - assertEquals(stringVal, rootOptions[2].getStringValue()); - // Next option is a another string in category - assertEquals("Another String Option in Category", rootOptions[3].getName()); - assertEquals(IOption.STRING, rootOptions[3].getValueType()); - assertEquals(anotherStringVal, rootOptions[3].getStringValue()); - assertEquals("-str", rootOptions[3].getCommand()); - // Next option is an enumerated in category - assertEquals("Enumerated Option in Category", rootOptions[4].getName()); - assertEquals(IOption.ENUMERATED, rootOptions[4].getValueType()); - String selEnum = rootOptions[4].getSelectedEnum(); - assertEquals(enumVal, selEnum); - String[] enums = rootOptions[4].getApplicableValues(); - assertEquals(2, enums.length); - assertEquals("Default Enum", enums[0]); - assertEquals("Another Enum", enums[1]); - assertEquals("-e1", rootOptions[4].getEnumCommand(enums[0])); - assertEquals("-e2", rootOptions[4].getEnumCommand(enums[1])); - assertEquals("-e2", rootOptions[4].getEnumCommand(selEnum)); - // Final option is a boolean in Category - assertEquals("Boolean Option in Category", rootOptions[5].getName()); - assertEquals(IOption.BOOLEAN, rootOptions[5].getValueType()); - assertEquals(false, rootOptions[5].getBooleanValue()); - assertEquals("-nob", rootOptions[5].getCommandFalse()); - } - - /* - * Do a full sanity check on the root project type. - */ - private void checkRootProjectType(IProjectType type) throws BuildException { - // Project stuff - String expectedCleanCmd = "del /myworld"; - String expectedParserId = "org.eclipse.cdt.core.PE64"; - String[] expectedOSList = { "win32" }; - String[] expectedArchList = { "all" }; - assertTrue(type.isTestProjectType()); - IConfiguration[] configs = type.getConfigurations(); - if (configs[0].getArtifactName().equals("ManagedBuildTest")) { - assertEquals(configs[0].getArtifactExtension(), newExt); - } else { - assertEquals(configs[0].getArtifactExtension(), rootExt); - } - assertEquals(expectedCleanCmd, configs[0].getCleanCommand()); - assertEquals("make", configs[0].getBuildCommand()); - IToolChain toolChain = configs[0].getToolChain(); - ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); - String[] binaryParsers = targetPlatform.getBinaryParserList(); - assertEquals(binaryParsers.length, 1); - assertEquals(binaryParsers[0], expectedParserId); - assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); - assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); - // This configuration defines no errors parsers. - assertNull(configs[0].getErrorParserIds()); - assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs())); - - // Tools - ITool[] tools = toolChain.getTools(); - // Root Tool - ITool rootTool = tools[0]; - assertEquals("Root Tool", rootTool.getName()); - // 6 Options are defined in the root tool - IOption[] options = rootTool.getOptions(); - assertEquals(6, options.length); - // First option is a 3-element list with 1 built-in - assertEquals("List Option in Top", options[0].getName()); - assertEquals(IOption.STRING_LIST, options[0].getValueType()); - String[] valueList = options[0].getStringListValue(); - assertEquals(2, valueList.length); - assertEquals("a", valueList[0]); - assertEquals("b", valueList[1]); - String[] builtInList = options[0].getBuiltIns(); - assertEquals(1, builtInList.length); - assertEquals("c", builtInList[0]); - assertEquals(options[0].getCommand(), "-L"); - // Next option is a boolean in top - assertEquals("Boolean Option in Top", options[1].getName()); - assertEquals(IOption.BOOLEAN, options[1].getValueType()); - assertEquals(false, options[1].getBooleanValue()); - assertEquals("-b", options[1].getCommand()); - // Next option is a string category - assertEquals("String Option in Category", options[2].getName()); - assertEquals(IOption.STRING, options[2].getValueType()); - assertEquals("x", options[2].getStringValue()); - // Next option is another string category - assertEquals("Another String Option in Category", options[3].getName()); - assertEquals(IOption.STRING, options[3].getValueType()); - assertEquals("", options[3].getStringValue()); - assertEquals("-str", options[3].getCommand()); - // Next option is an enumerated - assertEquals("Enumerated Option in Category", options[4].getName()); - assertEquals(IOption.ENUMERATED, options[4].getValueType()); - // Post-2.0 enums store the ID, not the string value - assertEquals("default.enum.option", options[4].getSelectedEnum()); - assertEquals("-e1", options[4].getEnumCommand("default.enum.option")); - // Need this methof to populate the UI selection widget - valueList = options[4].getApplicableValues(); - assertEquals(2, valueList.length); - assertEquals("Default Enum", valueList[0]); - assertEquals("Another Enum", valueList[1]); - // Test compatability with 1.2 scheme of getting the command from the name - assertEquals("-e1", options[4].getEnumCommand(valueList[0])); - assertEquals("-e2", options[4].getEnumCommand(valueList[1])); - // Final option is another boolean - assertEquals("Boolean Option in Category", options[5].getName()); - assertEquals(IOption.BOOLEAN, options[5].getValueType()); - assertEquals(false, options[5].getBooleanValue()); - assertEquals("", options[5].getCommand()); - assertEquals("-nob", options[5].getCommandFalse()); - - // Option Categories - IOptionCategory topCategory = rootTool.getTopOptionCategory(); - assertEquals("Root Tool", topCategory.getName()); - Object[][] catoptions = topCategory.getOptions(configs[0]); - int i; - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(2, i); - assertEquals("List Option in Top", ((IOption) catoptions[0][1]).getName()); - assertEquals("Boolean Option in Top", ((IOption) catoptions[1][1]).getName()); - IOptionCategory[] categories = topCategory.getChildCategories(); - assertEquals(1, categories.length); - assertEquals("Category", categories[0].getName()); - catoptions = categories[0].getOptions(configs[0]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(4, i); - assertEquals("String Option in Category", ((IOption) catoptions[0][1]).getName()); - assertEquals("Another String Option in Category", ((IOption) catoptions[1][1]).getName()); - assertEquals("Enumerated Option in Category", ((IOption) catoptions[2][1]).getName()); - assertEquals("Boolean Option in Category", ((IOption) catoptions[3][1]).getName()); - - // There should be 3 defined configs - configs = type.getConfigurations(); - assertEquals(3, configs.length); - - // Root Config - IConfiguration rootConfig = configs[0]; - assertEquals("Root Config", rootConfig.getName()); - - // Tool elements - tools = rootConfig.getTools(); - assertEquals(1, tools.length); - assertEquals("Root Tool", tools[0].getName()); - assertEquals("-r", tools[0].getOutputFlag()); - assertTrue(tools[0].buildsFileType("foo")); - assertTrue(tools[0].buildsFileType("bar")); - assertTrue(tools[0].producesFileType("toor")); - assertEquals("doIt", tools[0].getToolCommand()); - assertEquals("", tools[0].getOutputPrefix()); - // The root tool defines one valid header file extension - assertTrue(rootTool.isHeaderFile("baz")); - assertTrue(tools[0].isHeaderFile("baz")); - assertEquals(ITool.FILTER_C, rootTool.getNatureFilter()); - - // Partially Overriden Configuration - assertEquals("Root Override Config", configs[1].getName()); - tools = configs[1].getTools(); - assertEquals(1, tools.length); - assertEquals("Root Tool", tools[0].getName()); - topCategory = tools[0].getTopOptionCategory(); - catoptions = topCategory.getOptions(configs[1]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(2, i); - assertEquals("List Option in Top", ((IOption) catoptions[0][1]).getName()); - valueList = ((IOption) catoptions[0][1]).getStringListValue(); - assertEquals("a", valueList[0]); - assertEquals("b", valueList[1]); - assertEquals("Boolean Option in Top", ((IOption) catoptions[1][1]).getName()); - assertEquals(true, ((IOption) catoptions[1][1]).getBooleanValue()); - assertEquals("-b", ((IOption) catoptions[1][1]).getCommand()); - categories = topCategory.getChildCategories(); - catoptions = categories[0].getOptions(configs[1]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(4, i); - assertEquals("String Option in Category", ((IOption) catoptions[0][1]).getName()); - assertEquals("y", ((IOption) catoptions[0][1]).getStringValue()); - assertEquals("Another String Option in Category", ((IOption) catoptions[1][1]).getName()); - assertEquals("", ((IOption) catoptions[1][1]).getStringValue()); - assertEquals("Enumerated Option in Category", ((IOption) catoptions[2][1]).getName()); - valueList = ((IOption) catoptions[2][1]).getApplicableValues(); - assertEquals(2, valueList.length); - assertEquals("Default Enum", valueList[0]); - assertEquals("Another Enum", valueList[1]); - assertEquals("-e1", ((IOption) catoptions[2][1]).getEnumCommand(valueList[0])); - assertEquals("-e2", ((IOption) catoptions[2][1]).getEnumCommand(valueList[1])); - assertEquals(1, tools.length); - assertEquals("Boolean Option in Category", ((IOption) catoptions[3][1]).getName()); - assertEquals(false, ((IOption) catoptions[3][1]).getBooleanValue()); - assertEquals("", ((IOption) catoptions[3][1]).getCommand()); - assertEquals("-nob", ((IOption) catoptions[3][1]).getCommandFalse()); - assertEquals(1, tools.length); - ITool tool = tools[0]; - assertNotNull(tool); - assertEquals("Root Tool", tool.getName()); - assertEquals("-r", tool.getOutputFlag()); - assertTrue(tool.buildsFileType("foo")); - assertTrue(tool.buildsFileType("bar")); - assertTrue(tool.producesFileType("toor")); - assertTrue(tool.isHeaderFile("baz")); - assertEquals("doIt", tool.getToolCommand()); - assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags()); - - // Completely Overridden configuration - assertEquals("Complete Override Config", configs[2].getName()); - tools = configs[2].getTools(); - assertEquals(1, tools.length); - assertEquals("Root Tool", tools[0].getName()); - topCategory = tools[0].getTopOptionCategory(); - catoptions = topCategory.getOptions(configs[2]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(2, i); - // Check that there's an string list with totally new values - assertEquals("List Option in Top", ((IOption) catoptions[0][1]).getName()); - assertEquals(IOption.STRING_LIST, ((IOption) catoptions[0][1]).getValueType()); - valueList = ((IOption) catoptions[0][1]).getStringListValue(); - assertTrue(valueList.length == 3); - assertEquals("d", valueList[0]); - assertEquals("e", valueList[1]); - assertEquals("f", valueList[2]); - assertEquals("-L", ((IOption) catoptions[0][1]).getCommand()); - // and a true boolean (commands should not have changed) - assertEquals("Boolean Option in Top", ((IOption) catoptions[1][1]).getName()); - assertEquals(IOption.BOOLEAN, ((IOption) catoptions[1][1]).getValueType()); - assertEquals(true, ((IOption) catoptions[1][1]).getBooleanValue()); - assertEquals("-b", ((IOption) catoptions[1][1]).getCommand()); - // Check that there's an overridden enumeration and string - categories = topCategory.getChildCategories(); - catoptions = categories[0].getOptions(configs[2]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(4, i); - assertEquals("String Option in Category", ((IOption) catoptions[0][1]).getName()); - assertEquals(IOption.STRING, ((IOption) catoptions[0][1]).getValueType()); - assertEquals("overridden", ((IOption) catoptions[0][1]).getStringValue()); - assertEquals("Another String Option in Category", ((IOption) catoptions[1][1]).getName()); - assertEquals(IOption.STRING, ((IOption) catoptions[1][1]).getValueType()); - assertEquals("alsooverridden", ((IOption) catoptions[1][1]).getStringValue()); - assertEquals("Enumerated Option in Category", ((IOption) catoptions[2][1]).getName()); - assertEquals(IOption.ENUMERATED, ((IOption) catoptions[2][1]).getValueType()); - assertEquals("another.enum.option", ((IOption) catoptions[2][1]).getSelectedEnum()); - assertEquals("Boolean Option in Category", ((IOption) catoptions[3][1]).getName()); - assertEquals(IOption.BOOLEAN, ((IOption) catoptions[3][1]).getValueType()); - assertEquals(true, ((IOption) catoptions[3][1]).getBooleanValue()); - tool = tools[0]; - assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags()); - - // Make sure that the build manager returns the default makefile generator (not null) - assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0])); - } - - /* - * Do a full sanity check on the root managed project. - */ - private void checkRootManagedProject(IManagedProject managedProj, String testValue) throws BuildException { - String expectedCleanCmd = "del /myworld"; - String expectedParserId = "org.eclipse.cdt.core.PE64"; - String[] expectedOSList = { "win32" }; - String[] expectedArchList = { "all" }; - assertTrue(managedProj.getProjectType().isTestProjectType()); - IConfiguration[] configs = managedProj.getConfigurations(); - if (configs[0].getArtifactName().equals("ManagedBuildTest")) { - assertEquals(configs[0].getArtifactExtension(), newExt); - } else { - assertEquals(configs[0].getArtifactExtension(), rootExt); - } - assertEquals(expectedCleanCmd, configs[0].getCleanCommand()); - assertEquals("make", configs[0].getBuildCommand()); - IToolChain toolChain = configs[0].getToolChain(); - ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); - String[] binaryParsers = targetPlatform.getBinaryParserList(); - assertEquals(binaryParsers.length, 1); - assertEquals(binaryParsers[0], expectedParserId); - assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); - assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); - // This configuration defines no errors parsers. - assertNull(configs[0].getErrorParserIds()); - assertTrue(Arrays.equals(configs[0].getErrorParserList(), CCorePlugin.getDefault().getAllErrorParsersIDs())); - - // Tools - ITool[] tools = configs[0].getTools(); - // Root Tool - ITool rootTool = tools[0]; - assertEquals("Root Tool", rootTool.getName()); - // 6 Options are defined in the root tool - IOption[] options = rootTool.getOptions(); - assertEquals(6, options.length); - // First option is a 3-element list with 1 built-in - assertEquals("List Option in Top", options[0].getName()); - assertEquals(IOption.STRING_LIST, options[0].getValueType()); - String[] valueList = options[0].getStringListValue(); - assertEquals(2, valueList.length); - assertEquals("a", valueList[0]); - assertEquals("b", valueList[1]); - String[] builtInList = options[0].getBuiltIns(); - assertEquals(1, builtInList.length); - assertEquals("c", builtInList[0]); - assertEquals(options[0].getCommand(), "-L"); - // Next option is a boolean in top - assertEquals("Boolean Option in Top", options[1].getName()); - assertEquals(IOption.BOOLEAN, options[1].getValueType()); - assertEquals(false, options[1].getBooleanValue()); - assertEquals("-b", options[1].getCommand()); - // Next option is a string category - assertEquals("String Option in Category", options[2].getName()); - assertEquals(IOption.STRING, options[2].getValueType()); - assertEquals(testValue, options[2].getStringValue()); - // Next option is another string category - assertEquals("Another String Option in Category", options[3].getName()); - assertEquals(IOption.STRING, options[3].getValueType()); - assertEquals("", options[3].getStringValue()); - assertEquals("-str", options[3].getCommand()); - // Next option is an enumerated - assertEquals("Enumerated Option in Category", options[4].getName()); - assertEquals(IOption.ENUMERATED, options[4].getValueType()); - // Post-2.0 enums store the ID, not the string value - assertEquals("default.enum.option", options[4].getSelectedEnum()); - assertEquals("-e1", options[4].getEnumCommand("default.enum.option")); - // Need this methof to populate the UI selection widget - valueList = options[4].getApplicableValues(); - assertEquals(2, valueList.length); - assertEquals("Default Enum", valueList[0]); - assertEquals("Another Enum", valueList[1]); - // Test compatability with 1.2 scheme of getting the command from the name - assertEquals("-e1", options[4].getEnumCommand(valueList[0])); - assertEquals("-e2", options[4].getEnumCommand(valueList[1])); - // Final option is another boolean - assertEquals("Boolean Option in Category", options[5].getName()); - assertEquals(IOption.BOOLEAN, options[5].getValueType()); - assertEquals(false, options[5].getBooleanValue()); - assertEquals("", options[5].getCommand()); - assertEquals("-nob", options[5].getCommandFalse()); - - // Option Categories - IOptionCategory topCategory = rootTool.getTopOptionCategory(); - assertEquals("Root Tool", topCategory.getName()); - Object[][] catoptions = topCategory.getOptions(configs[0]); - int i; - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(2, i); - IOption catOption = (IOption) catoptions[0][1]; - assertEquals("List Option in Top", catOption.getName()); - catOption = (IOption) catoptions[1][1]; - assertEquals("Boolean Option in Top", catOption.getName()); - IOptionCategory[] categories = topCategory.getChildCategories(); - assertEquals(1, categories.length); - assertEquals("Category", categories[0].getName()); - catoptions = categories[0].getOptions(configs[0]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(4, i); - catOption = (IOption) catoptions[0][1]; - assertEquals("String Option in Category", catOption.getName()); - catOption = (IOption) catoptions[1][1]; - assertEquals("Another String Option in Category", catOption.getName()); - catOption = (IOption) catoptions[2][1]; - assertEquals("Enumerated Option in Category", catOption.getName()); - catOption = (IOption) catoptions[3][1]; - assertEquals("Boolean Option in Category", catOption.getName()); - - // There should be 3 defined configs - assertEquals(3, configs.length); - - // Root Config - IConfiguration rootConfig = configs[0]; - assertEquals("Root Config", rootConfig.getName()); - - // Tool elements - tools = rootConfig.getTools(); - assertEquals(1, tools.length); - assertEquals("Root Tool", tools[0].getName()); - assertEquals("-r", tools[0].getOutputFlag()); - assertTrue(tools[0].buildsFileType("foo")); - assertTrue(tools[0].buildsFileType("bar")); - assertTrue(tools[0].producesFileType("toor")); - assertEquals("doIt", tools[0].getToolCommand()); - assertEquals("", tools[0].getOutputPrefix()); - // The root tool defines one valid header file extension - assertTrue(rootTool.isHeaderFile("baz")); - assertTrue(tools[0].isHeaderFile("baz")); - assertEquals(ITool.FILTER_C, rootTool.getNatureFilter()); - - // Partially Overriden Configuration - assertEquals("Root Override Config", configs[1].getName()); - tools = configs[1].getTools(); - assertEquals(1, tools.length); - assertEquals("Root Tool", tools[0].getName()); - topCategory = tools[0].getTopOptionCategory(); - catoptions = topCategory.getOptions(configs[1]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(2, i); - catOption = (IOption) catoptions[0][1]; - assertEquals("List Option in Top", catOption.getName()); - valueList = catOption.getStringListValue(); - assertEquals("a", valueList[0]); - assertEquals("b", valueList[1]); - catOption = (IOption) catoptions[1][1]; - assertEquals("Boolean Option in Top", catOption.getName()); - assertEquals(true, catOption.getBooleanValue()); - assertEquals("-b", catOption.getCommand()); - categories = topCategory.getChildCategories(); - catoptions = categories[0].getOptions(configs[1]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(4, i); - catOption = (IOption) catoptions[0][1]; - assertEquals("String Option in Category", catOption.getName()); - assertEquals("y", catOption.getStringValue()); - catOption = (IOption) catoptions[1][1]; - assertEquals("Another String Option in Category", catOption.getName()); - assertEquals("", catOption.getStringValue()); - catOption = (IOption) catoptions[2][1]; - assertEquals("Enumerated Option in Category", catOption.getName()); - valueList = catOption.getApplicableValues(); - assertEquals(2, valueList.length); - assertEquals("Default Enum", valueList[0]); - assertEquals("Another Enum", valueList[1]); - catOption = (IOption) catoptions[2][1]; - assertEquals("-e1", catOption.getEnumCommand(valueList[0])); - assertEquals("-e2", catOption.getEnumCommand(valueList[1])); - assertEquals(1, tools.length); - catOption = (IOption) catoptions[3][1]; - assertEquals("Boolean Option in Category", catOption.getName()); - assertEquals(false, catOption.getBooleanValue()); - assertEquals("", catOption.getCommand()); - assertEquals("-nob", catOption.getCommandFalse()); - assertEquals(1, tools.length); - ITool tool = tools[0]; - assertNotNull(tool); - assertEquals("Root Tool", tool.getName()); - assertEquals("-r", tool.getOutputFlag()); - assertTrue(tool.buildsFileType("foo")); - assertTrue(tool.buildsFileType("bar")); - assertTrue(tool.producesFileType("toor")); - assertTrue(tool.isHeaderFile("baz")); - assertEquals("doIt", tool.getToolCommand()); - assertEquals("-La -Lb -b y -e1 -nob", tool.getToolFlags()); - - // Completely Overridden configuration - assertEquals("Complete Override Config", configs[2].getName()); - tools = configs[2].getTools(); - assertEquals(1, tools.length); - assertEquals("Root Tool", tools[0].getName()); - topCategory = tools[0].getTopOptionCategory(); - catoptions = topCategory.getOptions(configs[2]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(2, i); - // Check that there's an string list with totally new values - catOption = (IOption) catoptions[0][1]; - assertEquals("List Option in Top", catOption.getName()); - assertEquals(IOption.STRING_LIST, catOption.getValueType()); - valueList = catOption.getStringListValue(); - assertTrue(valueList.length == 3); - assertEquals("d", valueList[0]); - assertEquals("e", valueList[1]); - assertEquals("f", valueList[2]); - assertEquals("-L", catOption.getCommand()); - // and a true boolean (commands should not have changed) - catOption = (IOption) catoptions[1][1]; - assertEquals("Boolean Option in Top", catOption.getName()); - assertEquals(IOption.BOOLEAN, catOption.getValueType()); - assertEquals(true, catOption.getBooleanValue()); - assertEquals("-b", catOption.getCommand()); - // Check that there's an overridden enumeration and string - categories = topCategory.getChildCategories(); - catoptions = categories[0].getOptions(configs[2]); - for (i = 0; i < catoptions.length; i++) - if (catoptions[i][0] == null) - break; - assertEquals(4, i); - catOption = (IOption) catoptions[0][1]; - assertEquals("String Option in Category", catOption.getName()); - assertEquals(IOption.STRING, catOption.getValueType()); - assertEquals("overridden", catOption.getStringValue()); - catOption = (IOption) catoptions[1][1]; - assertEquals("Another String Option in Category", catOption.getName()); - assertEquals(IOption.STRING, catOption.getValueType()); - assertEquals("alsooverridden", catOption.getStringValue()); - catOption = (IOption) catoptions[2][1]; - assertEquals("Enumerated Option in Category", catOption.getName()); - assertEquals(IOption.ENUMERATED, catOption.getValueType()); - assertEquals("another.enum.option", catOption.getSelectedEnum()); - catOption = (IOption) catoptions[3][1]; - assertEquals("Boolean Option in Category", catOption.getName()); - assertEquals(IOption.BOOLEAN, catOption.getValueType()); - assertEquals(true, catOption.getBooleanValue()); - tool = tools[0]; - assertEquals("-Ld -Le -Lf -b overridden -stralsooverridden -e2", tool.getToolFlags()); - - // Make sure that the build manager returns the default makefile generator (not null) - assertNotNull(ManagedBuildManager.getBuildfileGenerator(configs[0])); - } - - /* - * The Sub Sub project type has a reference to a tool that is defined - * independently from the project type itself. This is a common pattern - * for tools that are shared between many project types. - * - * The tool itself is defined as having two option categories, with - * one option in each category. To test that the reference is properly - * inheritted, the project type overrides the default value of the boolean - * option. - * - * The test confirms that the basic settings are inheritted through the - * reference, and that the overridden value is used instead of the - * default. It also tests that the command can be overidden through a - * tool reference. - * - * Finally, the string option in the configuration is overridden and the - * test confirms that it contains both the overridden boolean that the - * project type provides, and the overridden string that it provides. - * - * @param testSubSub - */ - private void checkSubSubProjectType(IProjectType projType) { - final String indyToolName = "Target Independent Tool"; - final String indyToolCommand = "RC.EXE"; - final String indyToolInputExt = "rc"; - final String indyToolOutputExt = "free"; - final String indyToolOutFlag = "/fo"; - final String indyToolHeader = "h"; - final String indyToolHeaderNot = "j"; - final String indyCatOne = "Free"; - final String indyCatTwo = "Chained"; - final String freeOptName = "String in Free"; - final String chainedOptName = "Boolean in Chained"; - final String freeOptValue = "Live free or die"; - final String newCmd = "Let the Wookie win"; - final String stringOverride = "The future language of slaves"; - - IConfiguration[] configs = projType.getConfigurations(); - // Check the inherited clean command - assertEquals("rm -yourworld", configs[0].getCleanCommand()); - // Check that the make command is overridden from parent - assertEquals("nmake", configs[0].getBuildCommand()); - // Make sure we get the proper binary parser - IToolChain toolChain = configs[0].getToolChain(); - ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); - assertEquals("org.eclipse.cdt.core.ELF", targetPlatform.getBinaryParserList()[0]); - // Make sure the os list is inherited - String[] expectedOSList = { "win32", "linux", "solaris" }; - assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); - // Make sure the arch list is inherited - String[] expectedArchList = { "x86", "ppc" }; - assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); - - // Get the 5 configurations (3 from test, 1 from test sub and 1 from this) - assertEquals(5, configs.length); - - // Check the tools. We should have 3 (1 from each parent and the one referenced). - ITool[] tools = configs[0].getTools(); - assertEquals(3, tools.length); - ITool toolRef = tools[0]; - - // Make sure we get all the tool settings - assertEquals(toolRef.getName(), indyToolName); - assertEquals(toolRef.getToolCommand(), indyToolCommand); - assertTrue(toolRef.buildsFileType(indyToolInputExt)); - assertEquals(toolRef.getOutputExtension(indyToolInputExt), indyToolOutputExt); - assertEquals(toolRef.getOutputFlag(), indyToolOutFlag); - assertTrue(toolRef.isHeaderFile(indyToolHeader)); - assertFalse(toolRef.isHeaderFile(indyToolHeaderNot)); - assertEquals(toolRef.getNatureFilter(), ITool.FILTER_BOTH); - // Check out the referenced tool and make sure we get all option categories - IOptionCategory topCategory = toolRef.getTopOptionCategory(); - IOptionCategory[] categories = topCategory.getChildCategories(); - assertEquals(1, categories.length); - assertEquals(categories[0].getName(), indyCatOne); - IOptionCategory[] subCategories = categories[0].getChildCategories(); - // Is the chained category a subcategory - assertEquals(1, subCategories.length); - assertEquals(subCategories[0].getName(), indyCatTwo); - // Make sure the option in the top category is correct - Object[][] optsInCat = categories[0].getOptions(configs[0]); - int i; - for (i = 0; i < optsInCat.length; i++) - if (optsInCat[i][0] == null) - break; - assertEquals(1, i); - IOption optCat = (IOption) optsInCat[0][1]; - assertEquals(freeOptName, optCat.getName()); - try { - // We get the option categories and options from the tool itself, but the - // tool reference will have a set of 0 to n option references that contain - // overridden settings. In this case, the string is inheritted and should - // not be reference - assertEquals(IOption.STRING, optCat.getValueType()); - IOption stringOpt = toolRef.getOptionById(optCat.getId()); - assertTrue(stringOpt instanceof Option); - assertEquals(freeOptValue, stringOpt.getStringValue()); - } catch (BuildException e1) { - fail("Failed getting string value in subsub :" + e1.getLocalizedMessage()); - } - - // Do the same for the options in the child cat - Object[][] optsInSubCat = subCategories[0].getOptions(configs[0]); - for (i = 0; i < optsInSubCat.length; i++) - if (optsInSubCat[i][0] == null) - break; - assertEquals(1, i); - IOption booleanRef = toolRef.getOptionById(((IOption) optsInSubCat[0][1]).getId()); - assertEquals(chainedOptName, booleanRef.getName()); - try { - assertEquals(IOption.BOOLEAN, booleanRef.getValueType()); - assertTrue(booleanRef.getBooleanValue()); - } catch (BuildException e) { - fail("Failure getting boolean value in subsub: " + e.getLocalizedMessage()); - } - - // Test that the tool command can be changed through the reference - toolRef.setToolCommand(newCmd); - assertEquals(toolRef.getToolCommand(), newCmd); - - // Muck about with the options in the local config - IConfiguration subSubConfig = projType.getConfiguration("sub.sub.config"); - assertNotNull(subSubConfig); - ITool[] configTools = subSubConfig.getTools(); - // This tool ref is inherited from parent, so it does not belong to the config - ITool configToolRef = configTools[0]; - assertNotNull(configToolRef); - optCat = (IOption) optsInCat[0][1]; - IOption configStringOpt = configToolRef.getOptionById(optCat.getId()); - assertNotNull(configStringOpt); - // Override the string option - try { - subSubConfig.setOption(configToolRef, configStringOpt, stringOverride); - } catch (BuildException e) { - fail("Failure setting string value in subsubconfiguration: " + e.getLocalizedMessage()); - } - // Now the config should have a tool ref to the independent tool - configTools = subSubConfig.getTools(); - configToolRef = configTools[0]; - assertNotNull(configToolRef); - - // Test that the string option is overridden in the configuration - optsInCat = categories[0].getOptions(configs[0]); - for (i = 0; i < optsInCat.length; i++) - if (optsInCat[i][0] == null) - break; - assertEquals(1, i); - optCat = (IOption) optsInCat[0][1]; - assertEquals(freeOptName, optCat.getName()); - configStringOpt = configToolRef.getOptionById(optCat.getId()); - try { - assertEquals(stringOverride, configStringOpt.getStringValue()); - } catch (BuildException e) { - fail("Failure getting string value in subsubconfiguration: " + e.getLocalizedMessage()); - } - // The tool should also contain the boolean option set to true - IOption optSubCat = (IOption) optsInSubCat[0][1]; - IOption configBoolOpt = configToolRef.getOptionById(optSubCat.getId()); - assertNotNull(configBoolOpt); - try { - assertTrue(configBoolOpt.getBooleanValue()); - } catch (BuildException e) { - fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage()); - } - - // Override it in config and retest - try { - subSubConfig.setOption(configToolRef, configBoolOpt, false); - } catch (BuildException e) { - fail("Failure setting boolean value in subsubconfiguration: " + e.getLocalizedMessage()); - } - optsInSubCat = subCategories[0].getOptions(configs[0]); - for (i = 0; i < optsInSubCat.length; i++) - if (optsInSubCat[i][0] == null) - break; - assertEquals(1, i); - configBoolOpt = configToolRef.getOptionById(((IOption) optsInSubCat[0][1]).getId()); - assertEquals(chainedOptName, booleanRef.getName()); - try { - assertFalse(configBoolOpt.getBooleanValue()); - } catch (BuildException e) { - fail("Failure getting boolean value in subsubconfiguration: " + e.getLocalizedMessage()); - } - } - - /* - * Do a sanity check on the values in the sub-project type. Most of the - * sanity on the how build model entries are read is performed in - * the root project type check, so these tests just verify that the the sub - * project type properly inherits from its parent. For the new options - * in the sub project type, the test does a sanity check just to be complete. - */ - private void checkSubProjectType(IProjectType projType) throws BuildException { - final String expectedFlags = "-I/usr/include -I/opt/gnome/include -IC:\\home\\tester/include -I\"../includes\" x y z"; - - IConfiguration[] configs = projType.getConfigurations(); - // Check the overridden clean command - assertEquals("rm -yourworld", configs[0].getCleanCommand()); - // Make sure the projType inherits the make command - assertEquals("make", configs[0].getBuildCommand()); - // Make sure the binary parser is hard-coded and available - IToolChain toolChain = configs[0].getToolChain(); - ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); - assertEquals("org.eclipse.cdt.core.PE64", targetPlatform.getBinaryParserList()[0]); - String[] expectedOSList = { "win32", "linux", "solaris" }; - assertTrue(Arrays.equals(expectedOSList, toolChain.getOSList())); - // Make sure the list is overridden - String[] expectedArchList = { "x86", "ppc" }; - assertTrue(Arrays.equals(expectedArchList, toolChain.getArchList())); - - // Make sure this is a test projType - assertTrue(projType.isTestProjectType()); - // Make sure the build artifact extension is there - assertEquals(configs[0].getArtifactExtension(), subExt); - - // Get the tools for this projType - ITool[] tools = configs[0].getTools(); - // Do we inherit properly from parent - ITool rootTool = tools[0]; - assertEquals("Root Tool", rootTool.getName()); - // Now get the tool defined for this projType - ITool subTool = tools[1]; - assertEquals("Sub Tool", subTool.getName()); - // Confirm that it has four options - IOption[] subOpts = subTool.getOptions(); - assertEquals(5, subOpts.length); - assertEquals("", subTool.getOutputFlag()); - assertTrue(subTool.buildsFileType("yarf")); - assertTrue(subTool.producesFileType("bus")); - assertEquals("", subTool.getToolCommand()); - assertEquals("lib", subTool.getOutputPrefix()); - assertTrue(subTool.isHeaderFile("arf")); - assertTrue(subTool.isHeaderFile("barf")); - assertEquals(ITool.FILTER_BOTH, subTool.getNatureFilter()); - - // Do a sanity check on the options - assertEquals("Include Paths", subOpts[0].getName()); - assertEquals(IOption.INCLUDE_PATH, subOpts[0].getValueType()); - String[] incPath = subOpts[0].getIncludePaths(); - assertEquals(2, incPath.length); - assertEquals("/usr/include", incPath[0]); - assertEquals("/opt/gnome/include", incPath[1]); - String[] builtInPaths = subOpts[0].getBuiltIns(); - assertEquals(1, builtInPaths.length); - assertEquals("/usr/gnu/include", builtInPaths[0]); - assertEquals("-I", subOpts[0].getCommand()); - assertEquals(IOption.BROWSE_DIR, subOpts[0].getBrowseType()); - - // There are no user-defined preprocessor symbols - assertEquals("Defined Symbols", subOpts[1].getName()); - assertEquals(IOption.PREPROCESSOR_SYMBOLS, subOpts[1].getValueType()); - String[] defdSymbols = subOpts[1].getDefinedSymbols(); - assertEquals(0, defdSymbols.length); - assertEquals("-D", subOpts[1].getCommand()); - // But there is a builtin - String[] builtInSymbols = subOpts[1].getBuiltIns(); - assertEquals(1, builtInSymbols.length); - assertEquals("BUILTIN", builtInSymbols[0]); - // Broswe type should be none - assertEquals(IOption.BROWSE_NONE, subOpts[1].getBrowseType()); - - assertEquals("More Includes", subOpts[2].getName()); - assertEquals(IOption.INCLUDE_PATH, subOpts[2].getValueType()); - String[] moreIncPath = subOpts[2].getIncludePaths(); - assertEquals(2, moreIncPath.length); - assertEquals("C:\\home\\tester/include", moreIncPath[0]); - assertEquals("-I", subOpts[2].getCommand()); - assertEquals(IOption.BROWSE_DIR, subOpts[2].getBrowseType()); - - // Check the user object option - assertEquals("User Objects", subOpts[3].getName()); - assertEquals(IOption.OBJECTS, subOpts[3].getValueType()); - String[] objs = subOpts[3].getUserObjects(); - assertEquals(2, objs.length); - assertEquals("obj1.o", objs[0]); - assertEquals("obj2.o", objs[1]); - assertEquals(IOption.BROWSE_FILE, subOpts[3].getBrowseType()); - assertEquals("", subOpts[3].getCommand()); - - // There should be a string list with no command - assertEquals("No Command StringList", subOpts[4].getName()); - assertEquals(IOption.STRING_LIST, subOpts[4].getValueType()); - - // Make sure the tool flags look right - assertEquals(subTool.getToolFlags(), expectedFlags); - - // Get the configs for this projType; it should inherit all the configs defined for the parent - assertEquals(4, configs.length); - assertEquals("Sub Config", configs[0].getName()); - assertEquals("Root Config", configs[1].getName()); - assertEquals("Root Override Config", configs[2].getName()); - assertEquals("Complete Override Config", configs[3].getName()); - } - - private void checkForwardProjectTypes(IProjectType parent, IProjectType child, IProjectType grandchild) { - // check that the projType parent reference has been resolved. - assertEquals(parent, child.getSuperClass()); - assertEquals(child, grandchild.getSuperClass()); - - // get the parent tool - IConfiguration[] parentConfigs = parent.getConfigurations(); - ITool[] parentTools = parentConfigs[0].getTools(); - assertEquals(1, parentTools.length); - ITool parentTool = parentTools[0]; - assertNotNull(parentTool); - - // check option categories - IOption option = parentTool.getOptionById("test.forward.option"); - assertNotNull(option); - IOptionCategory[] firstLevel = parentTool.getTopOptionCategory().getChildCategories(); - assertEquals(1, firstLevel.length); - IOptionCategory[] secondLevel = firstLevel[0].getChildCategories(); - assertEquals(1, secondLevel.length); - assertEquals(0, secondLevel[0].getChildCategories().length); - Object[][] optList = secondLevel[0].getOptions(parentConfigs[0]); - int i; - for (i = 0; i < optList.length; i++) - if (optList[i][0] == null) - break; - assertEquals(1, i); - assertEquals(option, optList[0][1]); - - // get the tool reference from the child - IConfiguration[] childConfigs = child.getConfigurations(); - ITool[] childTools = childConfigs[0].getTools(); - assertEquals(1, childTools.length); - ITool childToolRef = childTools[0]; - assertEquals(parentTool.getSuperClass(), childToolRef.getSuperClass()); - - // get and check the option reference - IOption optRef = childToolRef.getOptionById("test.forward.option"); - assertEquals(option, optRef); - - // get the tool reference from the grandchild - IConfiguration[] grandConfigs = grandchild.getConfigurations(); - ITool[] grandTools = grandConfigs[0].getTools(); - assertEquals(1, grandTools.length); - ITool grandToolRef = grandTools[0]; - assertEquals(parentTool.getSuperClass(), grandToolRef.getSuperClass()); - - } - - public void checkProviderProjectType(IProjectType projType) throws Exception { - Properties props = new Properties(); - props.load(getClass().getResourceAsStream("test_commands")); - - // check that this projType is in the file - String command = props.getProperty(projType.getId()); - assertNotNull(command); - - IProjectType parent = projType.getSuperClass(); - assertNotNull(parent); - assertEquals("test.forward.parent.target", parent.getId()); - - IConfiguration[] configs = projType.getConfigurations(); - ITool toolRef = configs[0].getFilteredTools()[0]; - assertEquals(command, toolRef.getToolCommand()); - } - - /** - * Remove all the project information associated with the project used during test. - */ - public void cleanup() throws CoreException, IOException { - ResourceHelper.cleanUp(getName()); - removeProject(projectName); - removeProject(projectName2); - } - - /* (non-Javadoc) - * Create a new project named name or return the project in - * the workspace of the same name if it exists. - * - * @param name The name of the project to create or retrieve. - * @return - * @throws CoreException - */ - private IProject createProject(String name) throws CoreException { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - final IProject newProjectHandle = root.getProject(name); - IProject project = null; - - if (!newProjectHandle.exists()) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceDescription workspaceDesc = workspace.getDescription(); - workspaceDesc.setAutoBuilding(false); - workspace.setDescription(workspaceDesc); - IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); - //description.setLocation(root.getLocation()); - project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), - /*MakeCorePlugin.MAKE_PROJECT_ID*/ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); - - // Now associate the builder with the project - ManagedBuildTestHelper.addManagedBuildNature(project); - } else { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } - }; - NullProgressMonitor monitor = new NullProgressMonitor(); - workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor); - project = newProjectHandle; - } - - // Open the project if we have to - if (!project.isOpen()) { - project.open(new NullProgressMonitor()); - } - - return project; - } - - /** - * Remove the IProject with the name specified in the argument from the - * receiver's workspace. - * - * @param name - */ - private void removeProject(String name) { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject project = root.getProject(name); - if (project.exists()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e1) { - } finally { - try { - System.gc(); - System.runFinalization(); - project.delete(true, true, null); - } catch (CoreException e2) { - assertTrue(false); - } - } - } - } - - /** - * @throws BuildException - */ - public void testErrorParsers() throws BuildException { - // Create new project - IProject project = null; - try { - project = createProject(projectName2); - // Now associate the builder with the project - ManagedBuildTestHelper.addManagedBuildNature(project); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - } catch (CoreException e) { - fail("Test failed on error parser project creation: " + e.getLocalizedMessage()); - } - - // Find the base project Type definition - IProjectType projType = ManagedBuildManager.getProjectType("test.error.parsers"); - assertNotNull(projType); - - // Create the target for our project that builds a dummy executable - IManagedProject newProj = ManagedBuildManager.createManagedProject(project, projType); - assertEquals(newProj.getName(), projType.getName()); - ManagedBuildManager.setNewProjectVersion(project); - - ManagedBuildManager.getBuildInfo(project).setValid(true); - // Initialize the path entry container - IStatus initResult = ManagedBuildManager.initBuildInfoContainer(project); - if (initResult.getCode() != IStatus.OK) { - fail("Initializing build information failed for: " + project.getName() + " because: " - + initResult.getMessage()); - } - - // Copy over the configs - IConfiguration[] baseConfigs = projType.getConfigurations(); - for (int i = 0; i < baseConfigs.length; ++i) { - newProj.createConfiguration(baseConfigs[i], baseConfigs[i].getId() + "." + i); - } - - // Test this out - checkErrorParsersProject(newProj); - - // Save, close, reopen and test again - ManagedBuildManager.saveBuildInfo(project, true); - ManagedBuildManager.removeBuildInfo(project); - try { - ResourceHelper.joinIndexerBeforeCleanup(getName()); - project.close(null); - } catch (CoreException e) { - fail("Failed on error parser project close: " + e.getLocalizedMessage()); - } - try { - project.open(null); - } catch (CoreException e) { - fail("Failed on error parser project open: " + e.getLocalizedMessage()); - } - - // Test that the default config was remembered - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - - // Check the rest of the default information - checkErrorParsersProject(info.getManagedProject()); - ManagedBuildManager.removeBuildInfo(project); - } - - /* - * Do a sanity check on the error parsers target. - */ - private void checkErrorParsersProject(IManagedProject proj) throws BuildException { - // Target stuff - String expectedBinParserId = "org.eclipse.cdt.core.PE64"; - IConfiguration[] configs = proj.getConfigurations(); - IToolChain toolChain = configs[0].getToolChain(); - ITargetPlatform targetPlatform = toolChain.getTargetPlatform(); - assertEquals(expectedBinParserId, targetPlatform.getBinaryParserList()[0]); - // This target defines errors parsers. Check that the error parsers - // have been assigned. - assertEquals( - "org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GmakeErrorParser", - configs[0].getErrorParserIds()); - - // Tool - ITool[] tools = configs[0].getTools(); - ITool rootTool = tools[0]; - assertEquals(1, tools.length); - assertEquals("EP Tool", tools[0].getName()); - assertEquals("-o", tools[0].getOutputFlag()); - assertTrue(tools[0].buildsFileType("y")); - assertTrue(tools[0].buildsFileType("x")); - assertTrue(tools[0].producesFileType("xy")); - assertEquals("EP", tools[0].getToolCommand()); - assertEquals(ITool.FILTER_C, rootTool.getNatureFilter()); - - // There should be one defined configs - assertEquals(1, configs.length); - } - - /** - * Test that the build artifact of a ITarget can be modified - * programmatically. - */ - public void testConfigBuildArtifact() throws CoreException { - // Open the test project - IProject project = createProject(projectName); - IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); - assertNotNull(info); - IManagedProject managedProj = info.getManagedProject(); - assertNotNull(managedProj); - IConfiguration defaultConfig = info.getDefaultConfiguration(); - assertNotNull(defaultConfig); - - // Set the build artifact of the configuration - String ext = defaultConfig.getArtifactExtension(); - String name = project.getName() + "." + ext; - defaultConfig.setArtifactName(name); - - // Save, close, reopen and test again - ManagedBuildManager.saveBuildInfo(project, false); - ManagedBuildManager.removeBuildInfo(project); - ResourceHelper.joinIndexerBeforeCleanup(getName()); - project.close(null); - project.open(null); - - // Check the artifact name - info = ManagedBuildManager.getBuildInfo(project); - assertNotNull(info); - managedProj = info.getManagedProject(); - assertNotNull(managedProj); - defaultConfig = info.getDefaultConfiguration(); - assertNotNull(defaultConfig); - assertEquals(name, defaultConfig.getArtifactName()); - } - - public void testThatAlwaysFails() { - assertTrue(false); - } - -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests_SharedToolOptions.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests_SharedToolOptions.java deleted file mode 100644 index ff8afb403b1..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests_SharedToolOptions.java +++ /dev/null @@ -1,566 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2011 Symbian Ltd and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Symbian - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.core.tests; - -import java.net.URL; - -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.managedbuilder.core.IConfiguration; -import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; -import org.eclipse.cdt.managedbuilder.core.IManagedProject; -import org.eclipse.cdt.managedbuilder.core.IOption; -import org.eclipse.cdt.managedbuilder.core.IOptionCategory; -import org.eclipse.cdt.managedbuilder.core.IProjectType; -import org.eclipse.cdt.managedbuilder.core.ITool; -import org.eclipse.cdt.managedbuilder.core.IToolChain; -import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; -import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; -import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; -import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler; -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.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Platform; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -// TODO LK - write test for resource configurations + IOptionCategory.getOptions(config) -// TODO LK - write tests for EVENT_OPEN call-backs -// TODO LK - do not deprecate IOption.getParent() as suggested by Leo - -/* - * These tests exercise CDT 3.0 shared tool options extensions - */ -public class ManagedBuildCoreTests_SharedToolOptions extends TestCase { - - class IconComparator { - static final int None = 0; - static final int One = 1; - static final int Two = 2; - - // The following uses a numbering scheme defined for - // testCategory and testOption - - // Co-ordinates of option groups 2nd level that have icon 1 - int One_i[] = { 3, 2, 4, 7 }; - int One_j[] = { 1, 2, 1, 1 }; - // Co-ordinates of option groups 2nd level that have icon 1 - int Two_i[] = { 2, 6 }; - int Two_j[] = { 1, 1 }; - - IconComparator() { - assertEquals(One_i.length, One_j.length); - assertEquals(Two_i.length, Two_j.length); - } - - int Compare(int i, int j) { - int k; - - // Check for icon 1 - for (k = 0; k < One_i.length; k++) { - if ((i == One_i[k]) && (j == One_j[k])) { - return One; - } - } - // Check for icon 2 - for (k = 0; k < Two_i.length; k++) { - if ((i == Two_i[k]) && (j == Two_j[k])) { - return Two; - } - } - // None of them - return None; - } - } - - class ValueHandlerComparator { - static final int MBS = 0; - static final int TEST = 1; - - // The following uses a numbering scheme defined for - // testCategory and testOption - - // Co-ordinates of option groups 2nd level that have a test value handler - int Test_i[] = { 2, 2, 3, 5, 7 }; - int Test_j[] = { 1, 4, 2, 1, 1 }; - String Test_arg[] = { "Option2.1.1", "Option2.2.2", "Option3.1.2", "Option5.1", "Option7.1" }; - String last_arg; - - ValueHandlerComparator() { - assertEquals(Test_i.length, Test_j.length); - assertEquals(Test_i.length, Test_arg.length); - last_arg = ""; - } - - int Compare(int i, int j) { - int k; - - // Check for Test handler - for (k = 0; k < Test_i.length; k++) { - if ((i == Test_i[k]) && (j == Test_j[k])) { - last_arg = Test_arg[k]; - return TEST; - } - } - // None of them - last_arg = ""; - return MBS; - } - - String getArg() { - return last_arg; - } - } - - // Constants - private final String projectName = "test30_sto"; - private final String projectID = "test30_sto.dummy"; - private final String configID = "test30_sto.dummy.config"; - private final String configName = "Configuration for test30_sto"; - - // Control variables - private boolean testExtensionElements = true; - private boolean testIsSetup = false; - - // Chain leading to tool, etc - private IProjectType testProject; - private IConfiguration testConfig; - private IToolChain testToolChain; - - // Direct children of toolChain - private ITool testTools[]; - private IOptionCategory testCategoryTop[]; - private IOption testOptionTop[]; - - // 2nd level children (of toolChain and tool) mapped in the following pattern - // onto the arrays: - // tool_1: cat_1.1 cat_1.2 cat_1.3 ... - // ... - // tool_n: cat_n.1 catn.2 - // The same 2d-array is used to store top-level categories - // n+1: topcat_1 - // ... - // n+m: topcat_m - private Object testCategory[][]; - private Object testOption[][]; - - // Helper classes - private IconComparator iconComparator; - private ValueHandlerComparator valueHandlerComparator; - - public ManagedBuildCoreTests_SharedToolOptions(String name) { - super(name); - - iconComparator = new IconComparator(); - valueHandlerComparator = new ValueHandlerComparator(); - } - - public static Test suite() { - TestSuite suite = new TestSuite(ManagedBuildCoreTests_SharedToolOptions.class.getName()); - - suite.addTest(new ManagedBuildCoreTests_SharedToolOptions("testIcons")); - suite.addTest(new ManagedBuildCoreTests_SharedToolOptions("testValueHandlers")); - suite.addTest(new ManagedBuildCoreTests_SharedToolOptions("testOptions")); - suite.addTest(new ManagedBuildCoreTests_SharedToolOptions("testConfiguration")); - - return suite; - } - - private void assertCorrectId(String s1, String s2) { - if (testExtensionElements == true) { - // A strict comparison is required - assertTrue(s1.equals(s2)); - } else { - // Compare for non-extension element Id's - assertTrue(s1.startsWith(s2 + ".")); - } - } - - private IProject createProject(String name) throws CoreException { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - final IProject newProjectHandle = root.getProject(name); - IProject project = null; - - if (!newProjectHandle.exists()) { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceDescription workspaceDesc = workspace.getDescription(); - workspaceDesc.setAutoBuilding(false); - workspace.setDescription(workspaceDesc); - IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); - //description.setLocation(root.getLocation()); - project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), - ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); - } else { - IWorkspace workspace = ResourcesPlugin.getWorkspace(); - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - @Override - public void run(IProgressMonitor monitor) throws CoreException { - newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); - } - }; - NullProgressMonitor monitor = new NullProgressMonitor(); - workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor); - project = newProjectHandle; - } - - // Open the project if we have to - if (!project.isOpen()) { - project.open(new NullProgressMonitor()); - } - - return project; - } - - /** - * Sets up the test environment for the default project - */ - private void setupDefaultProject() throws Exception { - - // The assertCorrectId() call needs to be set up - testExtensionElements = true; - // Get all the key structures of our test and do some sanity checking - // - testProject = ManagedBuildManager.getProjectType(projectID); - assertNotNull(testProject); - assertTrue(testProject.isTestProjectType()); - assertFalse(testProject.isAbstract()); - - // Get and check project configurations - only one - // - setupConfiguration(); - assertTrue(testConfig.isExtensionElement()); - } - - /** - * Sets up the test configuration from the project set - * in the test - */ - private void setupConfiguration() throws Exception { - - IConfiguration[] configs = testProject.getConfigurations(); - assertNotNull(configs); - assertEquals(configs.length, 1); - testConfig = configs[0]; - assertEquals(testConfig.getId(), configID); - assertEquals(testConfig.getName(), configName); - } - - /** - * Sets up the test environment for a project created from the - * default project - */ - private IProject setupProject() throws Exception { - - // The assertCorrectId() call needs to be set up - testExtensionElements = false; - // Create new project - IProject project = null; - try { - project = createProject(projectName); - // Now associate the builder with the project - ManagedBuildTestHelper.addManagedBuildNature(project); - IProjectDescription description = project.getDescription(); - // Make sure it has a managed nature - if (description != null) { - assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); - } - - } catch (CoreException e) { - fail("Test failed on project creation: " + e.getLocalizedMessage()); - } - // Find the base project type definition - IProjectType projType = ManagedBuildManager.getProjectType(projectID); - assertNotNull(projType); - // Create a managed project - IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType); - assertEquals(newProject.getName(), projType.getName()); - assertFalse(newProject.equals(projType)); - ManagedBuildManager.setNewProjectVersion(project); - // Set up the environment - testProject = newProject.getProjectType(); - IConfiguration config = testProject.getConfiguration(configID); - testConfig = newProject.createConfiguration(config, configID + ".12345678"); - - return project; - } - - /** - * Sets up the test environment and does some initial checking. - * Do not do this in the constructor, as it is part of the test. - */ - private void setupTestEnvironment() throws Exception { - - int i; - - // Test ID's - // - // String configID = "test30_sto.dummy.config"; - // String configName = "Configuration for test30_sto"; - String toolChainID = "test30_sto.dummy.toolchain"; - String toolChainName = "Toolchain for test30_sto"; - // Toolchain Info - int numTools = 4; - String toolIDs = "test30_sto.dummy.tool."; - int firstToolID = 1; - // Top level option categories and groups - // int numTopCategories = 3; - String topCategoryIDs = "test30_sto.dummy.category."; - int firstTopCategoryID = 5; - - // Sizes of some arrays - int sizeCategoryTop = 0; - int sizeOptionTop = 0; - int sizeTools = 0; - - // Fetch toolchain - // - testToolChain = testConfig.getToolChain(); - assertNotNull(testToolChain); - assertEquals(testToolChain.getName(), toolChainName); - assertCorrectId(testToolChain.getId(), toolChainID); - - // Fetch and check tools list - // - testTools = testToolChain.getTools(); - assertNotNull(testTools); - assertEquals(testTools.length, numTools); - int toolNo = firstToolID; - sizeTools = numTools; - for (i = 0; i < sizeTools; i++) { - assertCorrectId(testTools[i].getId(), toolIDs + toolNo); - toolNo++; - } - - // Fetch and check top level option categories and options - // - testCategoryTop = testToolChain.getChildCategories(); - testOptionTop = testToolChain.getOptions(); - - if (testCategoryTop != null) { - int categoryNo = firstTopCategoryID; - sizeCategoryTop = testCategoryTop.length; - for (i = 0; i < sizeCategoryTop; i++, categoryNo++) { - String ID = testCategoryTop[i].getId(); - // Categories are always extension elements, so check - // for an identical match - assertEquals(ID, topCategoryIDs + categoryNo); - } - } - if (testOptionTop != null) { - sizeOptionTop = testOptionTop.length; - } - - // Fetch and check 2nd level level option categories and options - // - testCategory = new Object[testTools.length + sizeCategoryTop][]; - testOption = new Object[testTools.length + sizeOptionTop][]; - for (i = 0; i < sizeTools; i++) { - testCategory[i] = testTools[i].getChildCategories(); - testOption[i] = testTools[i].getOptions(); - // Make the arrays safe in case we have null references - if (testCategory[i] == null) { - testCategory[i] = new Object[0]; - } - if (testOption[i] == null) { - testOption[i] = new Object[0]; - } - } - // Add top level categories and options to test arrays - // - for (i = 0; i < sizeCategoryTop; i++) { - testCategory[sizeTools + i] = new Object[1]; - testCategory[sizeTools + i][0] = testCategoryTop[i]; - } - for (i = 0; i < sizeOptionTop; i++) { - testOption[sizeTools + i] = new Object[1]; - testOption[sizeTools + i][0] = testOptionTop[i]; - } - } - - /** - * Check, whether icon paths in tool1 - tool3 have been created. - * Check, whether icon paths in category 2.1 - 3.1 have been created - */ - public void testIcons() throws Exception { - - // Set up the environment - if (testIsSetup == false) { - setupDefaultProject(); - setupTestEnvironment(); - } - - // Get path's of icons to compare against - CTestPlugin me = CTestPlugin.getDefault(); - URL icon1 = Platform.asLocalURL(me.find(new Path("icons/one.gif"), null)); - URL icon2 = Platform.asLocalURL(me.find(new Path("icons/two.gif"), null)); - - // Check the icons on tools - assertToolIcon(testTools[0], icon1); - assertToolIcon(testTools[1], null); - assertToolIcon(testTools[2], icon2); - - // Check the top level and 2nd level categories - int i; - for (i = 0; i < testCategory.length; i++) { - - int j; - for (j = 0; j < testCategory[i].length; j++) { - URL url = ((IOptionCategory) testCategory[i][j]).getIconPath(); - - switch (iconComparator.Compare(i + 1, j + 1)) { - case IconComparator.None: - assertEquals(url, null); - break; - case IconComparator.One: - assertEquals(url, icon1); - break; - case IconComparator.Two: - assertEquals(url, icon2); - break; - } - } - } - } - - private void assertToolIcon(ITool tool, URL url) { - assertTrue(tool instanceof IOptionCategory); - IOptionCategory toolCategory = (IOptionCategory) tool; - assertEquals(toolCategory.getIconPath(), url); - } - - /** - * Test whether option objects have value handlers as expected - */ - public void testValueHandlers() throws Exception { - - // Set up the environment - if (testIsSetup == false) { - setupDefaultProject(); - setupTestEnvironment(); - } - - int i; - for (i = 0; i < testOption.length; i++) { - - int j; - for (j = 0; j < testOption[i].length; j++) { - IOption option = (IOption) testOption[i][j]; - IManagedOptionValueHandler handler = option.getValueHandler(); - String handlerExtraArg = option.getValueHandlerExtraArgument(); - - switch (valueHandlerComparator.Compare(i + 1, j + 1)) { - case ValueHandlerComparator.MBS: - assertEquals(ManagedOptionValueHandler.getManagedOptionValueHandler(), handler); - break; - case ValueHandlerComparator.TEST: - assertTrue(handler instanceof TestValueHandler); - assertEquals(valueHandlerComparator.getArg(), handlerExtraArg); - break; - } - } - } - } - - /** - * Test whether OptionCatgeory.getOptions(IConfiguration) works as expected - */ - public void testOptions() throws Exception { - - // Set up the environment - if (testIsSetup == false) { - setupDefaultProject(); - setupTestEnvironment(); - } - // Go over all option Categories - int i; - int j; - Object[][] results; - for (i = 0; i < testCategory.length; i++) { - for (j = 0; j < testCategory[i].length; j++) { - results = ((IOptionCategory) testCategory[i][j]).getOptions(testConfig); - // Go over results and check the following: - // A) results[k][0] must be the parent tool or toolChain - // B) results[k][1] must be in testOption[i] - for (int k = 0; k < results[0].length; k++) { - if (results[k][0] == null) { - assertNull(results[k][1]); - break; - } - // A) results[k][0] must be the parent tool or toolChain - switch (i) { - case 0: - case 1: - case 2: - case 3: - // Tool - assertTrue(results[k][0] instanceof ITool); - assertEquals(results[k][0], testTools[i]); - break; - default: - // ToolChain - assertTrue(results[k][0] instanceof IToolChain); - assertEquals(results[k][0], testToolChain); - break; - } - // B) results[k][1] must be in testOption[i] - // and its parent must be testCategory[i][j] - boolean found = false; - for (int l = 0; l < testOption[i].length; l++) { - if (testOption[i][l] == results[k][1]) { - found = true; - break; - } - } - assertTrue(found); - assertEquals(((IOption) results[k][1]).getCategory(), testCategory[i][j]); - } - } - } - } - - /** - * Test whether all the other tests work as expected for - * non-extension configurations. - */ - public void testConfiguration() throws Exception { - - // Set up the environment - IProject project = setupProject(); - try { - setupTestEnvironment(); - // Rerun the other tests, without setting the test up again - testIsSetup = true; - testIcons(); - testValueHandlers(); - testOptions(); - } finally { - ResourceHelper.cleanUp(getName()); - project.delete(true, new NullProgressMonitor()); - } - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java new file mode 100644 index 00000000000..72b25cd1b9a --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java @@ -0,0 +1,566 @@ +/******************************************************************************* + * Copyright (c) 2005, 2011 Symbian Ltd and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Symbian - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.core.tests; + +import java.net.URL; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; +import org.eclipse.cdt.managedbuilder.core.IManagedProject; +import org.eclipse.cdt.managedbuilder.core.IOption; +import org.eclipse.cdt.managedbuilder.core.IOptionCategory; +import org.eclipse.cdt.managedbuilder.core.IProjectType; +import org.eclipse.cdt.managedbuilder.core.ITool; +import org.eclipse.cdt.managedbuilder.core.IToolChain; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; +import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; +import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler; +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.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceDescription; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +// TODO LK - write test for resource configurations + IOptionCategory.getOptions(config) +// TODO LK - write tests for EVENT_OPEN call-backs +// TODO LK - do not deprecate IOption.getParent() as suggested by Leo + +/* + * These tests exercise CDT 3.0 shared tool options extensions + */ +public class ManagedBuildCore_SharedToolOptionsTests extends TestCase { + + class IconComparator { + static final int None = 0; + static final int One = 1; + static final int Two = 2; + + // The following uses a numbering scheme defined for + // testCategory and testOption + + // Co-ordinates of option groups 2nd level that have icon 1 + int One_i[] = { 3, 2, 4, 7 }; + int One_j[] = { 1, 2, 1, 1 }; + // Co-ordinates of option groups 2nd level that have icon 1 + int Two_i[] = { 2, 6 }; + int Two_j[] = { 1, 1 }; + + IconComparator() { + assertEquals(One_i.length, One_j.length); + assertEquals(Two_i.length, Two_j.length); + } + + int Compare(int i, int j) { + int k; + + // Check for icon 1 + for (k = 0; k < One_i.length; k++) { + if ((i == One_i[k]) && (j == One_j[k])) { + return One; + } + } + // Check for icon 2 + for (k = 0; k < Two_i.length; k++) { + if ((i == Two_i[k]) && (j == Two_j[k])) { + return Two; + } + } + // None of them + return None; + } + } + + class ValueHandlerComparator { + static final int MBS = 0; + static final int TEST = 1; + + // The following uses a numbering scheme defined for + // testCategory and testOption + + // Co-ordinates of option groups 2nd level that have a test value handler + int Test_i[] = { 2, 2, 3, 5, 7 }; + int Test_j[] = { 1, 4, 2, 1, 1 }; + String Test_arg[] = { "Option2.1.1", "Option2.2.2", "Option3.1.2", "Option5.1", "Option7.1" }; + String last_arg; + + ValueHandlerComparator() { + assertEquals(Test_i.length, Test_j.length); + assertEquals(Test_i.length, Test_arg.length); + last_arg = ""; + } + + int Compare(int i, int j) { + int k; + + // Check for Test handler + for (k = 0; k < Test_i.length; k++) { + if ((i == Test_i[k]) && (j == Test_j[k])) { + last_arg = Test_arg[k]; + return TEST; + } + } + // None of them + last_arg = ""; + return MBS; + } + + String getArg() { + return last_arg; + } + } + + // Constants + private final String projectName = "test30_sto"; + private final String projectID = "test30_sto.dummy"; + private final String configID = "test30_sto.dummy.config"; + private final String configName = "Configuration for test30_sto"; + + // Control variables + private boolean testExtensionElements = true; + private boolean testIsSetup = false; + + // Chain leading to tool, etc + private IProjectType testProject; + private IConfiguration testConfig; + private IToolChain testToolChain; + + // Direct children of toolChain + private ITool testTools[]; + private IOptionCategory testCategoryTop[]; + private IOption testOptionTop[]; + + // 2nd level children (of toolChain and tool) mapped in the following pattern + // onto the arrays: + // tool_1: cat_1.1 cat_1.2 cat_1.3 ... + // ... + // tool_n: cat_n.1 catn.2 + // The same 2d-array is used to store top-level categories + // n+1: topcat_1 + // ... + // n+m: topcat_m + private Object testCategory[][]; + private Object testOption[][]; + + // Helper classes + private IconComparator iconComparator; + private ValueHandlerComparator valueHandlerComparator; + + public ManagedBuildCore_SharedToolOptionsTests(String name) { + super(name); + + iconComparator = new IconComparator(); + valueHandlerComparator = new ValueHandlerComparator(); + } + + public static Test suite() { + TestSuite suite = new TestSuite(ManagedBuildCore_SharedToolOptionsTests.class.getName()); + + suite.addTest(new ManagedBuildCore_SharedToolOptionsTests("testIcons")); + suite.addTest(new ManagedBuildCore_SharedToolOptionsTests("testValueHandlers")); + suite.addTest(new ManagedBuildCore_SharedToolOptionsTests("testOptions")); + suite.addTest(new ManagedBuildCore_SharedToolOptionsTests("testConfiguration")); + + return suite; + } + + private void assertCorrectId(String s1, String s2) { + if (testExtensionElements == true) { + // A strict comparison is required + assertTrue(s1.equals(s2)); + } else { + // Compare for non-extension element Id's + assertTrue(s1.startsWith(s2 + ".")); + } + } + + private IProject createProject(String name) throws CoreException { + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + final IProject newProjectHandle = root.getProject(name); + IProject project = null; + + if (!newProjectHandle.exists()) { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceDescription workspaceDesc = workspace.getDescription(); + workspaceDesc.setAutoBuilding(false); + workspace.setDescription(workspaceDesc); + IProjectDescription description = workspace.newProjectDescription(newProjectHandle.getName()); + //description.setLocation(root.getLocation()); + project = CCorePlugin.getDefault().createCProject(description, newProjectHandle, new NullProgressMonitor(), + ManagedBuilderCorePlugin.MANAGED_MAKE_PROJECT_ID); + } else { + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRunnable runnable = new IWorkspaceRunnable() { + @Override + public void run(IProgressMonitor monitor) throws CoreException { + newProjectHandle.refreshLocal(IResource.DEPTH_INFINITE, monitor); + } + }; + NullProgressMonitor monitor = new NullProgressMonitor(); + workspace.run(runnable, root, IWorkspace.AVOID_UPDATE, monitor); + project = newProjectHandle; + } + + // Open the project if we have to + if (!project.isOpen()) { + project.open(new NullProgressMonitor()); + } + + return project; + } + + /** + * Sets up the test environment for the default project + */ + private void setupDefaultProject() throws Exception { + + // The assertCorrectId() call needs to be set up + testExtensionElements = true; + // Get all the key structures of our test and do some sanity checking + // + testProject = ManagedBuildManager.getProjectType(projectID); + assertNotNull(testProject); + assertTrue(testProject.isTestProjectType()); + assertFalse(testProject.isAbstract()); + + // Get and check project configurations - only one + // + setupConfiguration(); + assertTrue(testConfig.isExtensionElement()); + } + + /** + * Sets up the test configuration from the project set + * in the test + */ + private void setupConfiguration() throws Exception { + + IConfiguration[] configs = testProject.getConfigurations(); + assertNotNull(configs); + assertEquals(configs.length, 1); + testConfig = configs[0]; + assertEquals(testConfig.getId(), configID); + assertEquals(testConfig.getName(), configName); + } + + /** + * Sets up the test environment for a project created from the + * default project + */ + private IProject setupProject() throws Exception { + + // The assertCorrectId() call needs to be set up + testExtensionElements = false; + // Create new project + IProject project = null; + try { + project = createProject(projectName); + // Now associate the builder with the project + ManagedBuildTestHelper.addManagedBuildNature(project); + IProjectDescription description = project.getDescription(); + // Make sure it has a managed nature + if (description != null) { + assertTrue(description.hasNature(ManagedCProjectNature.MNG_NATURE_ID)); + } + + } catch (CoreException e) { + fail("Test failed on project creation: " + e.getLocalizedMessage()); + } + // Find the base project type definition + IProjectType projType = ManagedBuildManager.getProjectType(projectID); + assertNotNull(projType); + // Create a managed project + IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType); + assertEquals(newProject.getName(), projType.getName()); + assertFalse(newProject.equals(projType)); + ManagedBuildManager.setNewProjectVersion(project); + // Set up the environment + testProject = newProject.getProjectType(); + IConfiguration config = testProject.getConfiguration(configID); + testConfig = newProject.createConfiguration(config, configID + ".12345678"); + + return project; + } + + /** + * Sets up the test environment and does some initial checking. + * Do not do this in the constructor, as it is part of the test. + */ + private void setupTestEnvironment() throws Exception { + + int i; + + // Test ID's + // + // String configID = "test30_sto.dummy.config"; + // String configName = "Configuration for test30_sto"; + String toolChainID = "test30_sto.dummy.toolchain"; + String toolChainName = "Toolchain for test30_sto"; + // Toolchain Info + int numTools = 4; + String toolIDs = "test30_sto.dummy.tool."; + int firstToolID = 1; + // Top level option categories and groups + // int numTopCategories = 3; + String topCategoryIDs = "test30_sto.dummy.category."; + int firstTopCategoryID = 5; + + // Sizes of some arrays + int sizeCategoryTop = 0; + int sizeOptionTop = 0; + int sizeTools = 0; + + // Fetch toolchain + // + testToolChain = testConfig.getToolChain(); + assertNotNull(testToolChain); + assertEquals(testToolChain.getName(), toolChainName); + assertCorrectId(testToolChain.getId(), toolChainID); + + // Fetch and check tools list + // + testTools = testToolChain.getTools(); + assertNotNull(testTools); + assertEquals(testTools.length, numTools); + int toolNo = firstToolID; + sizeTools = numTools; + for (i = 0; i < sizeTools; i++) { + assertCorrectId(testTools[i].getId(), toolIDs + toolNo); + toolNo++; + } + + // Fetch and check top level option categories and options + // + testCategoryTop = testToolChain.getChildCategories(); + testOptionTop = testToolChain.getOptions(); + + if (testCategoryTop != null) { + int categoryNo = firstTopCategoryID; + sizeCategoryTop = testCategoryTop.length; + for (i = 0; i < sizeCategoryTop; i++, categoryNo++) { + String ID = testCategoryTop[i].getId(); + // Categories are always extension elements, so check + // for an identical match + assertEquals(ID, topCategoryIDs + categoryNo); + } + } + if (testOptionTop != null) { + sizeOptionTop = testOptionTop.length; + } + + // Fetch and check 2nd level level option categories and options + // + testCategory = new Object[testTools.length + sizeCategoryTop][]; + testOption = new Object[testTools.length + sizeOptionTop][]; + for (i = 0; i < sizeTools; i++) { + testCategory[i] = testTools[i].getChildCategories(); + testOption[i] = testTools[i].getOptions(); + // Make the arrays safe in case we have null references + if (testCategory[i] == null) { + testCategory[i] = new Object[0]; + } + if (testOption[i] == null) { + testOption[i] = new Object[0]; + } + } + // Add top level categories and options to test arrays + // + for (i = 0; i < sizeCategoryTop; i++) { + testCategory[sizeTools + i] = new Object[1]; + testCategory[sizeTools + i][0] = testCategoryTop[i]; + } + for (i = 0; i < sizeOptionTop; i++) { + testOption[sizeTools + i] = new Object[1]; + testOption[sizeTools + i][0] = testOptionTop[i]; + } + } + + /** + * Check, whether icon paths in tool1 - tool3 have been created. + * Check, whether icon paths in category 2.1 - 3.1 have been created + */ + public void testIcons() throws Exception { + + // Set up the environment + if (testIsSetup == false) { + setupDefaultProject(); + setupTestEnvironment(); + } + + // Get path's of icons to compare against + CTestPlugin me = CTestPlugin.getDefault(); + URL icon1 = Platform.asLocalURL(me.find(new Path("icons/one.gif"), null)); + URL icon2 = Platform.asLocalURL(me.find(new Path("icons/two.gif"), null)); + + // Check the icons on tools + assertToolIcon(testTools[0], icon1); + assertToolIcon(testTools[1], null); + assertToolIcon(testTools[2], icon2); + + // Check the top level and 2nd level categories + int i; + for (i = 0; i < testCategory.length; i++) { + + int j; + for (j = 0; j < testCategory[i].length; j++) { + URL url = ((IOptionCategory) testCategory[i][j]).getIconPath(); + + switch (iconComparator.Compare(i + 1, j + 1)) { + case IconComparator.None: + assertEquals(url, null); + break; + case IconComparator.One: + assertEquals(url, icon1); + break; + case IconComparator.Two: + assertEquals(url, icon2); + break; + } + } + } + } + + private void assertToolIcon(ITool tool, URL url) { + assertTrue(tool instanceof IOptionCategory); + IOptionCategory toolCategory = (IOptionCategory) tool; + assertEquals(toolCategory.getIconPath(), url); + } + + /** + * Test whether option objects have value handlers as expected + */ + public void testValueHandlers() throws Exception { + + // Set up the environment + if (testIsSetup == false) { + setupDefaultProject(); + setupTestEnvironment(); + } + + int i; + for (i = 0; i < testOption.length; i++) { + + int j; + for (j = 0; j < testOption[i].length; j++) { + IOption option = (IOption) testOption[i][j]; + IManagedOptionValueHandler handler = option.getValueHandler(); + String handlerExtraArg = option.getValueHandlerExtraArgument(); + + switch (valueHandlerComparator.Compare(i + 1, j + 1)) { + case ValueHandlerComparator.MBS: + assertEquals(ManagedOptionValueHandler.getManagedOptionValueHandler(), handler); + break; + case ValueHandlerComparator.TEST: + assertTrue(handler instanceof TestValueHandler); + assertEquals(valueHandlerComparator.getArg(), handlerExtraArg); + break; + } + } + } + } + + /** + * Test whether OptionCatgeory.getOptions(IConfiguration) works as expected + */ + public void testOptions() throws Exception { + + // Set up the environment + if (testIsSetup == false) { + setupDefaultProject(); + setupTestEnvironment(); + } + // Go over all option Categories + int i; + int j; + Object[][] results; + for (i = 0; i < testCategory.length; i++) { + for (j = 0; j < testCategory[i].length; j++) { + results = ((IOptionCategory) testCategory[i][j]).getOptions(testConfig); + // Go over results and check the following: + // A) results[k][0] must be the parent tool or toolChain + // B) results[k][1] must be in testOption[i] + for (int k = 0; k < results[0].length; k++) { + if (results[k][0] == null) { + assertNull(results[k][1]); + break; + } + // A) results[k][0] must be the parent tool or toolChain + switch (i) { + case 0: + case 1: + case 2: + case 3: + // Tool + assertTrue(results[k][0] instanceof ITool); + assertEquals(results[k][0], testTools[i]); + break; + default: + // ToolChain + assertTrue(results[k][0] instanceof IToolChain); + assertEquals(results[k][0], testToolChain); + break; + } + // B) results[k][1] must be in testOption[i] + // and its parent must be testCategory[i][j] + boolean found = false; + for (int l = 0; l < testOption[i].length; l++) { + if (testOption[i][l] == results[k][1]) { + found = true; + break; + } + } + assertTrue(found); + assertEquals(((IOption) results[k][1]).getCategory(), testCategory[i][j]); + } + } + } + } + + /** + * Test whether all the other tests work as expected for + * non-extension configurations. + */ + public void testConfiguration() throws Exception { + + // Set up the environment + IProject project = setupProject(); + try { + setupTestEnvironment(); + // Rerun the other tests, without setting the test up again + testIsSetup = true; + testIcons(); + testValueHandlers(); + testOptions(); + } finally { + ResourceHelper.cleanUp(getName()); + project.delete(true, new NullProgressMonitor()); + } + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTestSuite.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTestSuite.java new file mode 100644 index 00000000000..87fc4cfe990 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTestSuite.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2010, 2012 Andrew Gvozdev and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.managedbuilder.language.settings.providers.tests; + +import junit.framework.TestSuite; + +/** + * Test suite to test language settings providers defined in cdt.managedbuilder.core. + */ +public class AllLanguageSettingsProvidersMBSTestSuite extends TestSuite { + + public static TestSuite suite() { + return new AllLanguageSettingsProvidersMBSTestSuite(); + } + + public AllLanguageSettingsProvidersMBSTestSuite() { + super(AllLanguageSettingsProvidersMBSTestSuite.class.getName()); + + addTestSuite(LanguageSettingsProvidersMBSTest.class); + addTestSuite(GCCBuildCommandParserTest.class); + addTestSuite(BuiltinSpecsDetectorTest.class); + addTestSuite(GCCBuiltinSpecsDetectorTest.class); + addTestSuite(CompilationDatabaseParserTest.class); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTests.java deleted file mode 100644 index e638ee210a1..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/AllLanguageSettingsProvidersMBSTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2010, 2012 Andrew Gvozdev and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Andrew Gvozdev - initial API and implementation - *******************************************************************************/ - -package org.eclipse.cdt.managedbuilder.language.settings.providers.tests; - -import junit.framework.TestSuite; - -/** - * Test suite to test language settings providers defined in cdt.managedbuilder.core. - */ -public class AllLanguageSettingsProvidersMBSTests extends TestSuite { - - public static TestSuite suite() { - return new AllLanguageSettingsProvidersMBSTests(); - } - - public AllLanguageSettingsProvidersMBSTests() { - super(AllLanguageSettingsProvidersMBSTests.class.getName()); - - addTestSuite(LanguageSettingsProvidersMBSTest.class); - addTestSuite(GCCBuildCommandParserTest.class); - addTestSuite(BuiltinSpecsDetectorTest.class); - addTestSuite(GCCBuiltinSpecsDetectorTest.class); - addTestSuite(CompilationDatabaseParserTest.class); - } -} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTestSuite.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTestSuite.java new file mode 100644 index 00000000000..ece48e30e79 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTestSuite.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright (c) 2007, 2009 2008 Symbian Software Limited and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Bala Torati (Symbian) - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.templateengine.tests; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * This is a TestSuite, the TestCases created to test Template engine are + * added to test-suite. The test suite will execute all the test cases added + * to the Suite. + * + * @since 4.0 + */ +public class AllTemplateEngineTestSuite extends TestSuite { + + public static void main(String[] args) { + junit.textui.TestRunner.run(AllTemplateEngineTestSuite.suite()); + } + + /** + * Since the TemplateEngine consists of UI(Wizard). + * A TestWizard is created to which the dynamically generated + * UIPages are added. The Wizard is launched from here. + * The TestCases created to test the TemplateEngine is initialized here. + * @return + * + * @since 4.0 + */ + public static Test suite() { + TestSuite suite = new TestSuite("Template engine tests"); //$NON-NLS-1$ + //$JUnit-BEGIN$ + + suite.addTestSuite(TestProcesses.class); + + //$JUnit-END$ + return suite; + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTests.java deleted file mode 100644 index ba5313791b7..00000000000 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/templateengine/tests/AllTemplateEngineTests.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 2008 Symbian Software Limited and others. - * - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Bala Torati (Symbian) - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.managedbuilder.templateengine.tests; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * This is a TestSuite, the TestCases created to test Template engine are - * added to test-suite. The test suite will execute all the test cases added - * to the Suite. - * - * @since 4.0 - */ -public class AllTemplateEngineTests extends TestSuite { - - public static void main(String[] args) { - junit.textui.TestRunner.run(AllTemplateEngineTests.suite()); - } - - /** - * Since the TemplateEngine consists of UI(Wizard). - * A TestWizard is created to which the dynamically generated - * UIPages are added. The Wizard is launched from here. - * The TestCases created to test the TemplateEngine is initialized here. - * @return - * - * @since 4.0 - */ - public static Test suite() { - TestSuite suite = new TestSuite("Template engine tests"); //$NON-NLS-1$ - //$JUnit-BEGIN$ - - suite.addTestSuite(TestProcesses.class); - - //$JUnit-END$ - return suite; - } -} -- cgit v1.2.3