From 382b8138e443e55fa5a5a411d93cb0f84301e9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Wa=C5=9Bko?= Date: Wed, 25 Aug 2021 21:38:38 +0200 Subject: [PATCH] Implement and test 'library/preinstall' --- .../enso/languageserver/boot/MainModule.scala | 14 +- .../libraries/EditionReferenceResolver.scala | 14 +- .../libraries/LibraryConfig.scala | 4 +- .../libraries/LibraryInstallerConfig.scala | 11 ++ .../handler/LibraryPreinstallHandler.scala | 164 ++++++++++++++---- .../json/JsonConnectionController.scala | 5 +- .../websocket/json/BaseServerTest.scala | 42 ++--- .../websocket/json/LibrariesTest.scala | 127 +++++++++----- .../org/enso/compiler/PackageRepository.scala | 2 +- .../jsonrpc/test/JsonRpcServerTestKit.scala | 3 +- .../DefaultLibraryProvider.scala | 2 +- .../ResolvingLibraryProvider.scala | 7 +- .../test/TestLocalLockManager.scala | 9 +- .../enso/testkit/WithTemporaryDirectory.scala | 2 +- 14 files changed, 277 insertions(+), 129 deletions(-) create mode 100644 engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryInstallerConfig.scala diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala b/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala index 0cd0a6c30b165..c424b91571914 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/boot/MainModule.scala @@ -1,7 +1,10 @@ package org.enso.languageserver.boot import akka.actor.ActorSystem -import org.enso.distribution.locking.ThreadSafeFileLockManager +import org.enso.distribution.locking.{ + ResourceManager, + ThreadSafeFileLockManager +} import org.enso.distribution.{DistributionManager, Environment, LanguageHome} import org.enso.editions.EditionResolver import org.enso.editions.updater.EditionManager @@ -16,6 +19,7 @@ import org.enso.languageserver.io._ import org.enso.languageserver.libraries.{ EditionReferenceResolver, LibraryConfig, + LibraryInstallerConfig, LocalLibraryManager, ProjectSettingsManager } @@ -290,6 +294,7 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) { val lockManager = new ThreadSafeFileLockManager( distributionManager.paths.locks ) + val resourceManager = new ResourceManager(lockManager) val lockManagerService = system.actorOf( LockManagerService.props(lockManager), @@ -323,7 +328,12 @@ class MainModule(serverConfig: LanguageServerConfig, logLevel: LogLevel) { editionManager = editionManager, localLibraryProvider = DefaultLocalLibraryProvider.make(libraryLocations), publishedLibraryCache = - PublishedLibraryCache.makeReadOnlyCache(libraryLocations) + PublishedLibraryCache.makeReadOnlyCache(libraryLocations), + installerConfig = LibraryInstallerConfig( + distributionManager, + resourceManager, + Some(languageHome) + ) ) val jsonRpcControllerFactory = new JsonConnectionControllerFactory( diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/EditionReferenceResolver.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/EditionReferenceResolver.scala index 778be011de37e..576106c724ab6 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/EditionReferenceResolver.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/EditionReferenceResolver.scala @@ -3,7 +3,7 @@ package org.enso.languageserver.libraries import org.enso.editions.provider.EditionProvider import org.enso.editions.{DefaultEdition, EditionResolver, Editions} import org.enso.languageserver.libraries.EditionReference.NamedEdition -import org.enso.pkg.PackageManager +import org.enso.pkg.{Config, PackageManager} import java.io.File import scala.util.Try @@ -24,14 +24,14 @@ class EditionReferenceResolver( case EditionReference.NamedEdition(editionName) => editionProvider.findEditionForName(editionName).toTry case EditionReference.CurrentProjectEdition => - Try { - projectPackage.config.edition.getOrElse { - // TODO [RW] default edition from config (#1864) - DefaultEdition.getDefaultEdition - } - } + getCurrentProjectConfig.map(_.edition.getOrElse { + // TODO [RW] default edition from config (#1864) + DefaultEdition.getDefaultEdition + }) } + def getCurrentProjectConfig: Try[Config] = Try { projectPackage.config } + /** Resolves all edition dependencies of an edition identified by * [[EditionReference]]. */ diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryConfig.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryConfig.scala index 0aad3bb4393f3..85f3574d801fa 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryConfig.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryConfig.scala @@ -12,11 +12,13 @@ import org.enso.librarymanager.published.PublishedLibraryCache * @param editionManager an instance of edition manager * @param localLibraryProvider an instance of local library provider * @param publishedLibraryCache an instance of published library cache + * @param installerConfig configuration for the library installer */ case class LibraryConfig( localLibraryManager: ActorRef, editionReferenceResolver: EditionReferenceResolver, editionManager: EditionManager, localLibraryProvider: LocalLibraryProvider, - publishedLibraryCache: PublishedLibraryCache + publishedLibraryCache: PublishedLibraryCache, + installerConfig: LibraryInstallerConfig ) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryInstallerConfig.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryInstallerConfig.scala new file mode 100644 index 0000000000000..e9c384de1b77c --- /dev/null +++ b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/LibraryInstallerConfig.scala @@ -0,0 +1,11 @@ +package org.enso.languageserver.libraries + +import org.enso.distribution.{DistributionManager, LanguageHome} +import org.enso.distribution.locking.ResourceManager + +/** Gathers configuration needed by the library installer used in the `library/preinstall` endpoint. */ +case class LibraryInstallerConfig( + distributionManager: DistributionManager, + resourceManager: ResourceManager, + languageHome: Option[LanguageHome] +) diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/LibraryPreinstallHandler.scala b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/LibraryPreinstallHandler.scala index 0dd2b4c8daeb8..29fefc55a021e 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/LibraryPreinstallHandler.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/libraries/handler/LibraryPreinstallHandler.scala @@ -1,56 +1,150 @@ package org.enso.languageserver.libraries.handler -import akka.actor.{Actor, Props} +import akka.actor.{Actor, ActorRef, Props} +import akka.pattern.pipe import com.typesafe.scalalogging.LazyLogging import org.enso.cli.task.notifications.ActorProgressNotificationForwarder -import org.enso.jsonrpc.{Request, ResponseError} +import org.enso.cli.task.{ProgressNotification, ProgressReporter} +import org.enso.distribution.ProgressAndLockNotificationForwarder +import org.enso.distribution.locking.LockUserInterface +import org.enso.editions.LibraryName +import org.enso.jsonrpc.{Id, Request, ResponseError, ResponseResult, Unused} import org.enso.languageserver.filemanager.FileManagerApi.FileSystemError -import org.enso.languageserver.libraries.FakeDownload import org.enso.languageserver.libraries.LibraryApi._ +import org.enso.languageserver.libraries.handler.LibraryPreinstallHandler.{ + InstallationError, + InstallerError, + InternalError, + LibraryInstallationComplete +} +import org.enso.languageserver.libraries.{ + EditionReference, + EditionReferenceResolver, + LibraryInstallerConfig +} import org.enso.languageserver.util.UnhandledLogging +import org.enso.librarymanager.ResolvingLibraryProvider.Error +import org.enso.librarymanager.{ + DefaultLibraryProvider, + ResolvedLibrary, + ResolvingLibraryProvider +} + +import java.util.concurrent.Executors +import scala.concurrent.{ExecutionContext, Future} +import scala.util.Try /** A request handler for the `library/preinstall` endpoint. * - * It is currently a stub implementation which will be refined later on. + * @param editionReferenceResolver an [[EditionReferenceResolver]] instance + * @param installerConfig configuration for the library installer */ -class LibraryPreinstallHandler - extends Actor +class LibraryPreinstallHandler( + editionReferenceResolver: EditionReferenceResolver, + installerConfig: LibraryInstallerConfig +) extends Actor with LazyLogging with UnhandledLogging { + + implicit private val ec: ExecutionContext = + ExecutionContext.fromExecutor(Executors.newCachedThreadPool()) + override def receive: Receive = { - case Request(LibraryPreinstall, id, LibraryPreinstall.Params(_, name)) => - // TODO [RW] actual implementation - val progressReporter = - ActorProgressNotificationForwarder.translateAndForward( - LibraryPreinstall.name, - sender() - ) - - if (name == "Test") { - FakeDownload.simulateDownload( - "Download Test", - progressReporter, - seconds = 1 - ) - } else { - FakeDownload.simulateDownload( - "Downloading something...", - progressReporter - ) - FakeDownload.simulateDownload( - "Downloading something else...", - progressReporter - ) + case Request( + LibraryPreinstall, + id, + LibraryPreinstall.Params(namespace, name) + ) => + val replyTo = sender() + val libraryName = LibraryName(namespace, name) + val notificationForwarder = new ProgressAndLockNotificationForwarder { + override def sendProgressNotification( + notification: ProgressNotification + ): Unit = + replyTo ! ActorProgressNotificationForwarder + .translateProgressNotification(LibraryPreinstall.name, notification) + } + + val installation = Future { + val result: Either[InstallationError, ResolvedLibrary] = for { + libraryInstaller <- getLibraryProvider( + notificationForwarder + ).toEither.left.map(InternalError) + library <- libraryInstaller + .findLibrary(libraryName) + .left + .map(InstallerError) + } yield library + LibraryInstallationComplete(id, replyTo, libraryName, result) + } + installation pipeTo self + + case LibraryInstallationComplete(requestId, replyTo, libraryName, result) => + result match { + case Left(error) => + val errorMessage = error match { + case InternalError(throwable) => + FileSystemError( + s"Could not initialize library installer: " + + s"${throwable.getMessage}" + ) + case InstallerError(Error.NotResolved(_)) => + LibraryNotResolved(libraryName) + case InstallerError(Error.RequestedLocalLibraryDoesNotExist) => + LocalLibraryNotFound(libraryName) + case InstallerError(Error.DownloadFailed(version, reason)) => + LibraryDownloadError(libraryName, version, reason.getMessage) + } + replyTo ! ResponseError( + Some(requestId), + errorMessage + ) + case Right(_) => + replyTo ! ResponseResult(LibraryPreinstall, requestId, Unused) } - sender() ! ResponseError( - Some(id), - FileSystemError("Feature not implemented") - ) } + + private def getLibraryProvider( + notificationReporter: ProgressReporter with LockUserInterface + ): Try[ResolvingLibraryProvider] = + for { + config <- editionReferenceResolver.getCurrentProjectConfig + edition <- editionReferenceResolver.resolveEdition( + EditionReference.CurrentProjectEdition + ) + } yield DefaultLibraryProvider.make( + distributionManager = installerConfig.distributionManager, + resourceManager = installerConfig.resourceManager, + lockUserInterface = notificationReporter, + progressReporter = notificationReporter, + languageHome = installerConfig.languageHome, + edition = edition, + preferLocalLibraries = config.preferLocalLibraries + ) } object LibraryPreinstallHandler { - /** Creates a configuration object to create [[LibraryPreinstallHandler]]. */ - def props(): Props = Props(new LibraryPreinstallHandler) + /** Creates a configuration object to create [[LibraryPreinstallHandler]]. + * + * @param editionReferenceResolver an [[EditionReferenceResolver]] instance + * @param installerConfig configuration for the library installer + */ + def props( + editionReferenceResolver: EditionReferenceResolver, + installerConfig: LibraryInstallerConfig + ): Props = Props( + new LibraryPreinstallHandler(editionReferenceResolver, installerConfig) + ) + + case class LibraryInstallationComplete( + requestId: Id, + replyTo: ActorRef, + libraryName: LibraryName, + result: Either[InstallationError, ResolvedLibrary] + ) + + sealed trait InstallationError + case class InternalError(throwable: Throwable) extends InstallationError + case class InstallerError(error: Error) extends InstallationError } diff --git a/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala b/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala index 4eb8260b0c320..4cde27c762fd6 100644 --- a/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala +++ b/engine/language-server/src/main/scala/org/enso/languageserver/protocol/json/JsonConnectionController.scala @@ -513,7 +513,10 @@ class JsonConnectionController( .props(requestTimeout, libraryConfig.localLibraryManager), LibraryGetMetadata -> LibraryGetMetadataHandler .props(requestTimeout, libraryConfig.localLibraryManager), - LibraryPreinstall -> LibraryPreinstallHandler.props(), + LibraryPreinstall -> LibraryPreinstallHandler.props( + libraryConfig.editionReferenceResolver, + libraryConfig.installerConfig + ), LibraryPublish -> LibraryPublishHandler .props(requestTimeout, libraryConfig.localLibraryManager), LibrarySetMetadata -> LibrarySetMetadataHandler diff --git a/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/BaseServerTest.scala b/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/BaseServerTest.scala index ba18c703293df..be045a72962ac 100644 --- a/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/BaseServerTest.scala +++ b/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/BaseServerTest.scala @@ -5,10 +5,13 @@ import io.circe.literal._ import io.circe.parser.parse import io.circe.syntax.EncoderOps import org.apache.commons.io.FileUtils -import org.enso.distribution.locking.ThreadSafeFileLockManager +import org.enso.distribution.locking.{ + ResourceManager, + ThreadSafeFileLockManager +} import org.enso.distribution.{DistributionManager, LanguageHome} -import org.enso.editions.{EditionResolver, Editions} import org.enso.editions.updater.EditionManager +import org.enso.editions.{EditionResolver, Editions} import org.enso.jsonrpc.test.JsonRpcServerTestKit import org.enso.jsonrpc.{ClientControllerFactory, Protocol} import org.enso.languageserver.TestClock @@ -23,40 +26,29 @@ import org.enso.languageserver.effect.ZioExec import org.enso.languageserver.event.InitializedEvent import org.enso.languageserver.filemanager._ import org.enso.languageserver.io._ -import org.enso.languageserver.libraries.{ - EditionReferenceResolver, - LibraryConfig, - LocalLibraryManager, - ProjectSettingsManager -} +import org.enso.languageserver.libraries._ import org.enso.languageserver.monitoring.IdlenessMonitor import org.enso.languageserver.protocol.json.{ JsonConnectionControllerFactory, JsonRpc } import org.enso.languageserver.refactoring.ProjectNameChangedEvent -import org.enso.languageserver.runtime.{ - ContextRegistry, - RuntimeFailureMapper, - RuntimeRequestHandler -} +import org.enso.languageserver.runtime.{ContextRegistry, RuntimeFailureMapper} import org.enso.languageserver.search.SuggestionsHandler import org.enso.languageserver.session.SessionRouter import org.enso.languageserver.text.BufferRegistry import org.enso.librarymanager.LibraryLocations import org.enso.librarymanager.local.DefaultLocalLibraryProvider import org.enso.librarymanager.published.PublishedLibraryCache -import org.enso.lockmanager.server.LockManagerService import org.enso.pkg.PackageManager import org.enso.polyglot.data.TypeGraph import org.enso.polyglot.runtime.Runtime.Api import org.enso.runtimeversionmanager.test.FakeEnvironment import org.enso.searcher.sql.{SqlDatabase, SqlSuggestionsRepo, SqlVersionsRepo} -import org.enso.testkit.{EitherValue, HasTestDirectory} +import org.enso.testkit.{EitherValue, WithTemporaryDirectory} import org.enso.text.Sha3_224VersionCalculator import org.scalatest.OptionValues -import java.nio.file import java.nio.file.{Files, Path} import java.util.UUID import scala.concurrent.Await @@ -66,7 +58,7 @@ class BaseServerTest extends JsonRpcServerTestKit with EitherValue with OptionValues - with HasTestDirectory + with WithTemporaryDirectory with FakeEnvironment { import system.dispatcher @@ -90,12 +82,7 @@ class BaseServerTest graph } - private val testDirectory = - Files.createTempDirectory("enso-test").toRealPath() - override def getTestDirectory: file.Path = testDirectory - sys.addShutdownHook(FileUtils.deleteQuietly(testContentRoot.file)) - sys.addShutdownHook(FileUtils.deleteQuietly(testDirectory.toFile)) def mkConfig: Config = Config( @@ -234,6 +221,10 @@ class BaseServerTest val environment = fakeInstalledEnvironment() val languageHome = LanguageHome.detectFromExecutableLocation(environment) val distributionManager = new DistributionManager(environment) + val lockManager = new ThreadSafeFileLockManager( + distributionManager.paths.locks + ) + val resourceManager = new ResourceManager(lockManager) val editionProvider = EditionManager.makeEditionProvider( @@ -271,7 +262,12 @@ class BaseServerTest editionManager = editionManager, localLibraryProvider = DefaultLocalLibraryProvider.make(libraryLocations), publishedLibraryCache = - PublishedLibraryCache.makeReadOnlyCache(libraryLocations) + PublishedLibraryCache.makeReadOnlyCache(libraryLocations), + installerConfig = LibraryInstallerConfig( + distributionManager, + resourceManager, + Some(languageHome) + ) ) new JsonConnectionControllerFactory( diff --git a/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/LibrariesTest.scala b/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/LibrariesTest.scala index e3d24219d602c..1849cc8ef967b 100644 --- a/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/LibrariesTest.scala +++ b/engine/language-server/src/test/scala/org/enso/languageserver/websocket/json/LibrariesTest.scala @@ -6,6 +6,7 @@ import nl.gn0s1s.bump.SemVer import org.enso.editions.{Editions, LibraryName} import org.enso.languageserver.libraries.LibraryEntry import org.enso.languageserver.libraries.LibraryEntry.PublishedLibraryVersion +import org.enso.librarymanager.published.bundles.LocalReadOnlyRepository import org.enso.librarymanager.published.repository.{ EmptyRepository, ExampleRepository @@ -15,18 +16,14 @@ import org.enso.pkg.{Contact, PackageManager} import java.nio.file.Files class LibrariesTest extends BaseServerTest { + private val libraryRepositoryPort: Int = 47308 + + private val exampleRepo = new ExampleRepository + private val baseUrl = s"http://localhost:$libraryRepositoryPort/" + private val repositoryUrl = baseUrl + "libraries" + override protected def customEdition: Option[Editions.RawEdition] = Some( - Editions.Raw.Edition - .make( - parent = Some(buildinfo.Info.currentEdition), - libraries = Seq( - Editions.Raw.PublishedLibrary( - name = LibraryName("Foo", "Bar"), - version = SemVer(1, 2, 3), - repository = "main" - ) - ) - ) + exampleRepo.createEdition(repositoryUrl) ) "LocalLibraryManager" should { @@ -201,8 +198,6 @@ class LibrariesTest extends BaseServerTest { """) } - def port: Int = 47308 - "create, publish a library and fetch its manifest from the server" in { val client = getInitialisedWsClient() client.send(json""" @@ -256,10 +251,12 @@ class LibrariesTest extends BaseServerTest { } """) - val baseUrl = s"http://localhost:$port/" - val repositoryUrl = baseUrl + "libraries" - val repoRoot = getTestDirectory.resolve("libraries_repo_root") - EmptyRepository.withServer(port, repoRoot, uploads = true) { + val repoRoot = getTestDirectory.resolve("libraries_repo_root") + EmptyRepository.withServer( + libraryRepositoryPort, + repoRoot, + uploads = true + ) { val uploadUrl = baseUrl + "upload" val uploadRequestId = 2 client.send(json""" @@ -360,49 +357,85 @@ class LibrariesTest extends BaseServerTest { } } - "mocked library/preinstall" should { - "send progress notifications" in { + "library/preinstall" should { + "download the library sending progress notifications " + + "and correctly place it in cache" in { val client = getInitialisedWsClient() - client.send(json""" + + val repositoryPath = getTestDirectory.resolve("repository_path") + exampleRepo.createRepository(repositoryPath) + exampleRepo.withServer(libraryRepositoryPort, repositoryPath) { + val requestId = 0 + client.send(json""" { "jsonrpc": "2.0", "method": "library/preinstall", - "id": 0, + "id": $requestId, "params": { "namespace": "Foo", - "name": "Test" + "name": "Bar" } } """) - val messages = - for (_ <- 0 to 3) yield { - val msg = client.expectSomeJson().asObject.value - val method = msg("method").map(_.asString.value).getOrElse("error") - val params = - msg("params").map(_.asObject.value).getOrElse(JsonObject()) - (method, params) + + val messages = collection.mutable.ListBuffer[(String, JsonObject)]() + var waitingForTask = true + var waitingForResult = true + + while (waitingForTask || waitingForResult) { + val msg = client.expectSomeJson().asObject.value + + msg("id") match { + case Some(json) => + json.asNumber.value.toInt.value shouldEqual requestId + msg("result").value.asNull.value + waitingForResult = false + case None => + val method = + msg("method").map(_.asString.value).getOrElse("error") + val params = + msg("params").map(_.asObject.value).getOrElse(JsonObject()) + messages.addOne((method, params)) + + if (method == "task/finished") waitingForTask = false + } } - val taskStart = messages.find(_._1 == "task/started").value - val taskId = taskStart._2("taskId").value.asString.value - taskStart - ._2("relatedOperation") - .value - .asString - .value shouldEqual "library/preinstall" + val taskStart = messages.find(_._1 == "task/started").value + val taskId = taskStart._2("taskId").value.asString.value + taskStart + ._2("relatedOperation") + .value + .asString + .value shouldEqual "library/preinstall" - taskStart._2("unit").value.asString.value shouldEqual "Bytes" + taskStart._2("unit").value.asString.value shouldEqual "Bytes" - val updates = messages.filter { case (method, params) => - method == "task/progress-update" && - params("taskId").value.asString.value == taskId - } + val updates = messages.filter { case (method, params) => + method == "task/progress-update" && + params("taskId").value.asString.value == taskId + } + + updates should not be empty + updates.head._2("message").value.asString.value should include( + "Downloading" + ) - updates should not be empty - updates.head - ._2("message") - .value - .asString - .value shouldEqual "Download Test" + val cachePath = getTestDirectory.resolve("test_data").resolve("lib") + val readOnlyCache = new LocalReadOnlyRepository(cachePath) + val cachedLibraryRoot = readOnlyCache + .findCachedLibrary( + LibraryName("Foo", "Bar"), + SemVer(1, 0, 0) + ) + .value + + val pkg = + PackageManager.Default.loadPackage(cachedLibraryRoot.toFile).get + pkg.name shouldEqual "Bar" + pkg.listSources.map( + _.file.getName + ) should contain theSameElementsAs Seq("Main.enso") + } } } diff --git a/engine/runtime/src/main/scala/org/enso/compiler/PackageRepository.scala b/engine/runtime/src/main/scala/org/enso/compiler/PackageRepository.scala index d6e8cca0bdc5a..480d942cc4400 100644 --- a/engine/runtime/src/main/scala/org/enso/compiler/PackageRepository.scala +++ b/engine/runtime/src/main/scala/org/enso/compiler/PackageRepository.scala @@ -223,7 +223,7 @@ object PackageRepository { .map { case ResolvingLibraryProvider.Error.NotResolved(details) => Error.PackageCouldNotBeResolved(details) - case ResolvingLibraryProvider.Error.DownloadFailed(reason) => + case ResolvingLibraryProvider.Error.DownloadFailed(_, reason) => Error.PackageDownloadFailed(reason) case ResolvingLibraryProvider.Error.RequestedLocalLibraryDoesNotExist => Error.PackageLoadingError( diff --git a/lib/scala/json-rpc-server-test/src/main/scala/org/enso/jsonrpc/test/JsonRpcServerTestKit.scala b/lib/scala/json-rpc-server-test/src/main/scala/org/enso/jsonrpc/test/JsonRpcServerTestKit.scala index f2d62e2e760b4..62b12446d90c2 100644 --- a/lib/scala/json-rpc-server-test/src/main/scala/org/enso/jsonrpc/test/JsonRpcServerTestKit.scala +++ b/lib/scala/json-rpc-server-test/src/main/scala/org/enso/jsonrpc/test/JsonRpcServerTestKit.scala @@ -52,7 +52,7 @@ abstract class JsonRpcServerTestKit def clientControllerFactory: ClientControllerFactory override def beforeEach(): Unit = { - + super.beforeEach() server = new JsonRpcServer(protocol, clientControllerFactory) binding = Await.result(server.bind(interface, port = 0), 3.seconds) address = s"ws://$interface:${binding.localAddress.getPort}" @@ -60,6 +60,7 @@ abstract class JsonRpcServerTestKit override def afterEach(): Unit = { val _ = binding.unbind() + super.afterEach() } class WsTestClient(address: String, debugMessages: Boolean = false) { diff --git a/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/DefaultLibraryProvider.scala b/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/DefaultLibraryProvider.scala index 6582d26f59f78..e0343bc21921d 100644 --- a/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/DefaultLibraryProvider.scala +++ b/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/DefaultLibraryProvider.scala @@ -72,7 +72,7 @@ class DefaultLibraryProvider private ( .map(ResolvedLibrary(libraryName, version, _)) .toEither .left - .map(ResolvingLibraryProvider.Error.DownloadFailed) + .map(ResolvingLibraryProvider.Error.DownloadFailed(version, _)) } } } diff --git a/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/ResolvingLibraryProvider.scala b/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/ResolvingLibraryProvider.scala index fe32a81b47493..90391bb717f4f 100644 --- a/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/ResolvingLibraryProvider.scala +++ b/lib/scala/library-manager/src/main/scala/org/enso/librarymanager/ResolvingLibraryProvider.scala @@ -1,6 +1,6 @@ package org.enso.librarymanager -import org.enso.editions.LibraryName +import org.enso.editions.{LibraryName, LibraryVersion} /** A helper class for resolving libraries. */ trait ResolvingLibraryProvider { @@ -37,6 +37,9 @@ object ResolvingLibraryProvider { /** Indicates that the library version was missing and had to be downloaded, * but the download has failed. */ - case class DownloadFailed(reason: Throwable) extends Error + case class DownloadFailed( + version: LibraryVersion.Published, + reason: Throwable + ) extends Error } } diff --git a/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/TestLocalLockManager.scala b/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/TestLocalLockManager.scala index 1eab247e27f0c..d5c17b289ee64 100644 --- a/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/TestLocalLockManager.scala +++ b/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/TestLocalLockManager.scala @@ -1,11 +1,6 @@ package org.enso.runtimeversionmanager.test -import org.enso.distribution.locking.{ - Lock, - LockManager, - LockType, - ThreadSafeLockManager -} +import org.enso.distribution.locking.{Lock, LockType, ThreadSafeLockManager} import java.util.concurrent.TimeUnit import java.util.concurrent.locks.{ @@ -14,7 +9,7 @@ import java.util.concurrent.locks.{ Lock => JLock } -/** A [[LockManager]] that creates process-local locks. +/** A [[ThreadSafeLockManager]] that creates process-local locks. * * The locks are not visible by other processes, so this manager is not useful * for synchronizing multiple processes. It can be used to test concurrency diff --git a/lib/scala/testkit/src/main/scala/org/enso/testkit/WithTemporaryDirectory.scala b/lib/scala/testkit/src/main/scala/org/enso/testkit/WithTemporaryDirectory.scala index 0b54065025536..5f55a6cbe1e8d 100644 --- a/lib/scala/testkit/src/main/scala/org/enso/testkit/WithTemporaryDirectory.scala +++ b/lib/scala/testkit/src/main/scala/org/enso/testkit/WithTemporaryDirectory.scala @@ -17,8 +17,8 @@ trait WithTemporaryDirectory /** @inheritdoc */ override def beforeEach(): Unit = { - super.beforeEach() prepareTemporaryDirectory() + super.beforeEach() } /** @inheritdoc