1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Add test of new APIs for Autotools Cfg options.

Change-Id: I113e76ea076ac66b1006ddf10d6d60c10a53d584
Reviewed-on: https://git.eclipse.org/r/6944
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
IP-Clean: Jeff Johnston <jjohnstn@redhat.com>
Tested-by: Jeff Johnston <jjohnstn@redhat.com>
This commit is contained in:
Jeff Johnston 2012-07-23 15:55:20 -04:00
parent 4a09199110
commit 9742fded92
2 changed files with 85 additions and 0 deletions

View file

@ -1,3 +1,7 @@
2012-07-23 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/tests/UpdateConfigureTest.java: New test.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/tests/ProjectTools.java

View file

@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2008, 2012 Red Hat Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat Incorporated - initial API and implementation
* Marc-Andre Laperle - Fix failing test on Windows
*******************************************************************************/
package org.eclipse.cdt.autotools.tests;
import java.util.Map;
import junit.framework.TestCase;
import org.eclipse.cdt.autotools.core.AutotoolsOptionConstants;
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
import org.eclipse.cdt.autotools.core.IAutotoolsOption;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
// This test verifies an autogen.sh project that builds configure, but
// does not run it.
public class UpdateConfigureTest extends TestCase {
private IProject testProject;
/*
* @see TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
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 getting and updating configuration options for an Autotools Project. The top-level
* contains autogen.sh which will build configure, but not run it.
* @throws Exception
*/
public void testGetConfigureOptions() throws Exception {
Path p = new Path("zip/project2.zip");
ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
ProjectTools.setConfigDir(testProject, "src");
ProjectTools.markExecutable(testProject, "src/autogen.sh");
assertTrue(ProjectTools.build());
ICConfigurationDescription cfgDes = CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration();
IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
assertTrue(cfg.getName().equals("Build [GNU]"));
Map<String, IAutotoolsOption> opts = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
IAutotoolsOption configdir = opts.get(AutotoolsOptionConstants.OPT_CONFIGDIR);
assertTrue(configdir.equals("src"));
}
protected 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??
}
super.tearDown();
}
}