Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 238867 Details for
Bug 329657
An active build blocks user task (like save)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch proposal
patch329657.txt (text/plain), 7.67 KB, created by
Szymon Ptaszkiewicz
on 2014-01-10 10:27:15 EST
(
hide
)
Description:
Patch proposal
Filename:
MIME Type:
Creator:
Szymon Ptaszkiewicz
Created:
2014-01-10 10:27:15 EST
Size:
7.67 KB
patch
obsolete
>diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java >index 0220467..0e5a726 100644 >--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java >+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2010 IBM Corporation and others. >+ * Copyright (c) 2003, 2014 IBM 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 >@@ -159,7 +159,7 @@ > monitor.done(); > } > } >- >+ > /** > * Forces an autobuild to occur, even if nothing has changed since the last > * build. This is used to force a build after a clean. >@@ -255,6 +255,8 @@ > */ > private synchronized void setInterrupted(boolean value) { > interrupted = value; >+ if (value) >+ cancel(); > } > > /** >diff --git a/tests/org.eclipse.core.tests.resources/plugin.xml b/tests/org.eclipse.core.tests.resources/plugin.xml >index f27c228..05a10e2 100644 >--- a/tests/org.eclipse.core.tests.resources/plugin.xml >+++ b/tests/org.eclipse.core.tests.resources/plugin.xml >@@ -64,6 +64,11 @@ > <run class="org.eclipse.core.tests.internal.builders.ClearMarkersBuilder"/> > </builder> > </extension> >+ <extension point="org.eclipse.core.resources.builders" id="builderwithcallback" name="Builder With Callback"> >+ <builder> >+ <run class="org.eclipse.core.tests.internal.builders.BuilderWithCallback"/> >+ </builder> >+ </extension> > <extension point="org.eclipse.core.resources.builders" id="emptydeltabuilder" name="Empty Delta Builder"> > <builder callOnEmptyDelta="true"> > <run class="org.eclipse.core.tests.internal.builders.EmptyDeltaBuilder"/> >diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java >index f4fd2b9..8b91e20 100644 >--- a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java >+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderTest.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 IBM Corporation and others. >+ * Copyright (c) 2000, 2014 IBM 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 >@@ -21,6 +21,7 @@ > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.core.tests.harness.TestBarrier; > import org.eclipse.core.tests.harness.TestJob; >+import org.eclipse.core.tests.internal.builders.BuilderWithCallback.IBuildCallback; > > /** > * This class tests public API related to building and to build specifications. >@@ -1117,6 +1118,69 @@ > } > } > >+ public void testInterruptLongAutobuild() throws CoreException, InterruptedException { >+ setAutoBuilding(true); >+ >+ IProject project = getWorkspace().getRoot().getProject(getUniqueString()); >+ final IFile file = project.getFile("file.txt"); >+ ensureExistsInWorkspace(new IResource[] {project, file}, true); >+ addBuilder(project, BuilderWithCallback.BUILDER_NAME); >+ >+ waitForBuild(); >+ >+ final int[] status = new int[] {0}; >+ // use build callback to simulate user interaction with build >+ BuilderWithCallback.getInstance().setBuildCallback(new IBuildCallback() { >+ public IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) { >+ // let others know that build is running >+ status[0] = TestBarrier.STATUS_RUNNING; >+ // build will finish if monitor will be cancelled or the test already ended >+ while (!monitor.isCanceled() && status[0] != TestBarrier.STATUS_BLOCKED) { >+ try { >+ Thread.sleep(100); >+ } catch (InterruptedException e) { >+ // ignore >+ } >+ } >+ // let others know that build is finished >+ status[0] = TestBarrier.STATUS_DONE; >+ return null; >+ } >+ }); >+ >+ // setContents will trigger a build >+ file.setContents(getRandomContents(), IResource.NONE, getMonitor()); >+ // wait until build is running >+ TestBarrier.waitForStatus(status, TestBarrier.STATUS_RUNNING); >+ // setContents will trigger a build; do it in a separate job so that the main thread is not blocked >+ Job job = new Job("setContents") { >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ file.setContents(getRandomContents(), IResource.NONE, getMonitor()); >+ } catch (CoreException e) { >+ return e.getStatus(); >+ } >+ return Status.OK_STATUS; >+ } >+ }; >+ job.schedule(); >+ >+ try { >+ // wait until build is finished; this should happen if build started after >+ // the first setContents call was cancelled by the second setContents call >+ TestBarrier.waitForStatus(status, TestBarrier.STATUS_DONE); >+ } finally { >+ BuilderWithCallback.getInstance().setBuildCallback(null); >+ // unblock the builder so that the job can finish before ending the test >+ status[0] = TestBarrier.STATUS_BLOCKED; >+ job.join(); >+ assertTrue(job.getResult().isOK()); >+ } >+ >+ waitForBuild(); >+ ensureDoesNotExistInWorkspace(project); >+ } >+ > /** > * Tests the lifecycle of a builder. > */ >diff --git a/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderWithCallback.java b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderWithCallback.java >new file mode 100644 >index 0000000..3e19a02 >--- /dev/null >+++ b/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/internal/builders/BuilderWithCallback.java >@@ -0,0 +1,49 @@ >+/******************************************************************************* >+ * Copyright (c) 2014 IBM 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: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.core.tests.internal.builders; >+ >+import java.util.Map; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IncrementalProjectBuilder; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+/** >+ * Test builder that allows to override the build method using a callback interface. >+ */ >+public class BuilderWithCallback extends IncrementalProjectBuilder { >+ public interface IBuildCallback { >+ IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor); >+ } >+ >+ public static final String BUILDER_NAME = "org.eclipse.core.tests.resources.builderwithcallback"; >+ >+ private static BuilderWithCallback instance; >+ >+ public static BuilderWithCallback getInstance() { >+ return instance; >+ } >+ >+ private IBuildCallback buildCallback; >+ >+ public BuilderWithCallback() { >+ instance = this; >+ } >+ >+ protected IProject[] build(int kind, Map<String, String> args, IProgressMonitor monitor) { >+ if (buildCallback != null) >+ return buildCallback.build(kind, args, monitor); >+ return null; >+ } >+ >+ public void setBuildCallback(IBuildCallback buildCallback) { >+ this.buildCallback = buildCallback; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 329657
:
198950
| 238867 |
283869
|
289217