Commit Graph

10242 Commits

Author SHA1 Message Date
Ethan Atkins 16e7c70035 Lint TypeFunctions.scala 2019-01-31 21:47:33 -08:00
eugene yokota 1c5608e1dd
Merge pull request #4534 from eatkins/misc-fixups
Misc fixups
2019-01-31 21:19:21 -05:00
Ethan Atkins 7b8ed4d13f Allow sbt scripted tests to run in parallel
I'm not sure if this is a huge benefit or not, but it's nice to have the
option to run the scripted tests in parallel. The default behavior
should be the same as before.
2019-01-31 17:43:14 -08:00
Ethan Atkins 9023b58f83 Remove debug commands in scripted
These just create noise.
2019-01-31 17:43:14 -08:00
Ethan Atkins b2c9d3e2cf Use custom classloader for scripted tests
We had previously used reflection to load the bridge class, but
continued using sbt's default classloader. This was problematic because
the metabuild could have a different classpath from that required by the
scripted tests.

Bonus: scalafmt

Fixes: #4514
2019-01-31 17:43:14 -08:00
eugene yokota dc870e19b1
Merge pull request #4529 from eatkins/community-build-runner
Fix community build
2019-01-31 20:25:49 -05:00
eugene yokota 986abb3882
Merge pull request #4532 from eatkins/system-lint
System lint
2019-01-31 20:23:44 -05:00
Ethan Atkins 82cfbe83a7 Fix doc warning
The scaladoc task was warning:
'Could not find any member to link for "LinterLevelLowPriority"'. Given
that LinterLevelLowPriority is a package private trait, it shouldn't be
mentioned by name.
2019-01-31 17:04:40 -08:00
Ethan Atkins df6f3bd888 Switch to regular comment instead of scaladoc
Having this as scaladoc adds an unmoored doc comment compiler warning
because no documentation is generated for the class that is being
documented.
2019-01-31 17:04:40 -08:00
Ethan Atkins e0e2336a4b Update call to deprecated api in scripted 2019-01-31 17:04:40 -08:00
Ethan Atkins a556fc654a Lint Transform.scala
The file is green in intellij after this change.
2019-01-31 10:53:07 -08:00
Ethan Atkins da1cc40314 Rename System.scala to Transform.scala
The System.scala contained a single scala object called Transform, hence
the rename to Transform.scala.
2019-01-31 10:52:43 -08:00
Ethan Atkins 92807869ea Fix community build
The community build was broken for some projects because I broke builds
that relied on the unscoped definition of `runner`. To preserve legacy
behavior, I restore the old unscoped behavior and append the new scoped
runners that used the layered classloaders. This makes more sense
because the layered classloaders were specifically designed for the
Runtime and Test configurations and may not make sense in other
contexts.
2019-01-30 20:54:08 -08:00
eugene yokota f170d0c60c
Merge pull request #4526 from eatkins/cleanup-caffeine
Cleanup caffeine
2019-01-30 15:12:00 -05:00
Ethan Atkins ba3ff8198d Remove unneeded parens in Definition.scala 2019-01-30 10:46:00 -08:00
Ethan Atkins 06a153278f Cleanup cache when CommandExchange shuts down
I noticed that sometimes when running scripted tests that I'd run out of
metaspace. I believe that this may be due to the caffeine cache leaking
classloaders. Regardless, it's a good idea to clear the cache whenever
we shutdown the command exchange or reload the state.
2019-01-30 10:45:22 -08:00
Ethan Atkins 6e5caa90c1
Merge pull request #4476 from eatkins/classloaders
Add cache of layered classloaders for test and run tasks
2019-01-30 10:13:53 -08:00
Ethan Atkins 0a4fbc9f5a Set classLoaderLayeringStrategy in relevant configs
Previously, the ClassLoaderLayeringStrategy was set globally. This
didn't really make sense because the Runtime and Test configs had
different strategies available (Test being a superset of Runtime).
Instead, we now set the layering strategy in the Runtime and Test
configurations directly. In doing this, we can eliminate the Default
ClassLoaderLayeringStrategy. Previously this had existed so that we
could set the layering strategy globally and have it do the right thing
in both test and runtime.

To implement this, I factored out the logic for generating the layered
classloader in the test task and shared it with the runtime task. I did
this because I realized that Test / run is a thing. Previously I had
been operating under the assumption that the runner would never include
the test dependencies. Once I realized this, it made sense to combine
the logic in both tasks.

As a bonus, I only allow the layering strategies that explicitly make
sense to be set in each configuration. If the user sets an invalid
strategy, an error will be thrown that specifies the valid strategies
for the task.

I also added ScalaInstance as an option for the runtime layer. It was an
oversight that this was left out.
2019-01-30 08:55:22 -08:00
Ethan Atkins 0fb60733cd Bump classloader-cache test to scala 2.12.8
These were written before we upgraded scala in the develop branch. I'm
not doing this as a fixup to keep the PR clean.
2019-01-30 08:55:22 -08:00
Ethan Atkins 3a211710f9 Rename some layering related fields/classes
In code review, @eed3si9n suggested that I switch to a more verbose and
descriptive naming scheme. In addition to trying to make layers more
descriptive, I also made the various layer case objects extend the
relevant layers so it's more clear what the layer should look like.
2019-01-30 08:55:22 -08:00
Ethan Atkins 1ca6b97de2 JDK 11 fixes
In JDK 11, String.lines returns java.util.stream.Stream[String]. Switch
to linesIterator instead.
2019-01-30 08:55:22 -08:00
Ethan Atkins 1d467bd966 Fix FileRepository implementation for scripted
I was seeing spurious travis failures and I finally tracked it down to
the fact that in some cases, the project metabuild would sometimes use a
caching file tree repository instead of a polling repository. This
caused problems because the caching repository can take a few milliseconds
to detect changes in a directory. Because scripted copies the project
sources to the temporary test directory, it was possible for the project
meta build compilation to be initiated before the cache was aware of all
of the files.

The reason this happened was because scripted would create a state where
the remaining commands looked like:
List(sbtPopOnFailure, resumeFromFailure, notifyUsersAboutShell, iflast shell, ~compile, < 41684)
The ~compile command was causing the continuous flag to get set to true
which caused the default file tree repository task to return the caching
version. The reason for the continuous flag was so that when sbt is
started in a non-interactive mode where the command is to be repeated,
then we use the caching file tree repository. To support this use case,
we just need to check that the last command begins with `~`, not that
_any_ command begins with `~`.
2019-01-30 08:55:22 -08:00
Ethan Atkins 5fc5846737 Add TaskRepository to manage ClassLoaderCache
We want the user to be able to invalidate the classloader cache in the
event that it somehow gets in a bad state. The cache is, however,
defined in multiple configurations, so there are in fact many
ClassLoaderCache instances that are managed by sbt. To make this sane, I
add a global cache that is keyed by a TaskKey[_] and can return
arbitrary data back. Invalidating all of the ClassLoaderCache instances
is then as straightforward as just replacing the TaskRepository
instance.

I also went ahead and unified the management of the global file tree
repository. Instead of having to specifically clear the file tree
repository or the classloader cache, the user can now invalidate both
with the new clearCaches command.
2019-01-30 08:55:22 -08:00
Ethan Atkins aca541898d Add scripted tests for classloader-cache
Normally I'd include these with the previous commit, but the diff is so
large that I put them in their own commit. The tests handle 5 scenarios:

1) akka-actor-system -- a project that has Akka as a dependency and a
   simple main method that creates and terminates an ActorSystem. What
   is interesting about this test is that if scriptedBufferLog := false,
   we notice that the first call to run is slow, but subsequent calls to
   run and test are fast. The test does at least ensure that recycling
   the runtime layer in test works ok.

2) jni -- verifies that a project with native libraries will be able to
   load the library with each run. It actually swaps out the underlying
   library so that the it really ensures that the library is reloaded
   between runs.

3) library-mismatch -- verifies that the layered classloaders can work
   when the test dependencies are incompatible with the runtime
   dependencies. In this test, the test dependencies use an api in a
   library called foo-lib that isn't available in the version used by
   the runtime dependencies. Because of this incompatibility, the test
   will not work if Test / layeringStrategy := LayeringStrategy.Full.

4) scalatest -- verifies that a test runs using the scalatest framework
5) utest -- verifies that a test runs using the utest framework

The reason for (4) and (5) is to ensure that both the in sourced test
frameworks and external frameworks work with the new loaders.
2019-01-30 08:55:22 -08:00
Ethan Atkins a06f5435c6 Use layered ClassLoaders in run and test tasks
Using the data structures that I added in the previous commits, it is
now possible to rework the run and test task to use (configurable)
layered class loaders. The layering strategy is globally set to
LayeringStrategy.Default. The default strategy leads to what is
effectively a three layered ClassLoader for the both the test and run
tasks. The first layer contains the scala instance (and test framework
loader in the test task). The second layer contains all of the
dependencies for the configuration while the third layer contains the
project artifacts.

The layering strategy is very easily changed both at the Global or
Configuration level, e.g. adding
Test / layeringStrategy := LayeringStrategy.Flat
to the project build.sbt will make the test task not even use the scala
instance and instead a create a single layer containing the full
classpath of the test task.

I also tried to ensure that all of the ClassLoaders have good toString
overrides so that it's easy to see how the ClassLoader is constructed
with, e.g. `show testLoader`, in the sbt console.

In this commit, the ClassLoaderCache instances are settings. In the next
commit, I make them tasks so that we can easily clear out the caches
with a command.
2019-01-30 08:55:22 -08:00
Ethan Atkins 8cba83aebb Improve TestFramework error reporting
It is possible for the test task to fail because of issues with the
layered ClassLoaders. When this occurs and is detectable, I try to
provide a useful error message that will help the user fix the issue.
2019-01-30 08:55:22 -08:00
Ethan Atkins f118a5e410 Add LayeringStrategy
This introduces a new trait LayeringStrategy that is used to configure
how sbt constructs the ClassLoaders used by the run and test tasks. In
addition to defining the various options, I try to give a good high
level overview of the problem that the LayeringStrategy is intended to
address in its scaladoc.
2019-01-30 08:55:22 -08:00
Ethan Atkins 2e40b52e7c Cleanup scripted tests
The sleeps in source-dependencies/export-jars are no longer necessary
and just slow the test down. I also fixed minor syntax issues in
scala-instance-classloader and fixed a thread leak in the test.
2019-01-30 08:55:22 -08:00
Ethan Atkins ef08290ecc Add ClassLoaderCache
In order to speed up the start up time of the test and run tasks, I'm
introducing a ClassLoaderCache that can be used to avoid reloading the
classes in the project dependencies (which includes the scala library).
I made the api as minimal as possible so that we can iterate on the
implementation without breaking binary compatibility. This feature will
be gated on a feature flag, so I'm not concerned with the cache class
loaders being useable in every user configuration. Over time, I hope
that the CachedClassLoaders will be a drop in replacement for the
existing one-off class loaders*.

The LayeredClassLoader was adapted from the NativeCopyLoader. The main
difference is that the NativeCopyLoader extracts named shared libraries
into the task temp directory to ensure that the ephemeral libraries are
deleted after each task run. This is a problem if we are caching the
ClassLoader so for LayeredClassLoader I track the native libraries that
are extracted by the loader and I delete them either when the loader is
explicitly closed or in a shutdown hook.

* This of course means that we both must layer the class loaders
appropriately so that the project code is in a layer above the cached
loaders and we must correctly invalidate the cache when the project, or
its dependencies are updated.
2019-01-30 08:55:22 -08:00
Ethan Atkins 5bbda9cf69 Add Repository interface
I am going to be introducing multiple caches throughout sbt and I am
going to build these features out using this simple Repository
interface. The idea is that we access data by some key through the
Repository. This allows us to use the strategy pattern to easily switch
the runtime implementation of how to get the data.
2019-01-30 08:55:22 -08:00
Ethan Atkins ec22d6c0da Add LRUCache to sbt.internal
I am going to add a classloader cache to improve the startup performance
of the run and test tasks. To prevent the classloader cache from having
unbounded size, I'm adding a simple LRUCache implementation to sbt. An
important characteristic of the implementation of the cache is that when
entries are evicted, we run a callback to cleanup the entry. This allows
us to automatically cleanup any resources created by the entry.

This is a pretty naive implementation that uses an array of entries that
it manipulates as elements are removed/accessed. In general, I expect
these caches to be quite small <= 4 elements, so the storage overhead /
performance of the simple implementation should be quite good. If
performance ever becomes an issue, we can specialzed LRUCache.apply to
use a different implementation for caches with large limits.
2019-01-30 08:55:22 -08:00
eugene yokota e36360977b
Merge pull request #4524 from eed3si9n/wip/bumpmodule
Zinc 1.3.0-M2, Util 1.3.0-M4
2019-01-30 11:01:18 -05:00
Eugene Yokota 67a0962b18 Diable these tests
Ref #4514

There's a problem with calling scripted from scripted tests.
It's likely the bug is in the metabuild of sbt/sbt, not sbt itself.
2019-01-30 01:43:28 -05:00
Eugene Yokota e91b651a03 Zinc 1.3.0-M2, Util 1.3.0-M4 2019-01-29 18:15:40 -05:00
Dale Wijnand 08d5eed549
Merge pull request #4521 from dwijnand/implement-Append-for-Function1
Implement Append for Function1
2019-01-29 18:17:38 +00:00
Dale Wijnand 32b342e9a8
Mention SAM conversions 2019-01-29 15:47:50 +00:00
Dale Wijnand 53c6299c94
Implement Append for Function1 2019-01-29 09:12:11 +00:00
Dale Wijnand 14bffefef9
Cleanup Append 2019-01-27 16:20:59 +00:00
eugene yokota 9e37391937
Merge pull request #4516 from cunei/bumpScala12x
Bump the 2.12 version to 2.12.8 in 1.2.x
2019-01-17 10:35:48 -05:00
Antonio Cunei 6b3ec4e1d0 More bumping up the 2.12 version to 2.12.8 in 1.2.x 2019-01-17 11:21:52 +01:00
eugene yokota 88624cb779
Merge pull request #4515 from eatkins/typed-path-api
Update TypedPath apis
2019-01-17 01:25:31 -05:00
Eugene Yokota d58cc75e39 IO 1.3.0-M5 2019-01-16 22:35:12 -05:00
Antonio Cunei 0b103c5701 Bump the 2.12 version to 2.12.8 in 1.2.x 2019-01-16 22:26:22 +01:00
Ethan Atkins 161dfd77f2 Update TypedPath apis
I renamed getPath to toPath in io so we need to update sbt to using the
correct api.
2019-01-16 13:22:56 -08:00
Ethan Atkins 48394c81d5
Merge pull request #4509 from eatkins/2.12.8
Bump scala version 2.12.8
2019-01-08 13:29:15 -08:00
Ethan Atkins 541d4047e6 Bump scala version 2.12.8
I ran a zsh one liner to generate this:
git grep "2.12.7" | cut -d ':' -f1 | sort | uniq | xargs perl -p -i -e "s/2.12.7/2.12.8/"
2019-01-08 11:11:23 -08:00
Ethan Atkins 78efa032f8
Merge pull request #4508 from eatkins/labeled-functions
Add LabeledFunctions to repo
2019-01-08 10:42:53 -08:00
Ethan Atkins 2b831e5988 Add LabeledFunctions to repo
I noticed that debugging settings that return functions is annoying
because often the setting is initialized as an anonymous function with a
useless toString method. To improve the debugging for users, I'm adding
a number of wrapper classes for functions that override the default
toString with a provided label.

I then used these functions to label all of the anonymous functions in
Watched.scala.
2019-01-08 09:45:06 -08:00
eugene yokota ed1200a763
Merge pull request #4497 from tdroxler/feature/preserve-error-order
Preserve errors order when publishing diagnostics
2019-01-04 10:48:01 -05:00
Eugene Yokota 68d0da379e add Mima exclusion 2019-01-04 09:55:28 -05:00