-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Meta.enso_project #10192
Merged
+175
−95
Merged
Fix Meta.enso_project #10192
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0991bdd
Project_Description constructor is private
Akirathan 2059ba8
Rewrite EnsoProjectTest to java
Akirathan c9a37e8
Fix typos in test
Akirathan 48b94ed
Project_Description.new is not private
Akirathan aa24564
Add tests for invocation of enso_project from polyglot
Akirathan f50e6e1
Add a failing test for evaluating enso_project from java
Akirathan 1b71504
Meta_Location_Spec succeeds if it is run standalone
Akirathan eadcc68
Enso_project descriptor is derived from package repository, not from …
Akirathan 2d22012
Merge branch 'refs/heads/develop' into wip/akirathan/9845-enso-proj-fix
Akirathan 79f0494
Merge branch 'refs/heads/develop' into wip/akirathan/9845-enso-proj-fix
Akirathan 54e5aeb
Fix Standard.Examples.data_dir
Akirathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
...ntime-integration-tests/src/test/java/org/enso/interpreter/test/meta/EnsoProjectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package org.enso.interpreter.test.meta; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Set; | ||
import org.enso.common.LanguageInfo; | ||
import org.enso.interpreter.util.ScalaConversions; | ||
import org.enso.pkg.QualifiedName; | ||
import org.enso.polyglot.PolyglotContext; | ||
import org.enso.polyglot.RuntimeOptions; | ||
import org.enso.test.utils.ContextUtils; | ||
import org.enso.test.utils.ProjectUtils; | ||
import org.enso.test.utils.SourceModule; | ||
import org.graalvm.polyglot.Source; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
public class EnsoProjectTest { | ||
@Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void noProjectWhenEvaluatingSingleFile() { | ||
try (var ctx = ContextUtils.createDefaultContext()) { | ||
var res = | ||
ContextUtils.evalModule( | ||
ctx, | ||
""" | ||
from Standard.Base import all | ||
from Standard.Base.Errors.Common import Module_Not_In_Package_Error | ||
|
||
main = | ||
enso_project.is_error | ||
"""); | ||
assertThat(res, notNullValue()); | ||
assertThat(res.asBoolean(), is(true)); | ||
} | ||
} | ||
|
||
@Test | ||
public void ensoProjectWorksInOneProject() throws IOException { | ||
var mainMod = | ||
new SourceModule( | ||
QualifiedName.fromString("Main"), | ||
""" | ||
from Standard.Base import all | ||
main = | ||
enso_project.name | ||
"""); | ||
var projDir = temporaryFolder.newFolder().toPath(); | ||
ProjectUtils.createProject("Proj", Set.of(mainMod), projDir); | ||
ProjectUtils.testProjectRun( | ||
projDir, | ||
(res) -> { | ||
assertThat(res.asString(), is("Proj")); | ||
}); | ||
} | ||
|
||
@Test | ||
public void ensoProjectWorksInTwoProjects() throws IOException { | ||
var mainMod1 = | ||
new SourceModule( | ||
QualifiedName.fromString("Main"), | ||
""" | ||
from Standard.Base import all | ||
|
||
get_enso_project_name = | ||
enso_project.name | ||
"""); | ||
var mainMod2 = | ||
new SourceModule( | ||
QualifiedName.fromString("Main"), | ||
""" | ||
from local.Proj1 import get_enso_project_name | ||
main = | ||
get_enso_project_name | ||
"""); | ||
var projDir1 = temporaryFolder.newFolder().toPath(); | ||
var projDir2 = temporaryFolder.newFolder().toPath(); | ||
ProjectUtils.createProject("Proj1", Set.of(mainMod1), projDir1); | ||
ProjectUtils.createProject("Proj2", Set.of(mainMod2), projDir2); | ||
ProjectUtils.testProjectRun( | ||
projDir2, | ||
(res) -> { | ||
assertThat(res.asString(), is("Proj2")); | ||
}); | ||
} | ||
|
||
@Test | ||
public void ensoProjectCanBeCalledFromJava() throws IOException { | ||
var mainMod = | ||
new SourceModule( | ||
QualifiedName.fromString("Main"), | ||
""" | ||
from Standard.Base import all | ||
main = | ||
42 | ||
"""); | ||
var projDir = temporaryFolder.newFolder().toPath(); | ||
ProjectUtils.createProject("Proj", Set.of(mainMod), projDir); | ||
var mainModFile = projDir.resolve("src").resolve("Main.enso"); | ||
assertThat(mainModFile.toFile().exists(), is(true)); | ||
try (var ctx = | ||
ContextUtils.defaultContextBuilder() | ||
.option(RuntimeOptions.PROJECT_ROOT, projDir.toAbsolutePath().toString()) | ||
.build()) { | ||
var mainSrc = Source.newBuilder(LanguageInfo.ID, mainModFile.toFile()).build(); | ||
// First eval the source so that everything is compiled. | ||
ctx.eval(mainSrc); | ||
var polyCtx = new PolyglotContext(ctx); | ||
var mod = polyCtx.getTopScope().getModule("Standard.Base.Meta.Enso_Project"); | ||
var assocType = mod.getAssociatedType(); | ||
var ensoProjMethod = mod.getMethod(assocType, "enso_project").get(); | ||
var projDescr = ensoProjMethod.execute(ScalaConversions.seq(List.of(assocType))); | ||
assertThat(projDescr.hasMembers(), is(true)); | ||
assertThat(projDescr.getMetaObject().getMetaSimpleName(), is("Project_Description")); | ||
assertThat(projDescr.hasMember("name"), is(true)); | ||
assertThat(projDescr.invokeMember("name").asString(), is("Proj")); | ||
} | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
...integration-tests/src/test/scala/org/enso/interpreter/test/semantic/EnsoProjectTest.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change. It ensures that one can run this test as standalone with
enso --run test/Base_Tests/src/Semantic/Meta_Location_Spec.enso
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't the tests below break if run without
--in-project
anyway?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to specify
--in-project
anymore since #8775There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why was the standalone run ever failing? It should always return
enso_dev.Base_Tests.Semantic.Meta_Location_Spec.My_Type
as the qualified name, no?If not, what does it return instead??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It incorrectly returns
Meta_Location_Spec.My_Type
.Meta.get_qualified_type_name
seems broken. Tracked in #10228. In that issue, there is a task to revert this change once that is fixed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, great