Skip to content
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

Run whole test/Base_Tests with NI #10296

Merged
merged 58 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
29a0920
Try to run the whole test/Base_Tests
JaroslavTulach Jun 17, 2024
51bc321
Catch NI error
JaroslavTulach Jun 17, 2024
2aa81cd
Instance methods on Decoder and Encoder are being called
JaroslavTulach Jun 17, 2024
354808a
java.util.ArrayList is often used in tests - register it for reflection
JaroslavTulach Jun 17, 2024
20f9589
Allow access to instance methods of these classes
JaroslavTulach Jun 17, 2024
d636711
Need reflective access to AdjustOp nested class
JaroslavTulach Jun 17, 2024
c3a97c1
Need to call instance methods on LinearModel
JaroslavTulach Jun 17, 2024
d61e5d2
Need access to nested classes
JaroslavTulach Jun 17, 2024
dc38371
Put all extra files to Extra_Imports.enso
JaroslavTulach Jun 17, 2024
4a7a5df
locate enso_parser library even in ./runner mode
JaroslavTulach Jun 17, 2024
6efc514
Need to access message method
JaroslavTulach Jun 17, 2024
3f02060
Execute ./runner --run <selected file>
JaroslavTulach Jun 17, 2024
35ca49c
./runner must embed all locales
JaroslavTulach Jun 17, 2024
501c07d
Making sure more missing symbols is accesible
JaroslavTulach Jun 17, 2024
377bd2a
Replacing usage of asGuestObject in EnsoFile by own TruffleObject imp…
JaroslavTulach Jun 18, 2024
466f222
Support reading into a byte[]
JaroslavTulach Jun 18, 2024
a9cda6f
I/O needs to be hidden behind @TruffleBoundary
JaroslavTulach Jun 18, 2024
0d902b2
Cannot be loaded from "root"
JaroslavTulach Jun 18, 2024
31e3798
XML.from_file requires -1 at the end of the file
JaroslavTulach Jun 18, 2024
cae2521
Include jdk.localedata to make I18N available
JaroslavTulach Jun 18, 2024
30ce7c3
Less polyglot java imports in XML.enso
JaroslavTulach Jun 19, 2024
0695d1b
InputStreamLike interface to 'view' EnsoFile's 'java' stream as havin…
JaroslavTulach Jun 19, 2024
ec2ea1f
LocalDateTime and Function are used in Base_Tests
JaroslavTulach Jun 19, 2024
d03ba23
Add all Charsets
JaroslavTulach Jun 19, 2024
3e5e0b0
Don't need index to runEngineDistribution
JaroslavTulach Jun 20, 2024
3c52ea7
Let the Stream_Utils handle asInputStream conversion
JaroslavTulach Jun 20, 2024
07e7770
Additional imports
JaroslavTulach Jun 20, 2024
d59f6f7
Introducing File_Utils to encapsulate matcher
JaroslavTulach Jun 20, 2024
9f4569a
Avoid Python None check when Python is missing
JaroslavTulach Jun 20, 2024
b9d221f
asOutputStream wrapper
JaroslavTulach Jun 20, 2024
5328f66
Need to support available() to make Reporting_Stream_Decoder_Spec suc…
JaroslavTulach Jun 20, 2024
ec0918f
Register OutputStreamLike for reflection
JaroslavTulach Jun 20, 2024
c2f9eb5
Make HttpClient.Builder ready for reflective access
JaroslavTulach Jun 20, 2024
04bfdcd
Survive when js_exception (provided via asGuestValue) doesn't have th…
JaroslavTulach Jun 20, 2024
6ab352e
Rather call static method than Predicate.test
JaroslavTulach Jun 20, 2024
961c3ec
When XML_Document.Value is private, allocate with factory method
JaroslavTulach Jun 20, 2024
7d73811
Include org.enso.base_test_helpers on classpath when building native …
JaroslavTulach Jun 20, 2024
b222ed0
Another place to asOutputStream
JaroslavTulach Jun 20, 2024
e819e74
Calling overloaded Path.of has some issues. Use File_Utils wrapper
JaroslavTulach Jun 20, 2024
fc24808
Few more extra imports
JaroslavTulach Jun 20, 2024
0dec33e
Regenerated SubstrateVM metadata with:
JaroslavTulach Jun 20, 2024
41ef406
Search from cwd is important for development setup
JaroslavTulach Jun 20, 2024
582f3be
Relaxing the test as NI cannot provide location of the error (yet)
JaroslavTulach Jun 20, 2024
403e0d6
HttpClient.Version is being access
JaroslavTulach Jun 20, 2024
cc14d91
Manual tweaks to reflect-config.json file
JaroslavTulach Jun 20, 2024
34424ae
Have to absolutize the file path
JaroslavTulach Jun 20, 2024
71cfc0d
Avoid asGuestValue in EnsoProjectNode
JaroslavTulach Jun 20, 2024
2b9be62
Need to read statusCode from EnsoHttpResponse
JaroslavTulach Jun 20, 2024
a1bff6e
Test is accessing IntHolder value and boxed fields
JaroslavTulach Jun 20, 2024
4c2089f
Merging with develop
JaroslavTulach Jun 20, 2024
c4fb3db
Re-adding @Tail_Call as #9251 is fixed
JaroslavTulach Jun 20, 2024
31a3de8
test/Base_Tests shall be executed with assertions enabled
JaroslavTulach Jun 20, 2024
b2caa90
HTTP Response is using a lot of Java classes
JaroslavTulach Jun 20, 2024
1bae374
polyglot java import JsonLocation to be able to extract line and colu…
JaroslavTulach Jun 20, 2024
562e611
Factorial sample program is no longer needed
JaroslavTulach Jun 20, 2024
b8b4aae
Removing unused variables
JaroslavTulach Jun 20, 2024
8d0684c
Including Input_Stream_Spec in the Base_Tests
JaroslavTulach Jun 20, 2024
bfa60b4
Testing InputStreamLike with and without available member
JaroslavTulach Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"request": "launch",
"name": "Launch Native Image",
"nativeImagePath": "${workspaceFolder}/runner",
"args": "--help"
"args": "--run ${file}"
}
]
}
14 changes: 10 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2549,8 +2549,10 @@ lazy val `engine-runner` = project
if (smallJdkDirectory.exists()) {
IO.delete(smallJdkDirectory)
}
val JS_MODULES =
"org.graalvm.nativeimage,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.base,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise,jdk.compiler.graal,jdk.httpserver,java.naming,java.net.http"
val NI_MODULES =
"org.graalvm.nativeimage,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.base,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise"
val JDK_MODULES =
"jdk.localedata,jdk.compiler.graal,jdk.httpserver,java.naming,java.net.http"
val DEBUG_MODULES = "jdk.jdwp.agent"
val PYTHON_MODULES = "jdk.security.auth,java.naming"

Expand Down Expand Up @@ -2578,7 +2580,7 @@ lazy val `engine-runner` = project
}

val exec =
s"$jlink --module-path ${modules.mkString(":")} --output $smallJdkDirectory --add-modules $JS_MODULES,$DEBUG_MODULES,$PYTHON_MODULES"
s"$jlink --module-path ${modules.mkString(":")} --output $smallJdkDirectory --add-modules $NI_MODULES,$JDK_MODULES,$DEBUG_MODULES,$PYTHON_MODULES"
val exitCode = scala.sys.process.Process(exec).!

if (exitCode != 0) {
Expand Down Expand Up @@ -2610,6 +2612,9 @@ lazy val `engine-runner` = project
additionalOptions = Seq(
"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog",
"-H:IncludeResources=.*Main.enso$",
"-H:+AddAllCharsets",
"-H:+IncludeAllLocales",
"-ea",
// useful perf & debug switches:
// "-g",
// "-H:+SourceLevelDebug",
Expand Down Expand Up @@ -2660,6 +2665,7 @@ lazy val `engine-runner` = project
.dependsOn(`logging-service`)
.dependsOn(`logging-service-logback` % Runtime)
.dependsOn(`polyglot-api`)
.dependsOn(`enso-test-java-helpers`)

lazy val buildSmallJdk =
taskKey[File]("Build a minimal JDK used for native image generation")
Expand Down Expand Up @@ -3567,7 +3573,7 @@ ThisBuild / buildEngineDistributionNoIndex := {
lazy val runEngineDistribution =
inputKey[Unit]("Run or --debug the engine distribution with arguments")
runEngineDistribution := {
buildEngineDistribution.value
buildEngineDistributionNoIndex.value
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this is integrated, the runEngineDistribution command is going to be way faster. Thanks @Akirathan for the idea.

val args: Seq[String] = spaceDelimited("<arg>").parsed
DistributionPackage.runEnginePackage(
engineDistributionRoot.value,
Expand Down
18 changes: 1 addition & 17 deletions build/build/src/engine/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,28 +630,12 @@ pub async fn runner_sanity_test(
repo_root: &crate::paths::generated::RepoRoot,
enso_java: Option<&str>,
) -> Result {
let factorial_input = "6";
let factorial_expected_output = "720";
let engine_package = repo_root.built_distribution.enso_engine_triple.engine_package.as_path();
// The engine package is necessary for running the native runner.
ide_ci::fs::tokio::require_exist(engine_package).await?;
let output = Command::new(&repo_root.runner)
.args([
"--run",
repo_root.engine.runner.src.test.resources.factorial_enso.as_str(),
factorial_input,
])
.set_env_opt(ENSO_JAVA, enso_java)?
.set_env(ENSO_DATA_DIRECTORY, engine_package)?
.run_stdout()
.await?;
ensure!(
output.contains(factorial_expected_output),
"Native runner output does not contain expected result '{factorial_expected_output}'. Output:\n{output}",
);
if enso_java.is_none() {
let test_base = Command::new(&repo_root.runner)
.args(["--run", repo_root.test.join("Base_Tests").as_str(), "^Text"])
.args(["--run", repo_root.test.join("Base_Tests").as_str()])
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
.set_env_opt(ENSO_JAVA, enso_java)?
.set_env(ENSO_DATA_DIRECTORY, engine_package)?
.run_stdout()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import project.Errors.Encoding_Error.Encoding_Error
from project.Data.Text.Extensions import all

polyglot java import java.util.Base64
polyglot java import java.util.Base64.Decoder
polyglot java import java.util.Base64.Encoder

## A helper utility for handling base64 encoding.
type Base_64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ from project.Data.Text.Extensions import all
from project.Metadata.Choice import Option
from project.Metadata.Widget import Single_Choice

polyglot java import com.fasterxml.jackson.core.JsonLocation
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
polyglot java import com.fasterxml.jackson.core.JsonProcessingException
polyglot java import com.fasterxml.jackson.databind.JsonNode
polyglot java import com.fasterxml.jackson.databind.node.ArrayNode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import project.Nothing.Nothing
import project.Panic.Panic

polyglot java import org.enso.base.statistics.FitError
polyglot java import org.enso.base.statistics.LinearModel
polyglot java import org.enso.base.statistics.Regression

type Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Text.replace self term:(Text | Regex) replacement:Text (case_sensitivity:Case_Se
Applies the specified cleansings to the text.

Arguments:
- remove: A vector of the named patterns to cleanse from the text. The named patterns are
- remove: A vector of the named patterns to cleanse from the text. The named patterns are
applied in the order they are provided. The same named pattern can be used multiple
times. The named patterns are:
- ..Leading_Whitespace: Removes all whitespace from the start of the string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ polyglot java import java.time.DateTimeException
polyglot java import java.time.temporal.ChronoField
polyglot java import java.time.temporal.IsoFields
polyglot java import org.enso.base.Time_Utils
polyglot java import org.enso.base.Time_Utils.AdjustOp

## PRIVATE
Constructs a new Date from a year, month, and day.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ polyglot java import java.time.temporal.TemporalAdjuster
polyglot java import java.time.temporal.TemporalAdjusters
polyglot java import java.time.temporal.TemporalUnit
polyglot java import org.enso.base.time.CustomTemporalUnits
polyglot java import org.enso.base.time.Date_Utils
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these imports also be kept in Extra_Imports.enso?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My decision making process was:

  • if the failure is in *_Spec.enso file, put the polyglot java import into Extra_Imports.enso
  • if the failure is in Standard.Base library file, put the import into that file.

In this case the failure was in Date_Period.enso file, I believe.

polyglot java import org.enso.base.time.Date_Period_Utils
polyglot java import org.enso.base.time.Date_Time_Utils
polyglot java import org.enso.base.time.Time_Of_Day_Utils
polyglot java import org.enso.base.Time_Utils

## Represents a unit of time longer on the scale of days (longer than a day).
Expand Down
25 changes: 9 additions & 16 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ from project.Data.Range.Extensions import all
from project.Data.Text.Extensions import all
from project.Metadata import Display, make_single_choice, Widget

polyglot java import java.io.StringReader
polyglot java import java.lang.Exception as JException
polyglot java import javax.xml.parsers.DocumentBuilder
polyglot java import javax.xml.parsers.DocumentBuilderFactory
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
polyglot java import javax.xml.xpath.XPath
polyglot java import javax.xml.xpath.XPathConstants
polyglot java import javax.xml.xpath.XPathFactory
polyglot java import org.enso.base.XML_Utils
polyglot java import org.w3c.dom.Attr
polyglot java import org.w3c.dom.Document
polyglot java import org.w3c.dom.Element
polyglot java import org.w3c.dom.Node
polyglot java import org.w3c.dom.NodeList
polyglot java import org.w3c.dom.NamedNodeMap
polyglot java import org.w3c.dom.Text as Java_Text
polyglot java import org.xml.sax.InputSource
polyglot java import org.xml.sax.SAXException
polyglot java import org.xml.sax.SAXParseException

Expand Down Expand Up @@ -75,7 +74,8 @@ type XML_Document
from_stream : Input_Stream -> XML_Document ! XML_Error
from_stream input_stream:Input_Stream =
XML_Error.handle_java_exceptions <|
input_stream.with_java_stream java_stream-> XML_Document.from_source java_stream
input_stream.with_java_stream java_stream->
XML_Document.Value (XML_Utils.parseStream java_stream)

## GROUP Conversions
ICON convert
Expand All @@ -93,20 +93,13 @@ type XML_Document
from_text : Text -> XML_Document ! XML_Error
from_text xml_string:Text =
XML_Error.handle_java_exceptions <|
string_reader = StringReader.new xml_string
XML_Document.from_source (InputSource.new string_reader)
XML_Document.Value (XML_Utils.parseString xml_string)

## PRIVATE
Read XML from an input source.
from_source : Any -> XML_Document ! XML_Error
from_source input_source =
document_builder_factory = DocumentBuilderFactory.newInstance
document_builder = document_builder_factory.newDocumentBuilder
XML_Utils.setCustomErrorHandler document_builder
XML_Document.Value (document_builder.parse input_source)
Wrap Java's Document to XML_Document
new doc:Document = XML_Document.Value doc

## PRIVATE
Value (java_document:Document)
private Value (java_document:Document)


## GROUP Metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ from project.Metadata import make_single_choice

polyglot java import org.enso.base.enso_cloud.EnsoSecretHelper
polyglot java import org.enso.base.enso_cloud.HideableValue
polyglot java import org.enso.base.enso_cloud.HideableValue.PlainValue
polyglot java import org.enso.base.enso_cloud.HideableValue.SecretValue
polyglot java import org.enso.base.enso_cloud.HideableValue.ConcatValues
polyglot java import org.enso.base.enso_cloud.HideableValue.Base64EncodeValue

## A reference to a secret stored in the Enso Cloud.
type Enso_Secret
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ slice vector start end = @Builtin_Method "Array_Like_Helpers.slice"
`Map_Error`.
- No_Wrap: The first error is thrown, and is not wrapped in
`Map_Error`.
- Report_Warning: The result for that element is `Nothing`,
- Report_Warning: The result for that element is `Nothing`,
the error is attached as a warning. Currently unimplemented.
- Ignore: The result is `Nothing`, and the error is
ignored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,18 @@ polyglot java import org.enso.base.text.CaseFoldedString.Grapheme

# needed by Comparator_Spec:
polyglot java import org.enso.base.ObjectComparator

# often used in tests
polyglot java import java.util.ArrayList
polyglot java import java.util.Map
polyglot java import java.nio.CharBuffer
polyglot java import java.nio.file.Path
polyglot java import java.io.FileInputStream
polyglot java import java.io.FileOutputStream
polyglot java import java.math.BigInteger
polyglot java import java.time.LocalDate
polyglot java import java.time.LocalDateTime
polyglot java import java.util.function.Function
polyglot java import java.lang.Thread
polyglot java import java.lang.Thread.State
polyglot java import java.lang.Float
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Project_Description
Arguments:
- prim_root_file: The primitive root file of the project.
- prim_config: The primitive config of the project.
private Value prim_root_file prim_config
private Value prim_root_file ns:Text n:Text
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved

## GROUP Metadata
ICON folder
Expand Down Expand Up @@ -78,7 +78,7 @@ type Project_Description

enso_project.name
name : Text
name self = self.prim_config.name
name self = self.n

## GROUP Metadata
ICON metadata
Expand All @@ -89,7 +89,7 @@ type Project_Description

enso_project.namespace
namespace : Text
namespace self = self.prim_config.namespace
namespace self = self.ns

## ICON enso_icon
Returns the Enso project description for the project that the engine was
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ from project.Data.Json.Extensions import all

polyglot java import java.lang.Exception as JException
polyglot java import java.net.http.HttpClient
polyglot java import java.net.http.HttpClient.Redirect
polyglot java import java.net.http.HttpClient.Version
polyglot java import java.net.http.HttpClient.Builder as ClientBuilder
polyglot java import java.net.http.HttpRequest
polyglot java import java.net.http.HttpRequest.BodyPublisher
polyglot java import java.net.http.HttpRequest.BodyPublishers
polyglot java import java.net.http.HttpRequest.Builder
polyglot java import java.net.InetSocketAddress
polyglot java import java.net.ProxySelector
polyglot java import java.nio.file.Path
polyglot java import javax.net.ssl.SSLContext
polyglot java import org.enso.base.file_system.File_Utils
polyglot java import org.enso.base.enso_cloud.EnsoSecretHelper
polyglot java import org.enso.base.net.http.MultipartBodyBuilder
polyglot java import org.enso.base.net.http.UrlencodedBodyBuilder
Expand Down Expand Up @@ -242,7 +247,7 @@ resolve_body_to_publisher_and_boundary body:Request_Body =
json.if_not_error <|
Pair.new (body_publishers.ofString json) Nothing
Request_Body.Binary file ->
path = Path.of file.path
path = File_Utils.toPath file.path
Pair.new (body_publishers.ofFile path) Nothing
Request_Body.Form_Data form_data url_encoded ->
build_form_body_publisher form_data url_encoded
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ from project.Data.Text.Extensions import all
from project.Metadata import Display, Widget
from project.Network.HTTP.Response_Body import decode_format_selector

polyglot java import java.net.http.HttpHeaders
polyglot java import org.enso.base.enso_cloud.EnsoHttpResponse
polyglot java import java.util.Optional

type Response
## PRIVATE

Expand Down
12 changes: 5 additions & 7 deletions distribution/lib/Standard/Base/0.0.0-dev/src/System/File.enso
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ from project.System.File_Format import Auto_Detect, File_Format
polyglot java import java.io.File as Java_File
polyglot java import java.io.InputStream as Java_Input_Stream
polyglot java import java.io.OutputStream as Java_Output_Stream
polyglot java import java.nio.file.FileSystems
polyglot java import java.nio.file.Path
polyglot java import java.nio.file.StandardCopyOption
polyglot java import java.nio.file.StandardOpenOption
polyglot java import java.time.ZonedDateTime
polyglot java import org.enso.base.DryRunFileManager
polyglot java import org.enso.base.file_system.FileSystemSPI
polyglot java import org.enso.base.file_system.File_Utils

## PRIVATE
file_types : Vector
Expand Down Expand Up @@ -795,11 +794,10 @@ type File
_ ->
used_filter = if recursive.not || name_filter.contains "**" then name_filter else
(if name_filter.starts_with "*" then "*" else "**/") + name_filter
fs = FileSystems.getDefault
matcher = fs.getPathMatcher "glob:"+used_filter
matcher = File_Utils.matchPath "glob:"+used_filter
all_files.filter file->
pathStr = self.relativize file . path
matcher.matches (Path.of pathStr)
File_Utils.matches matcher pathStr

## GROUP Metadata
ICON metadata
Expand Down Expand Up @@ -894,11 +892,11 @@ Writable_File.from (that : File) = if Data_Link.is_data_link that then Data_Link
## PRIVATE
local_file_copy (source : File) (destination : File) (replace_existing : Boolean) -> Nothing =
File_Error.handle_java_exceptions source <|
copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING] else []
copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING.to_text] else []
source.copy_builtin destination copy_options

## PRIVATE
local_file_move (source : File) (destination : File) (replace_existing : Boolean) -> Nothing =
File_Error.handle_java_exceptions source <|
copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING] else []
copy_options = if replace_existing then [StandardCopyOption.REPLACE_EXISTING.to_text] else []
source.move_builtin destination copy_options
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ type File_Access
## PRIVATE

Convert this object into a representation understandable by the JVM.
to_java : StandardOpenOption
to_java self = case self of
File_Access.Append -> StandardOpenOption.APPEND
File_Access.Create -> StandardOpenOption.CREATE
File_Access.Create_New -> StandardOpenOption.CREATE_NEW
File_Access.Delete_On_Close -> StandardOpenOption.DELETE_ON_CLOSE
File_Access.Dsync -> StandardOpenOption.DSYNC
File_Access.Read -> StandardOpenOption.READ
File_Access.Sparse -> StandardOpenOption.SPARSE
File_Access.Sync -> StandardOpenOption.SYNC
File_Access.Truncate_Existing -> StandardOpenOption.TRUNCATE_EXISTING
File_Access.Write -> StandardOpenOption.WRITE
to_java : Text
to_java self =
java_option = case self of
File_Access.Append -> StandardOpenOption.APPEND
File_Access.Create -> StandardOpenOption.CREATE
File_Access.Create_New -> StandardOpenOption.CREATE_NEW
File_Access.Delete_On_Close -> StandardOpenOption.DELETE_ON_CLOSE
File_Access.Dsync -> StandardOpenOption.DSYNC
File_Access.Read -> StandardOpenOption.READ
File_Access.Sparse -> StandardOpenOption.SPARSE
File_Access.Sync -> StandardOpenOption.SYNC
File_Access.Truncate_Existing -> StandardOpenOption.TRUNCATE_EXISTING
File_Access.Write -> StandardOpenOption.WRITE
java_option.to_text

## PRIVATE
ensure_only_allowed_options (operation_name : Text) (allowed_options : Vector) (got_options : Vector) ~action =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import project.Data.Text.Text
import project.Data.Vector.Vector

polyglot java import java.nio.file.attribute.PosixFilePermission
polyglot java import java.nio.file.attribute.PosixFilePermissions
polyglot java import java.util.Set

type Permission
## Permission for read access for a given entity.
Expand Down Expand Up @@ -101,7 +103,8 @@ type File_Permissions
## PRIVATE
ADVANCED
Converts a Java `Set` of Java `PosixFilePermission` to `File_Permissions`.
from_java_set java_set =
from_java_set permissions:Text =
java_set = PosixFilePermissions.fromString permissions
vecs = Vector.build_multiple 3 builders->
owner = builders.at 0
group = builders.at 1
Expand Down
Loading
Loading