Add Meta.engine_version (#11320)

Numerous times I wasn't sure when running the IDE if I'm running the bundled engine or a development build. Usually this depends on if I launch the standalone IDE or use a development build of project-manager.

Still it's not always obvious, and making sure that your IDE is running the right engine version is very often the first step when debugging issues with e.g. engine changes not showing up properly.

Thus I thought it may be worth to add this method (currently hidden to users in component browser by marking as `PRIVATE`, one has to type it in manually):
![image](https://github.com/user-attachments/assets/13af3df4-49ff-49bb-9b19-601258a8ca02)

I think it should be a helpful tool for debugging.
This commit is contained in:
Radosław Waśko 2024-10-15 15:22:55 +02:00 committed by GitHub
parent 2285b7d752
commit 21bd05f318
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 56 additions and 0 deletions

View File

@ -688,3 +688,9 @@ type Instrumentor
- fqn: fully qualified name.
find_type_by_qualified_name : Text -> Any
find_type_by_qualified_name fqn = @Builtin_Method "Meta.find_type_by_qualified_name"
## PRIVATE
ADVANCED
Returns the version of the currently running Enso engine.
engine_version : Text
engine_version = @Builtin_Method "Meta.engine_version"

View File

@ -0,0 +1,45 @@
package org.enso.interpreter.node.expression.builtin.meta;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.nodes.Node;
import org.enso.interpreter.dsl.BuiltinMethod;
import org.enso.interpreter.runtime.data.text.Text;
import org.enso.version.BuildVersion;
@BuiltinMethod(
type = "Meta",
name = "engine_version",
description = "Returns the version of the currently running Enso engine.",
autoRegister = false)
public class CurrentEngineVersionNode extends Node {
public Text execute() {
return getCurrentVersion();
}
@CompilerDirectives.TruffleBoundary
private Text getCurrentVersion() {
StringBuilder sb = new StringBuilder();
sb.append("Enso Engine Version: ");
sb.append(BuildVersion.ensoVersion());
sb.append("\nDefault Edition: ");
sb.append(BuildVersion.currentEdition());
sb.append("\nCompiled with GraalVM ");
sb.append(BuildVersion.graalVersion());
sb.append(", Scalac ");
sb.append(BuildVersion.scalacVersion());
sb.append("\nBased on commit ");
sb.append(BuildVersion.commit());
sb.append(" (at ");
sb.append(BuildVersion.latestCommitDate());
sb.append(")\non ref ");
sb.append(BuildVersion.ref());
if (BuildVersion.isDirty()) {
sb.append("\n(with uncommitted changes)");
}
return Text.create(sb.toString());
}
}

View File

@ -476,6 +476,11 @@ add_specs suite_builder =
typ = Meta.Type.find fqn
typ . should_equal meta_type
suite_builder.group "Engine Metadata" group_builder->
group_builder.specify "should return engine version" <|
version = Meta.engine_version
version.should_contain "Enso Engine Version:"
main filter=Nothing =
suite = Test.build suite_builder->
add_specs suite_builder