mirror of
https://github.com/enso-org/enso.git
synced 2024-12-31 17:55:35 +03:00
Fix dev version check (#3265)
This commit is contained in:
parent
fbf747d6cf
commit
792c7e3538
13
build.sbt
13
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
|
||||
)
|
||||
|
@ -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"
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
@ -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 " +
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user