diff --git a/build.sbt b/build.sbt index d1455c7029c..e3ac4ca25ab 100644 --- a/build.sbt +++ b/build.sbt @@ -762,12 +762,13 @@ lazy val `version-output` = (project in file("lib/scala/version-output")) val file = (Compile / sourceManaged).value / "buildinfo" / "Info.scala" BuildInfo .writeBuildInfoFile( - file = file, - log = state.value.log, - ensoVersion = ensoVersion, - scalacVersion = scalacVersion, - graalVersion = graalVersion, - currentEdition = currentEdition + file = file, + log = state.value.log, + defaultDevEnsoVersion = defaultDevEnsoVersion, + ensoVersion = ensoVersion, + scalacVersion = scalacVersion, + graalVersion = graalVersion, + currentEdition = currentEdition ) }.taskValue ) diff --git a/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/ProjectCreateDefaultToLatestSpec.scala b/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/ProjectCreateDefaultToLatestSpec.scala index a8589a0641a..945a8f343be 100644 --- a/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/ProjectCreateDefaultToLatestSpec.scala +++ b/lib/scala/project-manager/src/test/scala/org/enso/projectmanager/protocol/ProjectCreateDefaultToLatestSpec.scala @@ -1,10 +1,18 @@ package org.enso.projectmanager.protocol import io.circe.literal.JsonStringContext +import nl.gn0s1s.bump.SemVer import org.enso.projectmanager.BaseServerSpec +import org.enso.runtimeversionmanager.test.OverrideTestVersionSuite + +class ProjectCreateDefaultToLatestSpec + extends BaseServerSpec + with OverrideTestVersionSuite { + + override val testVersion: SemVer = SemVer(0, 1, 0) -class ProjectCreateDefaultToLatestSpec extends BaseServerSpec { "project/create" should { + "default to latest available engine version if none are installed" in { implicit val client = new WsTestClient(address) client.send(json""" @@ -30,7 +38,7 @@ class ProjectCreateDefaultToLatestSpec extends BaseServerSpec { "jsonrpc":"2.0", "id":1, "error": { - "code": 4022, + "code": 4022, "message": $message, "data" : { "minimumRequiredVersion" : "9999.0.0" diff --git a/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/OverrideTestVersionSuite.scala b/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/OverrideTestVersionSuite.scala new file mode 100644 index 00000000000..eb145c138c7 --- /dev/null +++ b/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/OverrideTestVersionSuite.scala @@ -0,0 +1,25 @@ +package org.enso.runtimeversionmanager.test + +import nl.gn0s1s.bump.SemVer +import org.enso.runtimeversionmanager.CurrentVersion +import org.scalatest.{BeforeAndAfterAll, Suite} + +/** The suite that overrides the [[CurrentVersion]]. */ +trait OverrideTestVersionSuite extends Suite with BeforeAndAfterAll { + + private val originalVersion: SemVer = CurrentVersion.version + + /** The version that will be used in this suite. */ + def testVersion: SemVer + + override def beforeAll(): Unit = { + CurrentVersion.internalOverrideVersion(testVersion) + super.beforeAll() + } + + override def afterAll(): Unit = { + super.afterAll() + CurrentVersion.internalOverrideVersion(originalVersion) + } + +} diff --git a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala index 160cc860427..3852aa6370e 100644 --- a/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala +++ b/lib/scala/runtime-version-manager-test/src/test/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManagerSpec.scala @@ -1,6 +1,7 @@ package org.enso.runtimeversionmanager.components import java.nio.file.{Files, Path} + import nl.gn0s1s.bump.SemVer import org.enso.cli.OS import org.enso.distribution.FileSystem @@ -8,13 +9,19 @@ import org.enso.distribution.FileSystem.PathSyntax import org.enso.runtimeversionmanager.config.GlobalRunnerConfigurationManager import org.enso.runtimeversionmanager.releases.ReleaseNotFound import org.enso.runtimeversionmanager.test.{ + OverrideTestVersionSuite, RuntimeVersionManagerTest, TestRuntimeVersionManagementUserInterface } import org.enso.runtimeversionmanager.components import org.enso.testkit.OsSpec -class RuntimeVersionManagerSpec extends RuntimeVersionManagerTest with OsSpec { +class RuntimeVersionManagerSpec + extends RuntimeVersionManagerTest + with OsSpec + with OverrideTestVersionSuite { + + override val testVersion: SemVer = SemVer(0, 0, 1) "RuntimeVersionManager" should { "find the latest engine version in semver ordering " + diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala index 117b5c3cffe..7a2bf0a1262 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/CurrentVersion.scala @@ -15,9 +15,18 @@ object CurrentVersion { throw new IllegalStateException("Cannot parse the built-in version.") } + private val defaultDevEnsoVersion: SemVer = + SemVer(Info.defaultDevEnsoVersion).getOrElse { + throw new IllegalStateException("Cannot parse the built-in dev version.") + } + /** Version of the component. */ def version: SemVer = currentVersion + /** Check if the current version is the development one. */ + def isDevVersion: Boolean = + currentVersion == defaultDevEnsoVersion + /** Override launcher version with the provided one. * * Internal helper method used for testing. It should be called before any diff --git a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala index 7797d6a940c..c7f5aef6826 100644 --- a/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala +++ b/lib/scala/runtime-version-manager/src/main/scala/org/enso/runtimeversionmanager/components/RuntimeVersionManager.scala @@ -401,7 +401,19 @@ class RuntimeVersionManager( */ private def isEngineVersionCompatibleWithThisInstaller( manifest: Manifest - ): Boolean = CurrentVersion.version >= manifest.minimumRequiredVersion + ): Boolean = { + if (CurrentVersion.version >= manifest.minimumRequiredVersion) true + else if (CurrentVersion.isDevVersion) { + logger.warn( + "Ignoring the minimum required engine version check " + + s"[${manifest.minimumRequiredVersion}] for the development version " + + s"[${CurrentVersion.version}]." + ) + true + } else { + false + } + } /** Installs the engine with the provided version. * diff --git a/project/BuildInfo.scala b/project/BuildInfo.scala index 1294a332f73..92cda64ae55 100644 --- a/project/BuildInfo.scala +++ b/project/BuildInfo.scala @@ -14,6 +14,7 @@ object BuildInfo { * * @param file location where to write the Scala code * @param log a logger instance for diagnostics + * @param defaultDevEnsoVersion the default version used for dev builds * @param ensoVersion Enso version * @param scalacVersion Scala compiler version used in the project * @param graalVersion GraalVM version used in the project @@ -25,6 +26,7 @@ object BuildInfo { def writeBuildInfoFile( file: File, log: ManagedLogger, + defaultDevEnsoVersion: String, ensoVersion: String, scalacVersion: String, graalVersion: String, @@ -39,10 +41,11 @@ object BuildInfo { |object Info { | | // Versions - | val ensoVersion = "$ensoVersion" - | val scalacVersion = "$scalacVersion" - | val graalVersion = "$graalVersion" - | val currentEdition = "$currentEdition" + | val defaultDevEnsoVersion = "$defaultDevEnsoVersion" + | val ensoVersion = "$ensoVersion" + | val scalacVersion = "$scalacVersion" + | val graalVersion = "$graalVersion" + | val currentEdition = "$currentEdition" | | // Git Info | val commit = "${gitInfo.commitHash}" @@ -61,7 +64,7 @@ object BuildInfo { } private def isReleaseMode: Boolean = - if (sys.env.get("ENSO_RELEASE_MODE").contains("true")) true else false + sys.env.get("ENSO_RELEASE_MODE").contains("true") /** Information regarding the Git repository that was used in the build. *