Skip to content

Commit 7c6bd5b

Browse files
committed
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
1 parent 96839a0 commit 7c6bd5b

File tree

4 files changed

+77
-4
lines changed

4 files changed

+77
-4
lines changed

build/org.eclipse.cdt.managedbuilder.core.tests/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core.tests; singleton:=true
5-
Bundle-Version: 8.2.200.qualifier
5+
Bundle-Version: 8.2.300.qualifier
66
Bundle-Activator: org.eclipse.cdt.managedbuilder.testplugin.CTestPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2011, 2022 Broadcom Corporation and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Broadcom Corporation - Bug 303953 test
13+
* John Dallaway - Initial implementation (derived from bug 303953 test)
14+
*******************************************************************************/
15+
package org.eclipse.cdt.managedbuilder.core.regressions;
16+
17+
import static org.junit.jupiter.api.Assertions.assertFalse;
18+
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
20+
import java.io.ByteArrayInputStream;
21+
22+
import org.eclipse.cdt.managedbuilder.testplugin.AbstractBuilderTest;
23+
import org.eclipse.core.resources.IBuildConfiguration;
24+
import org.eclipse.core.resources.IFolder;
25+
import org.eclipse.core.resources.IProject;
26+
import org.eclipse.core.resources.IWorkspaceRunnable;
27+
import org.eclipse.core.resources.IncrementalProjectBuilder;
28+
import org.eclipse.core.resources.ResourcesPlugin;
29+
import org.eclipse.core.runtime.CoreException;
30+
import org.eclipse.core.runtime.IProgressMonitor;
31+
import org.junit.jupiter.api.Test;
32+
33+
/**
34+
* Test that removal of a directory containing source file(s) is
35+
* processed correctly by the default GnuMakefileGenerator.
36+
*/
37+
public class Bug_580441Test extends AbstractBuilderTest {
38+
39+
@Test
40+
public void testBuildAfterPopulatedSourceFolderDelete() throws CoreException {
41+
setWorkspace("regressions");
42+
final IProject app = loadProject("helloworldC");
43+
44+
// Create additional source file at src/test/test.c
45+
final IFolder testFolder = app.getFolder("src/test");
46+
testFolder.create(false, false, null);
47+
testFolder.getFile("test.c").create(new ByteArrayInputStream("int test;".getBytes()), false, null);
48+
49+
// Build debug configuration
50+
setActiveConfigurationByName(app, "Debug");
51+
buildConfig(app.getActiveBuildConfig());
52+
assertTrue(app.getFile("Debug/src/test/test.o").exists(), "test.o not created");
53+
54+
// Delete folder containing test.c and build again
55+
testFolder.delete(false, null);
56+
buildConfig(app.getActiveBuildConfig());
57+
assertFalse(app.getFolder("Debug/src/test").exists(), "test folder not deleted");
58+
}
59+
60+
private void buildConfig(IBuildConfiguration config) throws CoreException {
61+
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
62+
@Override
63+
public void run(IProgressMonitor monitor) throws CoreException {
64+
ResourcesPlugin.getWorkspace().build(new IBuildConfiguration[] { config },
65+
IncrementalProjectBuilder.INCREMENTAL_BUILD, true, monitor);
66+
}
67+
}, null);
68+
}
69+
70+
}

build/org.eclipse.cdt.managedbuilder.core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.cdt.managedbuilder.core; singleton:=true
5-
Bundle-Version: 9.4.0.qualifier
5+
Bundle-Version: 9.4.100.qualifier
66
Bundle-Activator: org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu2/GnuMakefileGenerator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2003, 2016 IBM Corporation and others.
2+
* Copyright (c) 2003, 2022 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,6 +17,7 @@
1717
* Marc-Andre Laperle
1818
* Liviu Ionescu - [322168]
1919
* Dorothea Pilz-Roeder (Advantest Europe GmbH) - [180451]
20+
* John Dallaway - [580441] fix processing on source folder deletion
2021
*******************************************************************************/
2122
package org.eclipse.cdt.managedbuilder.makegen.gnu2;
2223

@@ -192,7 +193,9 @@ public boolean visit(IResourceDelta delta) throws CoreException {
192193
// This is a source file so just add its container
193194
if (fo == null || fo.buildsFileType(ext)) {
194195
generator.appendDeletedFile(resource);
195-
generator.appendModifiedSubdirectory(resource);
196+
if (resource.getParent().exists()) {
197+
generator.appendModifiedSubdirectory(resource);
198+
}
196199
}
197200
}
198201
break;

0 commit comments

Comments
 (0)