243 Commits

Author SHA1 Message Date
Jungwoo
0f9ef53126 fix: add test 2024-04-05 11:18:02 +01:00
Jungwoo Yang
35490dc559 Fix MergeSort.java 2024-04-05 11:18:02 +01:00
translatenix
d916345d2c Use Files.newInputStream()/newOutputStream() where appropriate (#383)
Use `Files.newInputStream(path)` instead of `new FileInputStream(path.toFile())`
and `Files.newOutputStream(path)` instead of `new FileOutputStream(path.toFile())`.
2024-04-04 16:04:14 -07:00
Daniel Chao
28448b5512 Ensure owner and receiver are reset after executing alias (#373)
This fixes an issue where the frame's owner/receiver are not reset
if a type test on a typealias fails.
2024-03-28 07:58:22 -07:00
translatenix
11a2343a65 Change HttpClientInitException to extend RuntimeException (#359)
PklException is mainly used to indicate errors during evaluation of Pkl code.
It isn't a suitable superclass for HttpClientInitException.
2024-03-22 16:32:16 -07:00
translatenix
deaf6983c4 Follow HTTP redirects (#328)
- Change HttpClient to follow all redirects except HTTPS to HTTP.
- Run language snippet tests with --no-cache and real PackageServer
  instead of pre-seeded cache.
  This increases HTTP test coverage and enables testing of package redirects.
- Change PackageServer to return 301 for request paths starting with /HTTP301/
  and 307 for request paths starting with /HTTP307/.
- Update some outdated test package checksums that apparently weren't verified.
2024-03-21 10:26:07 -07:00
translatenix
60bcd56672 Eliminate unnecessary use of GregorianCalendar (#344)
Switch from `java.util.GregorianCalendar` to `java.time.LocalDateTime`
2024-03-21 08:50:14 -07:00
translatenix
dfe85b786e Replace magic test port 12110 with 0 (#345)
Also introduce constants for some test package SHAs
to make them easier to update.
2024-03-20 10:47:28 -07:00
Stefan M
46d65506d5 Do not package empty directories (#330)
Changes the packager to exclude any empty directories.

This change means that pkl project package for an already published packages will fail. The packager checks for an existing package at this version, and compares checksums. It will then error if the checksum has changed.

This is technically a breaking change, albeit a minor one. The workaround is to publish new versions of packages.

Published packages should still be compatible with Pkl 0.25.
2024-03-19 09:34:47 -07:00
Daniel Chao
e4ccf517fa Use layout.buildDirectory (#326)
This switches Gradle scripts to use `layout.buildDirectory` instead
of hard-coded "build".
2024-03-18 21:42:16 -07:00
translatenix
496e064caf Update to Gradle 8.6 (#245)
- Fix and clean up the pkl-commons-test build script.
- Change tests to read test packages/certs directly from
  the file system instead of packaging and reading them
  from the class path.
- Update expected checksums of some test packages.
- Fix a conflict between Pkl's and Gradle's
  Kotlin libraries in the pkl-gradle project.
- Fix build deprecation warnings.
- Ensure Gradle distribution integrity with `distributionSha256Sum`.
- Manually verify integrity of Gradle wrapper added by this commit.
2024-03-15 17:00:23 -07:00
Daniel Chao
faa7ac69bb Fix amending module with abstract class (#319)
This fixes an assertion error that gets thrown if:
1. A module declares a class as abstract
2. An amending module does not use that abstract class as a type

Underneath the hood, the modifiers of the class/typelias object member
is considered different from the modifiers on the VmClass/VmTypeAlias
values.

The object model skips forcing any explicitly members that are explicitly
declared hidden, abstract, or local.
However, it _should_ evaluate any abstract classes found in a module.
So, it's incorrect to apply the same modifiers on the class to the object member.
2024-03-15 07:53:09 -07:00
translatenix
014b3a8816 Bind PackageServer to ephemeral port to avoid port conflicts (#227)
This is a comprehensive solution to the "flaky PackageServer tests"
problem. It rules out port conflicts and imposes no limits on test
parallelism. The same solution can be used for other test servers
in the future.

Major changes:
- Turn `PackageServer` from a singleton into a class that is
  instantiated per test class or test method.
- Start the server the first time its `port` property is read.
  Bind the server to an ephemeral port instead of port 12110.
- For every test that uses `PackageServer`, pass the server port to
  `--test-port`, `HttpClient.Builder.setTestPort`, the `CliBaseOptions`
  or `ExecutorOptions` constructor, or the Gradle plugin's `testPort` property.
  Wire all of these to `RequestRewritingClient`'s `testPort` constructor parameter.
- Enhance `RequestRewritingClient` to replace port 12110 with `testPort`
  in request URIs unless `testPort` is -1 (its default).
- Introduce `ExecutorOptions.Builder`.
  This makes executor options more comfortable to create
  and allows to hide options such as `testPort`.
- Deprecate the `ExecutorOptions` constructor to steer users towards the builder.
- Get rid of `ExecutorOptions2`, which is no longer needed.
- Clean up `EmbeddedExecutorTest` with the help of the builder.
2024-03-13 10:40:55 -07:00
Islon Scherer
8dc258ef7d fix bug with for generator variables in mixin (#297) 2024-03-07 20:47:21 +01:00
Daniel Chao
9defe868c0 Clean up http-client changes (#295)
* pkl-excutor tests: symlink 0.25.0 distribution into pkl-executable/build
* Use `IoUtils.getPklHomeDir` in HttpClientBuilder
* Simplify Exceptions.java
* Enable testing for older pkl-executor distribution
2024-03-07 10:43:04 -08:00
translatenix
3f3dfdeb1e Use java.net.http.HttpClient instead of java.net.Http(s)URLConnection (#217)
Moving to java.net.http.HttpClient brings many benefits, including
HTTP/2 support and the ability to make asynchronous requests.

Major additions and changes:
- Introduce a lightweight org.pkl.core.http.HttpClient API.
  This keeps some flexibility and allows to enforce behavior
  such as setting the User-Agent header.
- Provide an implementation that delegates to java.net.http.HttpClient.
- Use HttpClient for all HTTP(s) requests across the codebase.
  This required adding an HttpClient parameter to constructors and
  factory methods of multiple classes, some of which are public APIs.
- Manage CA certificates per HTTP client instead of per JVM.
  This makes it unnecessary to set JVM-wide system/security properties
  and default SSLSocketFactory's.
- Add executor v2 options to the executor SPI
- Add pkl-certs as a new artifact, and remove certs from pkl-commons-cli artifact

Each HTTP client maintains its own connection pool and SSLContext.
For efficiency reasons, It's best to reuse clients whenever feasible.
To avoid memory leaks, clients are not stored in static fields.

HTTP clients are expensive to create. For this reason,
EvaluatorBuilder defaults to a "lazy" client that creates the underlying
java.net.http.HttpClient on the first send (which may never happen).
2024-03-06 10:25:56 -08:00
Islon Scherer
9c3a761cfa add test for checking out of sync snippets (#240) 2024-03-01 16:44:36 +01:00
Daniel Chao
6746040362 Fix: add missing "const" and "fixed" modifiers to reflect API (#265)
This fixes an issue where the reflect API does not show fixed or const modifiers on a property.
2024-02-29 07:02:09 -08:00
Islon Scherer
90dedb7837 remove file with \ on the name as windows does not support it (#251) 2024-02-26 15:03:46 +01:00
translatenix
32bc75bf50 Add targets for org.pkl.core.util.Nullable (#235)
Also, change `java.time.@Nullable Duration` to `@Nullable java.time.Duration` to reduce the chance
of false positive errors in IDEs.
2024-02-23 07:07:08 -08:00
translatenix
d756dff0e7 Delete stale files in LanguageSnippetTests/output
When I delete pkl-core/src/test/files/LanguageSnippetTests/output and
run "gw test", most output files are regenerated, but 46 of them aren't.
I assume these are stale files that should be deleted.
2024-02-22 15:05:14 +00:00
translatenix
21e0e149ac Tweak User-Agent header
It is customary to separate elements with a semicolon.
2024-02-21 11:40:46 +00:00
Sam Gammon
1e50200969 Use Gradle typed project accessors
This change activates the `TYPESAFE_PROJECT_ACCESSORS` feature
preview in Gradle, and switches to such accessors instead of
string-based project references, where possible

Relates-To: apple/pkl#204
Signed-off-by: Sam Gammon <sam@elide.ventures>
2024-02-21 11:36:02 +00:00
Islon Scherer
611ab3b55c make reflected values renderable (#170) 2024-02-21 09:57:08 +01:00
translatenix
91367ed065 Fix unnecessary temp path resolution in PackageResolvers (#219)
The only call site already resolved the path against tmpDir.
2024-02-20 20:47:28 -08:00
translatenix
ffc629f28f Fix concurrency bug in PackageResolvers (#220)
Access to field "isClosed" must be guarded.
2024-02-20 16:46:09 -08:00
translatenix
277f1e0cdb Mark generated/truffle as generated source dir in IntelliJ
This fixes many "unknown symbol" errors in Java source files.
2024-02-20 15:18:39 +00:00
translatenix
50a006b1b5 Simplify code in ResourceReaders (#175) 2024-02-19 13:48:56 +01:00
Kushal Pisavadia
3d1db25864 Fix name resolution in typealias with constraint (#144)
The body of a typealias gets inlined into wherever the typealias
is used. This fixes a bug where the references in the typealias body can
resolve to the wrong value.
2024-02-15 13:28:10 -08:00
translatenix
1c29287344 Fix usage of wrong lock object (#163)
This changes the lock object to `lock`, which every other method is locking on.
2024-02-15 13:25:43 -08:00
Kushal Pisavadia
699cdc623e Update GraalVM to 22.3.3 (from 22.3.1) (#156)
This bumps GraalVM's version.

References:
- https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-22.3.3
- https://github.com/oracle/graal/compare/vm-22.3.1...vm-22.3.3
- https://www.graalvm.org/release-notes/22_3/
2024-02-15 09:48:15 -08:00
translatenix
c3473cc626 Add Gradle task "testNative"
Support running native tests with "gw testNative" for consistency with "gw test".
2024-02-14 19:53:40 +00:00
Philip K.F. Hölzenspies
aa98123c93 Update pkl-core/src/test/kotlin/org/pkl/core/LanguageSnippetTestsEngine.kt 2024-02-13 20:53:29 +00:00
translatenix
da597d838d Don't run JUnit tests for non-existing native executables
This allows to "Run all Tests" in IntelliJ without getting lots of test errors because "pkl-alpine-linux-amd64" etc. doesn't exist.
2024-02-13 20:53:29 +00:00
shubham gupta
db55c527c6 logical and fix in mathUtils (#102) 2024-02-08 21:21:49 -08:00
Daniel Chao
dddae1190f Fixes for pkldoc (#96)
* Add URI encoding to paths and fragments
* Render quotes around identifiers when appropriate
2024-02-08 11:28:34 -08:00
translatenix
77d0f5b8ca Only build static executable if musl toolchain is installed (#83)
This improves the development experience for (WSL) Linux users.
They can now run "./gradlew buildNative" without having a musl toolchain installed.
In this case, only the dynamically linked executable will be built.
2024-02-07 20:57:53 -08:00
Shubham Gupta
5a8d8680c4 fix mangled url
Crash help text has mangled URL #61
2024-02-07 20:12:23 +00:00
Daniel Chao
9f4fd58577 Fix documentation homepage (#81)
This adds a trailing slash that was missing from the documentation
homepage.
2024-02-07 07:33:19 -08:00
Dimitris Apostolou
80aff3afad Fix typos 2024-02-04 18:55:08 +02:00
Dan Chao
ce65290aae Start next dev iteration 2024-02-01 20:55:37 -08:00
Dan Chao
3f4932fcb6 Prepare 0.25.0 release 2024-02-01 14:00:51 -08:00
Peter Niederwieser
ecad035dca Initial commit 2024-02-01 14:00:22 -08:00