1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 377295 - Build fails if project name contains characters [, ]

Change-Id: I9f116f524bb30e064e1cdbb3588c494a450d765e
Reviewed-on: https://git.eclipse.org/r/5636
Reviewed-by: Andrew Gvozdev <angvoz.dev@gmail.com>
IP-Clean: Andrew Gvozdev <angvoz.dev@gmail.com>
Tested-by: Andrew Gvozdev <angvoz.dev@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2012-04-23 02:00:18 -04:00 committed by Andrew Gvozdev
parent dd48abd247
commit eb6522badf
3 changed files with 34 additions and 30 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Broadcom Corporation and others.
* Copyright (c) 2011, 2012 Broadcom Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -71,11 +71,13 @@ public abstract class AbstractBuilderTest extends TestCase {
Job.getJobManager().cancel(CCorePlugin.getPDOMManager());
Job.getJobManager().join(CCorePlugin.getPDOMManager(), null);
// Clean-up any projects we were using
for (IProject project : projects) {
project.delete(true, null);
if (projects != null) {
// Clean-up any projects we were using
for (IProject project : projects) {
project.delete(true, null);
}
projects.clear();
}
projects.clear();
}
/**

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 QNX Software Systems and others.
* Copyright (c) 2011, 2012 QNX Software Systems 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
@ -11,11 +11,9 @@
package org.eclipse.cdt.managedbuilder.core.tests;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.CoreModel;
@ -28,6 +26,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.internal.core.FolderInfo;
import org.eclipse.cdt.managedbuilder.tcmodification.IConfigurationModification;
import org.eclipse.cdt.managedbuilder.tcmodification.IToolChainModificationManager;
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
@ -39,11 +38,10 @@ import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IncrementalProjectBuilder;
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.OperationCanceledException;
public class ManagedBuildDependencyLibsTests extends TestCase {
public class ManagedBuildDependencyLibsTests extends AbstractBuilderTest {
private static final String PROJ_PATH = "depLibsProjects";
private static final String MESSAGE_TAIL = " (see .log file for more details).";
@ -60,12 +58,12 @@ public class ManagedBuildDependencyLibsTests extends TestCase {
suite.addTest(new ManagedBuildDependencyLibsTests("testDepLibs"));
suite.addTest(new ManagedBuildDependencyLibsTests("testDepUObjs"));
suite.addTest(new ManagedBuildDependencyLibsTests("testGetArtifactTimeStampEscapeURI_bug377295"));
return suite;
}
private void buildProject(IProject curProject) {
IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(curProject);
try {
IProject[] referencedProjects = curProject.getReferencedProjects();
for(int i = 0; i < referencedProjects.length; ++i)
@ -117,20 +115,6 @@ public class ManagedBuildDependencyLibsTests extends TestCase {
ManagedBuildTestHelper.removeProject(fTlib.getName());
ManagedBuildTestHelper.removeProject(fTobjs.getName());
}
private void deleteFiles(IFolder dir, String pattern, IProgressMonitor monitor) {
List<IFile> files = new ArrayList<IFile>();
findFiles(dir, pattern, files);
for(Iterator<IFile> i = files.iterator(); i.hasNext(); ) {
IFile file = i.next();
try {
file.delete(true, monitor);
} catch (CoreException e) {
e.printStackTrace();
fail("Error deleting file " + file.getFullPath().toString() + '.' + MESSAGE_TAIL);
}
}
}
private void findFiles(IResource dir, String pattern, List<IFile> files) {
IResource resource = null;
@ -146,7 +130,7 @@ public class ManagedBuildDependencyLibsTests extends TestCase {
for(int i = 0; i < members.length; ++i) {
resource = members[i];
if(resource.getType() == IResource.FOLDER)
findFiles((IFolder)resource, pattern, files);
findFiles(resource, pattern, files);
else {
if(resource.getName().matches(pattern))
files.add((IFile)resource);
@ -291,4 +275,20 @@ public class ManagedBuildDependencyLibsTests extends TestCase {
fail("Error. This time it should build application.");
}
}
// Tests that the URI used to get the time stamp of the artifact is escaped correctly
// See AdditionalInput.getArtifactTimeStamp(IToolChain toolChain)
public void testGetArtifactTimeStampEscapeURI_bug377295() throws CoreException {
setWorkspace("regressions");
final IProject project = loadProject("helloworldC");
IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
for (IConfiguration configuration : configs) {
configuration.setArtifactName("test [377295]");
}
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
// This will trigger AdditionalInput.getArtifactTimeStamp to get called, no IllegalArgumentException should be thrown
project.build(IncrementalProjectBuilder.FULL_BUILD, null);
}
}

View file

@ -1,13 +1,14 @@
/*******************************************************************************
* Copyright (c) 2005, 2011 Intel Corporation and others.
* Copyright (c) 2005, 2012 Intel Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
* IBM Corporation
* Intel Corporation - Initial API and implementation
* IBM Corporation
* Marc-Andre Laperle
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
@ -40,6 +41,7 @@ import org.eclipse.cdt.managedbuilder.internal.macros.IMacroContextInfo;
import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
import org.eclipse.cdt.utils.cdtvariables.SupplierBasedCdtVariableSubstitutor;
import org.eclipse.core.filesystem.EFS;
@ -380,7 +382,7 @@ public class AdditionalInput implements IAdditionalInput {
} catch (BuildMacroException e) {
}
URI buildArtifactURI = buildLocationURI.resolve(artifactName);
URI buildArtifactURI = EFSExtensionManager.getDefault().append(buildLocationURI, artifactName);
try {
IFileStore artifact = EFS.getStore(buildArtifactURI);