Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix many of the test issues in #117 #118

Merged
merged 7 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions NewAndNoteworthy/CDT-11.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ See [Bug 580873](https://bugs.eclipse.org/bugs/show_bug.cgi?id=580873).

Please see [CHANGELOG-API](CHANGELOG-API.md) for details on the breaking API changes in this release as well as future planned API changes.

## New Job Family for backgrond build settings update

When the project is modified the managed build settings needs to update settings.

While much of this update happens synchronously to the `IResourceChangeListener` calls, the final update is done with a job.
If an update needs to be tracked for completion, after making an update the `IJobManager` can be queried using this family.

e.g. a join on the job being completed:

```java
Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY, null);
```

This new job family was added to improve stability of tests to ensure background operations are complete.
It may have other uses to other API consumers as well and is therefore included here.

# Bugs Fixed in this Release

See [GitHub milestones](https://github.com/eclipse-cdt/cdt/milestone/2?closed=1) and for bugs that haven't been transitioned to GitHub please see Bugzilla report [Bugs Fixed in CDT 11.0](https://bugs.eclipse.org/bugs/buglist.cgi?bug_status=RESOLVED&bug_status=VERIFIED&bug_status=CLOSED&classification=Tools&product=CDT&query_format=advanced&resolution=FIXED&target_milestone=11.0.0).
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
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.internal.buildmodel.BuildDescription;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildIOType;
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildResource;
Expand All @@ -63,7 +64,9 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.dialogs.IOverwriteQuery;

import junit.framework.Test;
Expand Down Expand Up @@ -125,6 +128,19 @@ public static Test suite() {
return new TestSuite(BuildDescriptionModelTests.class);
}

/**
* Add the CC Nature and wait until the project settings are fully updated.
*/
private void addCCNatureAndWait(IProject project) {
try {
CCProjectNature.addCCNature(project, null);
// wait for the build setting update that is trigged by adding the CC nature finishes
Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY, null);
} catch (CoreException | OperationCanceledException | InterruptedException e1) {
throw new RuntimeException("fail to add CC nature", e1);
}
}

public void testDes_Model() {
IProject project = createProject(PREFIX + "1", "test30_2.tar");
IFile aAsm = ManagedBuildTestHelper.createFile(project, "a.asm");
Expand Down Expand Up @@ -908,12 +924,7 @@ private IProject loadProject(String name) {

public void testDes_gnu30_exe() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}

addCCNatureAndWait(project);
ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
ManagedBuildTestHelper.createFile(project, "c.cpp");
Expand Down Expand Up @@ -1020,11 +1031,7 @@ public void testDes_gnu30_exe() {

public void testDes_gnu30_exe_deps() {
IProject project = createProject(PREFIX + "gnu30_exe_deps", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c", "\n#include \"a.h\"\n#include \"d.h\"\n");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -1174,11 +1181,7 @@ public void testDes_gnu30_exe_deps() {

public void testDesTestgnu21_exe() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.testgnu21.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -1285,11 +1288,7 @@ public void testDesTestgnu21_exe() {

public void testDesRcCfg() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

IFile ac = ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -1402,11 +1401,7 @@ public void testDesRcCfg() {

public void testDesRcbs() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -1586,11 +1581,7 @@ public void testDesRcbs() {

public void testDesAddlInVarUserObjs() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -1773,11 +1764,7 @@ public void testDesAddlInVarUserObjs() {

public void testDesAddlInVar() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.bdm.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -1943,11 +1930,7 @@ public void testDesAddlInVar() {

public void testDes_gnu30_exe_objsInProj() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -2057,11 +2040,7 @@ public void testDes_gnu30_exe_objsInProj() {

public void testDesRebuildState() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down Expand Up @@ -2400,11 +2379,7 @@ public void testDesRebuildState() {
public void testDesRebuildStateWithCustomBuildStep() {
/* This test captures Bug 389536 */
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.gnu30.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

IFile testYFile = ManagedBuildTestHelper.createFile(project, "test.y");

Expand Down Expand Up @@ -2605,11 +2580,7 @@ private void doTestTool(ITool tool) {

public void testDesRebuildStateInDescription() {
IProject project = createProject(PREFIX + "1", "cdt.managedbuild.target.bdm.exe");
try {
CCProjectNature.addCCNature(project, null);
} catch (CoreException e1) {
fail("fail to add CC nature");
}
addCCNatureAndWait(project);

ManagedBuildTestHelper.createFile(project, "a.c");
ManagedBuildTestHelper.createFile(project, "b.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildPathEntryContainerInitializer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.osgi.framework.BundleContext;

/**
Expand All @@ -53,6 +55,25 @@ public class ManagedBuilderCorePlugin extends Plugin {
// The unique id for all managed make projects
public static final String MANAGED_MAKE_PROJECT_ID = ManagedBuilderCorePlugin.getUniqueIdentifier()
+ ".managedMake"; //$NON-NLS-1$

/**
* When the project is modified the managed build settings needs to update settings.
*
* While much of this update happens synchronously to the {@link IResourceChangeListener}
* calls, the final update is done with a job. If an update needs to be tracked for
* completion, after making an update the {@link IJobManager} can be queried using
* this family.
*
* e.g. a join on the job being completed:
*
* <pre>
* Job.getJobManager().join(ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY, null);
* </pre>
*
* @since 9.5
*/
public static final Object BUILD_SETTING_UPDATE_JOB_FAMILY = new Object();

// NOTE: The code below is for tracking resource renaming and deleting. This is needed to keep
// ResourceConfiguration elements up to date. It may also be needed by AdditionalInput
// elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ protected IStatus run(IProgressMonitor monitor) {
return Status.OK_STATUS;
}

@Override
public boolean belongsTo(Object family) {
return family == ManagedBuilderCorePlugin.BUILD_SETTING_UPDATE_JOB_FAMILY;
}

};

job.setRule(root);
Expand Down
Loading