Skip to content

Commit

Permalink
Add a test demonstrating compilation/execution sequence
Browse files Browse the repository at this point in the history
Test case for #10883 which revealed problems with visualizations in
issue #10897.
  • Loading branch information
hubertp authored and 4e6 committed Sep 5, 2024
1 parent 96adbea commit fec5c58
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.enso.logger.masking.MaskedPath
import org.enso.polyglot.runtime.Runtime.Api

import java.util.logging.Level

import scala.concurrent.ExecutionContext

/** A command that performs edition of a file.
Expand Down Expand Up @@ -53,17 +52,21 @@ class EditFileCmd(request: Api.EditFileNotification)
if (request.execute) {
ctx.jobControlPlane.abortAllJobs()
ctx.jobProcessor
.run(new EnsureCompiledJob(Seq(request.path)))
.run(compileJob())
.foreach(_ => executeJobs.foreach(ctx.jobProcessor.run))
} else if (request.idMap.isDefined) {
ctx.jobProcessor.run(new EnsureCompiledJob(Seq(request.path)))
ctx.jobProcessor.run(compileJob())
}
}
)
)
}

private def executeJobs(implicit
protected def compileJob(): EnsureCompiledJob = {
new EnsureCompiledJob(Seq(request.path))
}

protected def executeJobs(implicit
ctx: RuntimeContext
): Iterable[ExecuteJob] = {
ctx.contextManager.getAllContexts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import scala.jdk.OptionConverters._
* @param files a files to compile
* @param isCancellable a flag indicating if the job is cancellable
*/
final class EnsureCompiledJob(
class EnsureCompiledJob(
protected val files: Iterable[File],
isCancellable: Boolean = true
) extends Job[EnsureCompiledJob.CompilationStatus](
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.enso.interpreter.instrument.command

import org.enso.interpreter.instrument.execution.RuntimeContext
import org.enso.interpreter.instrument.job.{
EnsureCompiledJob,
SlowEnsureCompiledJob
}
import org.enso.polyglot.runtime.Runtime.Api

import scala.concurrent.ExecutionContext
Expand All @@ -23,4 +27,8 @@ class SlowEditFileCmd(request: Api.EditFileNotification, delay: Boolean)
}
super.executeSynchronously(ctx, ec)
}

override protected def compileJob(): EnsureCompiledJob = {
new SlowEnsureCompiledJob(Seq(request.path))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.enso.interpreter.instrument.job

import org.enso.interpreter.instrument.execution.RuntimeContext
import org.enso.interpreter.instrument.job.EnsureCompiledJob.CompilationStatus

import java.io.File

class SlowEnsureCompiledJob(
files: Iterable[File],
isCancellable: Boolean = true
) extends EnsureCompiledJob(files, isCancellable) {

override def run(implicit ctx: RuntimeContext): CompilationStatus = {
Thread.sleep(1000)
super.run(ctx)
}

}

0 comments on commit fec5c58

Please sign in to comment.