mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
Bug 580441: Accommodate deleted folder of source files
Eliminate ResourceException by avoiding processing a deleted source folder resource as a modified resource. Change-Id: Icfa10040d4d3c6c06b2a4c040e7b632e94dff324
This commit is contained in:
parent
96839a029d
commit
7c6bd5bdcb
4 changed files with 77 additions and 4 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core.tests; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core.tests; singleton:=true
|
||||||
Bundle-Version: 8.2.200.qualifier
|
Bundle-Version: 8.2.300.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin
|
Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2011, 2022 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 - Bug 303953 test
|
||||||
|
* John Dallaway - Initial implementation (derived from bug 303953 test)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.managedbuilder.core.regressions;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
|
||||||
|
import org.eclipse.core.resources.IBuildConfiguration;
|
||||||
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
|
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.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that removal of a directory containing source file(s) is
|
||||||
|
* processed correctly by the default GnuMakefileGenerator.
|
||||||
|
*/
|
||||||
|
public class Bug_580441Test extends AbstractBuilderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBuildAfterPopulatedSourceFolderDelete() throws CoreException {
|
||||||
|
setWorkspace("regressions");
|
||||||
|
final IProject app = loadProject("helloworldC");
|
||||||
|
|
||||||
|
// Create additional source file at src/test/test.c
|
||||||
|
final IFolder testFolder = app.getFolder("src/test");
|
||||||
|
testFolder.create(false, false, null);
|
||||||
|
testFolder.getFile("test.c").create(new ByteArrayInputStream("int test;".getBytes()), false, null);
|
||||||
|
|
||||||
|
// Build debug configuration
|
||||||
|
setActiveConfigurationByName(app, "Debug");
|
||||||
|
buildConfig(app.getActiveBuildConfig());
|
||||||
|
assertTrue(app.getFile("Debug/src/test/test.o").exists(), "test.o not created");
|
||||||
|
|
||||||
|
// Delete folder containing test.c and build again
|
||||||
|
testFolder.delete(false, null);
|
||||||
|
buildConfig(app.getActiveBuildConfig());
|
||||||
|
assertFalse(app.getFolder("Debug/src/test").exists(), "test folder not deleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildConfig(IBuildConfiguration config) throws CoreException {
|
||||||
|
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
|
ResourcesPlugin.getWorkspace().build(new IBuildConfiguration[] { config },
|
||||||
|
IncrementalProjectBuilder.INCREMENTAL_BUILD, true, monitor);
|
||||||
|
}
|
||||||
|
}, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: %pluginName
|
Bundle-Name: %pluginName
|
||||||
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true
|
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true
|
||||||
Bundle-Version: 9.4.0.qualifier
|
Bundle-Version: 9.4.100.qualifier
|
||||||
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
|
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
|
||||||
Bundle-Vendor: %providerName
|
Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2016 IBM Corporation and others.
|
* Copyright (c) 2003, 2022 IBM Corporation and others.
|
||||||
*
|
*
|
||||||
* This program and the accompanying materials
|
* This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License 2.0
|
* are made available under the terms of the Eclipse Public License 2.0
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
* Marc-Andre Laperle
|
* Marc-Andre Laperle
|
||||||
* Liviu Ionescu - [322168]
|
* Liviu Ionescu - [322168]
|
||||||
* Dorothea Pilz-Roeder (Advantest Europe GmbH) - [180451]
|
* Dorothea Pilz-Roeder (Advantest Europe GmbH) - [180451]
|
||||||
|
* John Dallaway - [580441] fix processing on source folder deletion
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.managedbuilder.makegen.gnu2;
|
package org.eclipse.cdt.managedbuilder.makegen.gnu2;
|
||||||
|
|
||||||
|
@ -192,7 +193,9 @@ public class GnuMakefileGenerator implements IManagedBuilderMakefileGenerator2 {
|
||||||
// This is a source file so just add its container
|
// This is a source file so just add its container
|
||||||
if (fo == null || fo.buildsFileType(ext)) {
|
if (fo == null || fo.buildsFileType(ext)) {
|
||||||
generator.appendDeletedFile(resource);
|
generator.appendDeletedFile(resource);
|
||||||
generator.appendModifiedSubdirectory(resource);
|
if (resource.getParent().exists()) {
|
||||||
|
generator.appendModifiedSubdirectory(resource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue