Commit Graph

193 Commits

Author SHA1 Message Date
Eugene Yokota 1e157b991a apply formatting 2019-04-20 03:23:54 -04:00
Ethan Atkins 8ef5a67b64 Add better error message if run fails
It is possible with the new layering strategies that tests may fail if a
java package private class is accessed across classloader layers. This
will result in an IllegalAccessError that is hard to debug. With this
commit, I add an error message that will be displayed if run throws an
IllegalAccessError that suggests that the user try the
ScalaInstance layering strategy or the flat layering strategy.
2019-04-02 20:53:37 -07: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 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 6725b39a84 Bump io to 1.3.0-M3
I had to turn off -Xfatal-warnings in commandProj because after updating
io, commandProj depends on the deprecated EventMonitor class. In #4335,
I stop using EventMonitor, but deprecate the Watched class which is both
defined and used (as an unused attribute key) in commandProj. I think we
can probably get rid of Watched in 1.4.x and certainly in a hypothetical
2.x, so hopefully we can restore -Xfatal-warnings sooner than later.

I also had to replace uses of IO.classLocationFile with
IO.classLocationPath to avoid compilation failures due to
-Xfatal-warnings.
2018-10-08 13:59:34 -07:00
Eugene Yokota ef49a95b7d address more warnings 2018-09-18 17:45:24 -04:00
Eugene Yokota 4b23036c63 contraband 0.4.1 2018-09-18 16:56:19 -04:00
eugene yokota 8af7a5acae
Merge pull request #4358 from eed3si9n/wip/license
Apache License 2.0
2018-09-14 11:11:17 -04:00
Eugene Yokota 4ff4f6e45e Update header 2018-09-14 04:53:36 -04:00
Eugene Yokota f3424e265c Formatting 2018-09-14 00:59:01 -04:00
Ignasi Marimon-Clos 66b485f559 Duplicate reports for backwards-compat adding a name-compliant copy 2018-09-04 18:15:30 +02:00
xuwei-k 6936ca024e use Java 7 and 8 features
- diamond operator
- lambda
2018-07-08 22:32:26 +09:00
Daniel Riquelme aee10cf036 Fix CTRL-C exception 2018-06-22 05:04:30 -04:00
Ethan Atkins 27e93601b5 Add warning for slow hostname lookups on OS X
I spent a lot of time debugging why it took 5 seconds to run tests each
time. It turns out that if the hostname is not set explicitly on os x,
then getaddrinfo takes 5 seconds to try (and fail) to resolve the dns
entry for the localhostname. This is easily fixed by setting the
hostname, but it is not at all easy to figure out that a slow hostname
lookup is the reason why tests are slow to start.

I don't know if this is a common issue on other platforms, so only issue
the warning on OS X.
2018-06-06 10:53:46 -07:00
Tim Harper 5cc0038a65 Little better comment. Add timestamp to example. 2018-05-14 20:57:04 -06:00
Tim Harper 3702132019 Keep single parameter constructor for backwards bin compat. 2018-05-14 17:31:05 -06:00
Tim Harper 13085138a5 Remove milliseconds from format in order to comply with JUnit spec 2018-05-14 17:30:15 -06:00
Tim Harper add6bde396 Add timestamp field to JUnitXML report 2018-05-14 12:42:24 -06:00
Eugene Yokota 28e90ea09b Merge branch '1.1.x' into wip/merge-1.1.x 2018-04-29 14:31:30 -04:00
Dale Wijnand 8f4b8abb7b
Run scalafmt & test:scalafmt 2018-04-24 16:12:10 +01:00
OlegYch eeeb4c9ff2 Remove usage of DynamicVariable and fix memory leak, fixes https://github.com/sbt/sbt/issues/4112 2018-04-23 20:46:08 +03:00
Eugene Yokota c2837c7714 Merge branch 'wip/bumpsbt' into wip/merge-1.1.x 2018-03-27 10:16:10 -04:00
Ethan Atkins 9b24e9f9eb Use ConcurrentLinkedDeque for EventHandler
ArrayList::add is not thread safe. I ran into cases where async tests
using utests would fail even when all of the individual tests passed.
This was because multiple threads called back into the handle method of
the handler instance variable, which just delegated to eventList::add.
When this happened, one of the events would get added to the list as a
null reference, which would manifest as an NPE upstream on the master
process. After this change, my tests stopped failing.
2018-03-21 10:50:30 -07:00
Dale Wijnand dd4de14593
Upgrade to contraband 0.4.0 2018-03-12 15:39:07 +00:00
eugene yokota 92c95ce290
Merge pull request #3997 from eed3si9n/wip/test-status-thread-safety
Fix race condition in non-forked, parallel tests.
2018-03-07 16:18:55 -05:00
Jason Zaugg 0bea7e9e18 Fix race condition in non-forked, parallel tests.
Non forked tests that are run in parallel groups can call into
a single instance of TestStatusReporter concurrently.

This seems to be limited to the startGroup/endGroup/testEvent
methods called in:

  a41727fb17/testing/src/main/scala/sbt/TestFramework.scala (L100-L124)

Which itself is called within:

  a41727fb17/testing/src/main/scala/sbt/TestFramework.scala (L203-L229)

Creating the `runnables` that are run in parallel (in builds so configured):

  a6eb1260c8/main-actions/src/main/scala/sbt/Tests.scala (L222-L230)

We believe this to be the cause of the hang witnessed in
the a suite of Scalacheck-framework tests in the Scala
build:

  https://github.com/scala/scala-jenkins-infra/issues/249

This commit uses a concurrent map to support concurrent
status updates.
2018-03-05 18:23:03 +10:00
Dale Wijnand 113656aed1
Remove compile warnings 2018-01-16 11:17:01 +00:00
eugene yokota 34d311f9ce
Merge pull request #3807 from dwijnand/remove-warnings
Remove warnings
2017-12-19 13:18:59 -05:00
Eugene Yokota 40b86ae412 bump modules and plugins 2017-12-16 12:22:42 -05:00
Dale Wijnand 072366d48e
Remove all warnings from testingProj 2017-12-14 13:19:23 +00:00
Simon Schäfer 93e08b7ee7 Fix warnings about unused pattern vars in various projects 2017-10-19 13:07:24 +02:00
Dale Wijnand a41727fb17
Add, configure & enforce file headers 2017-10-05 09:03:40 +01:00
Răzvan Flavius Panda 0124a8ad0e Fix unused imports warnings 2017-09-15 16:35:08 +01:00
Dale Wijnand 4f0d2f9ffd
Scalafmt 1.2.0 2017-08-14 15:47:52 +01:00
Eugene Yokota 00a9dd14a4 Bump Contraband to latest 2017-07-17 01:05:30 -04:00
Eugene Yokota efa3b1d340
Bump to latest io, scalajson, sjsonnew, contraband, util, lm, zinc 2017-07-06 11:05:24 +01:00
Eugene Yokota f81598c6e9 Fixes test content logger dropping out, or displaying twice
Fixes #3117
2017-06-20 03:04:53 -04:00
Dale Wijnand a08a84145b
Drop test spam.
Fixes #3116
2017-06-13 12:35:27 +01:00
Dale Wijnand 33212d2331
Cleanup test logging related code 2017-06-13 12:34:59 +01:00
James Koch fe72a6e11d Issue #3154 - ScalaTest nested suites reported in JUnit XML reports as "(It is not a test)". 2017-05-27 00:18:40 -04:00
Eugene Yokota 2b5637270a update TestFramework
- update reset.sh for debugging
- use Vector around TestFramework
- unbind existing appdenders from newLog
- register string codec for TestStringEvent
2017-05-19 00:16:19 -04:00
eugene yokota d3ff3fb63a migrate PluginTrigger and ProjectOrigin to Contraband (#3191)
and move TestFramework to a non case class.
2017-05-13 13:01:51 +01:00
Eugene Yokota da046791e0 Apply Scalafmt formatting 2017-04-21 04:48:31 -04:00
Eugene Yokota 304d167813 Send ObjectEvent as JSON 2017-04-03 03:17:57 -04:00
Eugene Yokota 093fc061cc Send testing events to logger 2017-04-01 17:19:45 -04:00
xuwei-k 5b00e7326b s/newInstance/getDeclaredConstructor().newInstance()
java.lang.Class#newInstance deprecated since Java 9

http://download.java.net/java/jdk9/docs/api/java/lang/Class.html#newInstance--

```
Deprecated. This method propagates any exception thrown by the nullary constructor, including a checked exception. Use of this method effectively bypasses the compile-time exception checking that would otherwise be performed by the compiler. The Constructor.newInstance method avoids this problem by wrapping any exception thrown by the constructor in a (checked) InvocationTargetException.
The call

 clazz.newInstance()

can be replaced by

 clazz.getDeclaredConstructor().newInstance()

The latter sequence of calls is inferred to be able to throw the additional exception types InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.
Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized.
```
2017-03-15 11:53:49 +09:00
Dale Wijnand 43821667bf
Upgrade scalariform version 2016-12-11 12:13:11 +00:00
Ashley Mercer f92a0ab8a5 JUnitXmlTestsListener now correctly flags ignored, skipped and pending tests
Fixes #2198 Ref #2854

Generated Junit-style XML reports now include a count of ignored,
skipped and pending tests; and individual tests are correctly flagged
with the <skipped/> element.
2016-12-01 10:45:13 +00:00
xuwei-k 857fc0f5da use JavaConverters instead of JavaConversions
- https://issues.scala-lang.org/browse/SI-9684
- 0c5b42d974
2016-08-30 01:31:04 +09:00
Dale Wijnand deea82542c Remove unused imports 2016-07-12 11:55:10 +01:00
Dale Wijnand 12c2734052 Pattern match some if/else's 2016-07-07 18:21:25 +01:00
Dale Wijnand 32760bed55 Remove some fatal exception catching 2016-07-07 18:21:25 +01:00
Dale Wijnand d77e769635 Cleanup testAgentProj 2016-07-07 01:40:01 +01:00
Dale Wijnand 824df04699 Cleanup testingProj 2016-06-21 08:09:29 +01:00
Dale Wijnand 15d4527479 Kill trailing dead code 2016-06-21 08:09:29 +01:00
Martin Duhem a2abb6eeb6 Update to latest version of incremental, fix imports 2015-09-16 10:16:03 +02:00
Martin Duhem c981abd295 Fix all imports 2015-09-14 14:28:09 +02:00
Pierre DAL-PRA 54d54b9f4f Replace procedure syntax by explicit Unit annotation 2015-08-04 10:07:38 +02:00
Kamil Kloch cd3af2f0cd Updated ForkError.getMessage() to include exception's original name. 2015-05-25 13:50:56 +02:00
Allan Erskine 24d2a2024b Fixes #1881. Clone SystemProperties defending against ConcurrentModificationException 2015-02-28 23:46:02 -05:00
Jean-Rémi Desjardins ca736e55d3 Minor code cleanup 2014-12-03 09:56:34 -08:00
Josh Suereth d2950da9dd Fix issue where ScalaInstance broke the thread-context-classloader for all scala classes.
The issue is that when you manually set a ScalaInstance, i.e. not one from Ivy, the
classpath which is returned for any given configuration ONLY uses Ivy.   This means that
the legitimate Scala JAR files that need to be on the classpath are missing from the list.
For some reason, the way we instantiate tests uses an unfiltered classloader against the
ScalaInstance, *BUT* the thread-context-classloader DOES use a filtered instance by
classpath.   This add the hook into the TestFramework runner creation so that
the classpath accurately reflects the jars needed.

cc @rkuhn
2014-09-09 08:56:51 -04:00
Eugene Yokota 482bdc1b77 scalariform changes 2014-08-15 01:52:31 -04:00
Josh Suereth 666819e707 Fix unknown host exception in junit xml listener.
Fixes #1506
2014-08-08 13:03:01 -04:00
Josh Suereth ef70d84323 Fixes #1306 - Attempt to turn test suite names into better filenames. 2014-08-01 17:14:00 -04:00
Peter Vlugter f7fbdb0281 Select the first test fingerprint for a test name for forked tests
Move the 'distinct by name' filter to Tests.processOptions, which is used
by both in-process and forked tests.
2014-07-14 11:57:52 +12:00
Josh Suereth 4c2d88649e Fix formatting issues and bump to sbt 0.13.5 2014-05-28 09:12:55 -04:00
Josh Suereth 89091ca4fc Merge remote-tracking branch 'origin/0.13.5' into wip/fix-doc-generation
Conflicts:
	project/Sbt.scala
2014-05-28 09:09:51 -04:00
Josh Suereth b69a273f37 Fix import issues to generate sxr/scaladoc. 2014-05-28 08:55:29 -04:00
cheeseng 83af01b88a Changed to combine SuiteResult with same name, instead of replacing with latest one. This solves the test result count problem when a Suite is executed more than 1 time due to being returned as nested suites (sub-task). 2014-05-22 17:28:26 +08:00
xuwei-k 25b22f951a remove unnecessary var 2014-05-03 06:01:13 +09:00
Eugene Yokota adb41611cf added scalariform 2014-05-01 12:50:07 -04:00
Bruno Bieth b38b86add5 Added a test reporter for JUnit XML
Taken from https://github.com/chenkelmann/junit_xml_listener and slightly improved.
Activating is now just a matter of setting `testReportJUnitXml` to true.
This not only brings a very handy feature (hudson/jenkins support that syntax),
but gives more options for testing the SBT test infrastructure.
For instance checking that the test output is well segregated during a parallel
test run is just a matter of checking the report output.

Conflicts:
	main/src/main/scala/sbt/Keys.scala
2014-04-22 08:36:52 -04:00
Josh Suereth 0a8d844071 Fix merge conflicts in pulling doc fixes from 0.13.1 into 0.13 branch. 2014-03-06 10:10:38 -05:00
Bruno Bieth 5a88bd2302 Third draft to execute the forked tests in parallel.
This feature is not activated by default. To enable it set `testForkedParallel` to `true`.

The test-agent then executes the tests in a thread pool.
For now it has a fixed size set to the number of available processors.
The concurrent restrictions configuration should be used.
2013-11-21 08:20:43 -05:00
Mark Harrah c5120636e4 Continuation of previous commit's workaround for #937: close test streams early 2013-11-04 13:10:06 -05:00
James Roper b337f3d9ac Flush ObjectOutputStreams after construction
This protects against deadlocks between the writing and reading end,
since the ObjectOutputStream constructor writes a header, but does not
flush, and the ObjectInputStream constructor reads the header, and
blocks until it's read.
2013-11-01 13:26:07 -04:00
Mark Harrah bedc129d0e remove dead code in TestFramework 2013-10-11 18:48:48 -04:00
Mark Harrah 277813dd0a Improve forked test debugging by listing tests run by sbt. Fixes #868.
This helps diagnosing issues on the sbt/framework border by verifying
that sbt is properly collecting and invoking tests.
2013-10-03 10:57:00 -04:00
Mark Harrah a0e301e3d8 Pick the first test fingerprint for a given suite/class name. Fixes #827.
This drops older code that picked a single fingerprint within a framework.
This commit ensures only one name is executed across all frameworks.
The precedence is the order that frameworks are declared in Defaults.scala.
JUnit should be last because it is common for specs tests to be annotated
  with @RunWith for Eclipse support.  If a distinct fingerprint is not
  picked, the test will be run by both specs and JUnit.
In addition to this main reason, result processing code assumes one result
  per test class name and would have to be fixed if multiple fingerprints
  were allowed.
2013-07-25 17:36:11 -04:00
Mark Harrah 45677de789 test arguments no longer need to be passed throughout- they are now only used in Runner construction 2013-07-11 21:13:06 -04:00
Mark Harrah ef4ce0f789 Deleted unused discovered test parser/printer 2013-07-09 14:55:30 -04:00
Mark Harrah ccff43ce8c API docs and cleanup for test configuration data structures 2013-07-08 09:14:19 -04:00
Mark Harrah a1a00526ff properly wrap unknown test data structures in serializable ones 2013-06-28 12:12:58 -04:00
Mark Harrah 3e74b92bf8 TestFingerprintWrapper no longer necessary 2013-06-28 11:18:17 -04:00
Mark Harrah 301c11f9e0 Drop ForkTestDefinition in favor of TaskDef 2013-06-28 09:24:47 -04:00
Mark Harrah ba28e5b505 not necessary to rewrap TaskDef in FrameworkWrapper.createTask 2013-06-28 09:24:33 -04:00
Mark Harrah 019920c138 duration() is specified to return -1 when none exists 2013-06-28 09:09:46 -04:00
cheeseng 6d4e51386f Added Specs2 new implementation class name. 2013-06-28 18:04:08 +08:00
cheeseng 86f47bd67d Added explicitlySpecified and selectors field to ForkTestDefinition, and change ForkMain to use explicitlySpecified and selectors value sent from ForkTests. 2013-06-28 17:45:13 +08:00
cheeseng 0c66d1a5d3 Added support of Ignore, Canceled and Pending added in the latest framework API. 2013-06-28 17:19:27 +08:00
cheeseng 5bb46359b5 Change to use test-interface-1.0-SNAP7, and use ScalaTest 2.0.M6-SNAP26 which implemented test-interface-1.0-SNAP7. 2013-06-28 17:18:38 +08:00
cheeseng a920c739d6 Added support of nested test tasks when tests are executed in SubProcess. 2013-04-25 00:06:52 +08:00
cheeseng 3109912d00 Added support of nested test tasks when tests are executed InProcess and sequentially. 2013-04-25 00:06:52 +08:00
cheeseng ad18b4f3ae Added code to tag test task using Array[String] returned from Task.tags method. 2013-04-25 00:06:51 +08:00
cheeseng 1ec2118219 -Moved code that count test results from TestLogger to SuiteResult.
-Print the results in Tests.showResult.
2013-04-25 00:06:41 +08:00
cheeseng a76523a5f6 Added >1 framework class per framework support, this enables sbt to support both old and new framework API at the same time. 2013-04-23 12:00:05 +08:00
cheeseng f38a244d0f Added code to call Runner's done() method in both InProcess and SubProcess cases. 2013-04-23 12:00:03 +08:00
cheeseng 244e65cd79 -Changed behavior so that only a single Runner instance is used to run tests in multiple test groups.
-Added code to support remoteArgs in test-interface 1.0.
2013-04-23 11:09:50 +08:00