Closed mads-hartmann closed 11 years ago
Started jenkins job scala-search-3.0.x-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/37/
Started jenkins job scala-search-master-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/38/
jenkins job scala-search-master-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/38/
jenkins job scala-search-3.0.x-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/37/
Hm, I don't get these errors locally
Seems like the validator is using the wrong commit. Any ideas @jsuereth @dotta ?
@mads379 Not sure why it happens, but let's give it another try.
PLS REBUILD ALL
Started jenkins job scala-search-master-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/40/
Started jenkins job scala-search-3.0.x-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/39/
jenkins job scala-search-master-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/40/
jenkins job scala-search-3.0.x-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/39/
Rebased on master. Lets see what happens.
Started jenkins job scala-search-master-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/41/
Started jenkins job scala-search-3.0.x-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/40/
jenkins job scala-search-3.0.x-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/40/
jenkins job scala-search-master-2.10-pr-validator: Failed - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/41/
@dotta Okay, either the the validator is broken or something is wrong with the PR. checked out scala-ide/master and cherry picked this commit. mvn clean install
runs smoothly :)
@mads379 I just checked out your PR, and I can certify the reported failure is real :) I am a bit puzzled on why you can't reproduce it, as it doesn't look like a (bad) timing kind of failure.
@dotta How did you re-produce it?
@mads379 just a plain mvn clean install
. Maybe try mvn clean install -Dtycho.localArtifacts=ignore
...
@dotta Oh, it does indeed fail. I was certain I tried earlier. Oh well, I'll fix it :)
No, I get another error.
Failed tests:
corrupIndexExceptionWhenIndexing(org.scala.tools.eclipse.search.jobs.ProjectIndexJobTest):
reactsToCloseEvents(org.scala.tools.eclipse.search.ProjectChangeObserverTest): It should've reacted to the close event expected:<true> but was:<false>
Not sure what to say, the failures I get match exactly the ones reported by the kitten.
Alright, I'll try another computer to see what happens. Thanks for trying it out :)
Did you notice that the IndexJobManagerTest
folder inside test-workspace
is empty? Did you forget to push some file?
That was indeed the problem :) I had the folder structure locally but because the folders were empty they were not committed. I've added a dummy file now which seems to fix the problem. The ProjectChangeObserverTest
still fails every once in a while. I'll look at it tomorrow.
Started jenkins job scala-search-3.0.x-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/42/
Started jenkins job scala-search-master-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/43/
jenkins job scala-search-3.0.x-2.10-pr-validator: Success - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/42/
jenkins job scala-search-master-2.10-pr-validator: Success - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/43/
Mads, awesome PR! The code is really neat and well tested, great job!
@dotta While refactoring the code to use ScalaProject
everywhere I've encountered a problem. In the ProjectChangeObserver
we get passed an IProject
when projects are opened or closed. When a project is closed we can't test if it as a Scala project because ScalaPlugin.isScalaProject
requires it to be open. So instead I think that ProjectChangeObserver
needs to deal with IProject
s and we just have to check if a project is a Scala project in IndexJobManager
before starting a ProjectIndexJob
@dotta @dragos I believe that I've found a visibility bug. Not sure if it's in the IDE code of Eclipse. Consider the following example:
@Test
def startsIndexingJobWhenProjectIsCreated() {
val name = "IndexJobManagerTest-ToBeCreated"
val latch = new CountDownLatch(1)
ProjectChangeObserver(onOpen = (p: IProject) => {
// This runs in another thread.
if (p.getName == name) {
assertTrue(ScalaPlugin.plugin.isScalaProject(p))
latch.countDown()
}
})
// event
val p = SDTTestUtils.createProjects(name).head
assertTrue(ScalaPlugin.plugin.isScalaProject(p.underlying))
latch.await(EVENT_DELAY, java.util.concurrent.TimeUnit.SECONDS)
// reaction
assertTrue(config.isIndexing(project.underlying))
}
The assertion in the onOpen
function fails whereas the one on just before latch.await
succeeds. Any idea how to fix this?
@mads379 Mmmm, interesting, I'll have a look.
@mads379 Actually, can you add the following additional assertion assertTrue(p.isOpen)
right before assertTrue(ScalaPlugin.plugin.isScalaProject(p))
and see if it fails.
@dotta That one succeeds, so the project is open :)
@dotta It seems to be the hasNature
on IProject
that's causing it. It succeeds with hasNature(ScalaPlugin.plugin.natureId)
on the test thread but not on the ProjectChangeObserver
thread. Perhaps we simply have to force the check on isScalaProject
to be executed in the main thread? I'm pretty sure Eclipse provides some functionality for that
@dotta Yep, the problem is caused by IProject
. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=329143 doesn't mention a fix though :/
I thought that maybe it was just the instance of IProject that was propagated through the events that wasn't updated so I tried
val root = ResourcesPlugin.getWorkspace.getRoot
val p = root.getProject(project.getName)
ScalaPlugin.plugin.isScalaProject(p)
Inside of IndexJobManager but this still returns false when though the assertion is true in the test where the projects are created.
@dotta I might have found the problem. The way projects are created is that we use
project = ...
project.create(null)
project.open(null)
val description = project.getDescription()
description.setNatureIds(Array(ScalaPlugin.plugin.natureId, JavaCore.NATURE_ID))
project.setDescription(description, null)
setDescription
will fire it's own events (according to the docs), so by the time we get the events from the create/open
calls the project isn't a in fact a Scala project yet as those events haven't propagated through the system yet. I'll see if I can find an elegant way to handle this.
Alright, so I just pushed 010bdbc which fixes two things
@dotta pointed out that when he checked out the branch and ran the tests they never terminated. This happened because I did some refactoring and forgot to update a variable :) I updated the tests so they all used EVENT_DELAY to define how long to (max) wait for the latches. That number was previously 10000 because it has been used to define the time in milliseconds before, but with latches we define it in seconds so failing tests would appear to be non-terminating as they were waiting 10000 seconds for the latches ;)
Another issue I found was the test for indexing newly created scala projects failed. This test started failing because I fixed the code such that it only started indexing jobs for Scala projects. Now, the problem was that newly created Scala projects weren't considered Scala projects in the thread running the ProjectChangeObserver, even though ScalaPlugin.plugin.isScalaProject
would succeed on the thread that created the project. The reason for this turned out to be quite simple.
The ProjectChangeObserver listened to OPEN
events on projects. But they way we create Scala projects in Eclipse require three separate method invocations
project.create(null)
project.open(null)
project.setDescription(description, null) // marks it as a Scala project
So when we reacted to the OPEN
event the project wasn't considered a Scala project yet by Eclipse, as the event generated by setDescription hadn't propagated through the system yet.
Started jenkins job scala-search-3.0.x-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/43/
Started jenkins job scala-search-master-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/44/
jenkins job scala-search-3.0.x-2.10-pr-validator: Success - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/43/
jenkins job scala-search-master-2.10-pr-validator: Success - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/44/
@dotta Pushed a commit that adds life-cycle managing. We use stackable traits to do it, inspired by Daniel Spiewak's talk on the cake pattern (http://nescala.org/, around 26:45). Have a look at Lifecycle.scala, IndexJobManager.scala, SearchPlugin.scala to see how it is used right now
Started jenkins job scala-search-3.0.x-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/44/
Started jenkins job scala-search-master-2.10-pr-validator at https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-master-2.10-pr-validator/45/
jenkins job scala-search-3.0.x-2.10-pr-validator: Success - https://jenkins.scala-ide.org:8496/jenkins/job/scala-search-3.0.x-2.10-pr-validator/44/
The life-cycle of the
ProjectIndexJob
s is now managed byIndexJobManager
. It listens toopen/close/delete
events on the projects in the workspace usingProjectChangeObserver
.Tests have been aded for both the
ProjectChangeObserver
andIndexJobManager
I now manage dependencies between various components using the cake pattern.
Fixes #1001609 #1001610