Skip to content

Commit

Permalink
Latest 3.1.x Merge (#3)
Browse files Browse the repository at this point in the history
* Drop the timer in Ultimately for an Executor

Change the behaviour of Ultimately to spawn a single daemon thread for
handling dispatching of futures.

* Move ulimately scheduler to object

* Added a type annotation for clarity in Ultimately and added a tolerance to an UltimatelySpec test to reduce the likelihood of flicker.

* Get NonEmptyArray and its tests to compile in scala 2.10.

* Removed the use of deprecated getStackTraceString in FuturesSpec.

* Enhanced README.md to include instruction to build and publish for Scala 2.13.

* Changed default scala version to 2.11.11.

* Fixed occasionally failing tests in PosIntSpec and PosZIntSpec when tests run under scala 2.10, which is caused by range size cannot be more than Int.MaxValue, added code to make sure the limit is not violated in the test.

* Fixed stack depth problem in RefSpecLike and fixture.SpecLike under Scala 2.12 and 2.13.

* Removed special treatment of validating method for scala 2.12.

* Extends special handle of Predef string printing to scala 2.13 in RequirementsSpec.scala.

* Extends special handle of Predef string printing to scala 2.13 in AssertionsSpec.scala.

* Make source compatible to build with Scala 2.10, 2.11, 2.12 and 2.13.0-M2.

Conflicts:

	project/build.properties
	project/plugins.sbt
	project/scalatest.scala

* Fixed failing tests in NegIntSpec, NegZIntSpec and NonZeroIntSpec when built under Scala 2.10.

* Fixed failing tests in PosIntSpec and PosZIntSpec when built under Scala 2.10.

* Make examples.js runnable by not copying examples that use java.io.File when generating examples.js.

* Make source compatible to build with Scala 2.10, 2.11, 2.12 and 2.13.0-M2.

* In travis, bumped up scala versions, removed jdk7 build, added add-on to install jdk6, make builds for scala 2.10 and 2.11 to use jdk6 and 2.12 to use jdk8.

* Added dist: trusty and change sudo value to required.

* Got the right set of external dependencies version to get genRegularTests5 passes.

* Got genRegularTests5 to work again.

* Increased stack size to 10M in travis_build.sh.

* Changed JVM_OPTS to SBT_OPTS in travis_build.sh.

* Added scala 2.13.0-M2 to travis build.

* Fixed genInspectorsShorthandsTests2 problem when runs under scala 2.13.0-M2.

* Added scala version to gentests shared settings.

* Make sure compile in travis is using 10M stack size.

* Rewritten time limited examples to be scala-js friendly.

* Changed back sudo to false in .travis.yml, trying to fix some test in the matrix failed before it started problem.

* Changed to use scala 2.12.4 as default scala version.

* Changed getJavaHome in build to throw error when Java 6 is not used to build for Scala 2.10 and 2.11.

* Updated .travis.yml and README.md to use scala 2.12.4.

* Commentted out SbtCommandParser, which we currently doesn't support, to get rid of combinator parser dependency that it brought in.

* Should exclude scala 2.12.4 not 2.12.3 in travis.

* Made scalactic and scalatest project to generate scala source directly under sourceManaged root, making them friendlier to IDE.

* Work in progress fixing sourceManaged problem for GenRegularTests.

* Fixed sourceManaged up to must matchers tests generators.

* Fixed sourceManaged problem for all generated tests.

* Completed fixing remaining projects for sourceManaged.

* Exclude Ultimately from scalatest-js.

* Adjusted command to run generated tests in README.md.
(cherry picked from commit 3803aae)

* Make generators to generate files only when necessary.
(cherry picked from commit 68d9c29)

Conflicts:

	project/GenTable.scala

* Made all test generators and scala-js generators to generate files only when necessary, completed this behavior now.
(cherry picked from commit a996db8)

* Fixed Tolerance related failing tests.
  • Loading branch information
cheeseng authored and shadaj committed Oct 29, 2017
1 parent 13d062f commit e68db71
Show file tree
Hide file tree
Showing 65 changed files with 2,798 additions and 2,174 deletions.
22 changes: 16 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
language: scala
scala:
- 2.11.8
- 2.10.6
- 2.12.0
- 2.11.11
- 2.12.4
- 2.13.0-M2
addons:
apt:
packages:
- openjdk-6-jdk

jdk:
- oraclejdk7
- openjdk6
- oraclejdk8

dist: trusty
sudo: false

env:
Expand Down Expand Up @@ -46,10 +52,14 @@ env:

matrix:
exclude:
- scala: "2.12.0"
jdk: oraclejdk7
- scala: "2.12.0"
- scala: "2.13.0-M2"
jdk: openjdk6
- scala: "2.12.4"
jdk: openjdk6
- scala: "2.11.11"
jdk: oraclejdk8
- scala: "2.10.6"
jdk: oraclejdk8

branches:
only:
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ This command will build and run the regular tests:

`$ sbt test`

To run generated all tests, you'll need to increase maximum heap size to -Xmx5000M, and use this command instead:
To run generated all tests, you'll need to increase maximum heap size to at least -Xmx5000M, and use this command instead:

`$ sbt gentests/test`
$ rm -rf gentests
$ sbt gentests/test

You can also run different groups generated tests separately:


$ rm -rf gentests
$ sbt genMustMatchersTests1/test
$ sbt genMustMatchersTests2/test
$ sbt genMustMatchersTests3/test
Expand All @@ -65,7 +67,6 @@ You can also run different groups generated tests separately:
$ sbt genSortedTests/test
$ sbt genLoneElementTests/test
$ sbt genEmptyTests/test
$ sbt genSafeStyleTests/test

What it does is simply switch to gentests project and run test.

Expand Down Expand Up @@ -118,8 +119,8 @@ With Sonatype credentials and GPG file in place, you can now publish to Sonatype

To publish scalactic, scalatest and scalatest-app (for Scala and Scala-js, version 2.11 and 2.10, and make sure you're on Java 6) to Sonatype, use the following command:

`$ sbt clean publishSigned "project scalatestAppJS" clean publishSigned ++2.10.6 "project scalatestApp" clean publishSigned "project scalatestAppJS" clean publishSigned`
`$ sbt clean publishSigned ++2.11.11 "project scalatestAppJS" clean publishSigned ++2.10.6 "project scalatestApp" clean publishSigned "project scalatestAppJS" clean publishSigned`

To publish scalactic, scalatest and scalatest-app (for Scala and Scala-js, version 2.12, and make sure you're on Java 8) to Sonatype, use the following command:
To publish scalactic, scalatest and scalatest-app (for Scala and Scala-js, version 2.12 and 2.13, and make sure you're on Java 8) to Sonatype, use the following command:

`$ sbt ++2.12.0 clean publishSigned "project scalatestAppJS" clean publishSigned`
`$ sbt clean publishSigned "project scalatestAppJS" clean publishSigned ++2.13.0-M2 clean publishSigned "project scalatestAppJS" clean publishSigned`
20 changes: 20 additions & 0 deletions common-test/src/main/scala/org/scalatest/CompatParColls.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.scalatest

/**
* This compatibility workaround is taken from https://github.com/scala/scala-parallel-collections/issues/22
*/
private[org] object CompatParColls {
val Converters = {
import Compat._

{
import scala.collection.parallel._

CollectionConverters
}
}

object Compat {
object CollectionConverters
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import org.scalatest.AsyncFunSpec
import org.scalatest.concurrent.AsyncTimeLimitedTests
import org.scalatest.time.SpanSugar._

import scala.concurrent.Future

class ExampleSpec extends AsyncFunSpec with AsyncTimeLimitedTests {

// Note: You may need to either write 200.millis or (200 millis), or
Expand All @@ -28,12 +30,32 @@ class ExampleSpec extends AsyncFunSpec with AsyncTimeLimitedTests {

describe("An asynchronous time-limited test") {
it("should succeed if it completes within the time limit") {
Thread.sleep(100)
succeed
Future {
// Your code should run here, the following is just an example
// code of filling a buffer and assert its content that should
// not take more than 200 millis
val buffer = new StringBuilder
buffer.append("test")
assert(buffer.toString == "test")
}
}
it("should fail if it is taking too darn long") {
Thread.sleep(300)
succeed
Future {
// Your code should run here, the following is just an example
// code of filling buffer in loop that will take more than 200 millis
val startTime = scala.compat.Platform.currentTime
var stop = false
val buffer = new StringBuilder
while (!stop) {
for (i <- 1 to 100)
buffer.append(i.toString)
if ((scala.compat.Platform.currentTime - startTime) > 200)
stop = true
else
buffer.clear()
}
assert(buffer.length == 5050)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,28 @@ class ExampleSignalerSpec extends FunSpec with TimeLimitedTests {

describe("A time-limited test") {
it("should succeed if it completes within the time limit") {
Thread.sleep(100)
// Your code should run here, the following is just an example
// code of filling a buffer and assert its content that should
// not take more than 200 millis
val buffer = new StringBuilder
buffer.append("test")
assert(buffer.toString == "test")
}
it("should fail if it is taking too darn long") {
Thread.sleep(300)
// Your code should run here, the following is just an example
// code of filling buffer in loop that will take more than 200 millis
val startTime = scala.compat.Platform.currentTime
var stop = false
val buffer = new StringBuilder
while (!stop) {
for (i <- 1 to 100)
buffer.append(i.toString)
if ((scala.compat.Platform.currentTime - startTime) > 200)
stop = true
else
buffer.clear()
}
assert(buffer.length == 5050)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,28 @@ class ExampleSpec extends FunSpec with TimeLimitedTests {

describe("A time-limited test") {
it("should succeed if it completes within the time limit") {
Thread.sleep(100)
// Your code should run here, the following is just an example
// code of filling a buffer and assert its content that should
// not take more than 200 millis
val buffer = new StringBuilder
buffer.append("test")
assert(buffer.toString == "test")
}
it("should fail if it is taking too darn long") {
Thread.sleep(300)
// Your code should run here, the following is just an example
// code of filling buffer in loop that will take more than 200 millis
val startTime = scala.compat.Platform.currentTime
var stop = false
val buffer = new StringBuilder
while (!stop) {
for (i <- 1 to 100)
buffer.append(i.toString)
if ((scala.compat.Platform.currentTime - startTime) > 200)
stop = true
else
buffer.clear()
}
assert(buffer.length == 5050)
}
}
}
6 changes: 5 additions & 1 deletion project/GenCommonTestJS.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ object GenCommonTestJS {
files.map { sourceFileName =>
val sourceFile = new File(sourceDir, sourceFileName)
val destFile = new File(packageDir, sourceFile.getName)
copyFile(sourceFile, destFile)
if (!destFile.exists || sourceFile.lastModified > destFile.lastModified) {
copyFile(sourceFile, destFile)
}

destFile
}
}

Expand Down
3 changes: 2 additions & 1 deletion project/GenCommonTestNative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ object GenCommonTestNative {
"BookPropertyMatchers.scala",
"EmptyMocks.scala",
"FileMocks.scala",
"StringFixture.scala"
"StringFixture.scala",
"CompatParColls.scala"
), targetDir) ++
copyDir("common-test/src/main/scala/org/scalatest/path", "org/scalatest/path",
List("ExampleLikeSpecs.scala"), targetDir)
Expand Down
90 changes: 50 additions & 40 deletions project/GenCompatibleClasses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import java.io.{FileWriter, BufferedWriter, File}

object GenCompatibleClasses {

def genMain(targetDir: File, version: String, scalaVersion: String) {
val generatorSource = new File("GenCompatibleClasses.scala")

def genMain(targetDir: File, version: String, scalaVersion: String): Seq[File] = {
targetDir.mkdirs()
val listCellRendererClass = Class.forName("javax.swing.ListCellRenderer")
val isJava7 = listCellRendererClass.getTypeParameters.length > 0
Expand All @@ -13,56 +15,64 @@ object GenCompatibleClasses {
"EventHolderDefaultListModel" -> "private[tools] class EventHolderDefaultListModel extends DefaultListModel"
)

java6Classes.foreach { case (name, cls) =>
val file = new File(targetDir, name + ".scala")
val java6ClassesFiles =
java6Classes.map { case (name, cls) =>
val file = new File(targetDir, name + ".scala")
if (!file.exists || generatorSource.lastModified > file.lastModified) {
val bw = new BufferedWriter(new FileWriter(file))
try {
bw.write("package org.scalatest.tools\n")
bw.write("import javax.swing._\n")
if (isJava7)
bw.write(cls + "[EventHolder]")
else
bw.write(cls)
}
finally {
bw.flush()
bw.close()
}
println("Generated " + file.getAbsolutePath)
}
file
}

val file = new File(targetDir, "EventHolderListCellRenderer.scala")
if (!file.exists || generatorSource.lastModified > file.lastModified) {
val bw = new BufferedWriter(new FileWriter(file))

try {
bw.write("package org.scalatest.tools\n")
bw.write("import java.awt.Component\n")
bw.write("import javax.swing._\n")
if (isJava7)
bw.write(cls + "[EventHolder]")
else
bw.write(cls)
if (isJava7) { // workaround from http://www.scala-lang.org/old/node/10687
bw.write("private[tools] trait EventHolderListCellRenderer extends ListCellRenderer[EventHolder] {\n")
bw.write(" private val defaultRenderer: ListCellRenderer[EventHolder] = (new DefaultListCellRenderer()).asInstanceOf[ListCellRenderer[EventHolder]]\n")
bw.write(" protected def decorate(renderer: JLabel, value: Object, isSelected: Boolean): Component\n")
bw.write(" def getListCellRendererComponent(list: JList[_ <: EventHolder], value: EventHolder, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component = {\n")
bw.write(" val renderer: JLabel = defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus).asInstanceOf[JLabel]\n")
bw.write(" decorate(renderer, value, isSelected)\n")
bw.write(" }")
bw.write("}\n")
}
else {
bw.write("private[tools] trait EventHolderListCellRenderer extends ListCellRenderer {\n")
bw.write(" private val defaultRenderer: DefaultListCellRenderer = new DefaultListCellRenderer()\n")
bw.write(" protected def decorate(renderer: JLabel, value: Object, isSelected: Boolean): Component\n")
bw.write(" def getListCellRendererComponent(list: JList, value: Object, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component = {\n")
bw.write(" val renderer: JLabel = defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus).asInstanceOf[JLabel]\n")
bw.write(" decorate(renderer, value, isSelected)\n")
bw.write(" }")
bw.write("}\n")
}
}
finally {
bw.flush()
bw.close()
}
println("Generated " + file.getAbsolutePath)
}

val file = new File(targetDir, "EventHolderListCellRenderer.scala")
val bw = new BufferedWriter(new FileWriter(file))

try {
bw.write("package org.scalatest.tools\n")
bw.write("import java.awt.Component\n")
bw.write("import javax.swing._\n")
if (isJava7) { // workaround from http://www.scala-lang.org/old/node/10687
bw.write("private[tools] trait EventHolderListCellRenderer extends ListCellRenderer[EventHolder] {\n")
bw.write(" private val defaultRenderer: ListCellRenderer[EventHolder] = (new DefaultListCellRenderer()).asInstanceOf[ListCellRenderer[EventHolder]]\n")
bw.write(" protected def decorate(renderer: JLabel, value: Object, isSelected: Boolean): Component\n")
bw.write(" def getListCellRendererComponent(list: JList[_ <: EventHolder], value: EventHolder, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component = {\n")
bw.write(" val renderer: JLabel = defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus).asInstanceOf[JLabel]\n")
bw.write(" decorate(renderer, value, isSelected)\n")
bw.write(" }")
bw.write("}\n")
}
else {
bw.write("private[tools] trait EventHolderListCellRenderer extends ListCellRenderer {\n")
bw.write(" private val defaultRenderer: DefaultListCellRenderer = new DefaultListCellRenderer()\n")
bw.write(" protected def decorate(renderer: JLabel, value: Object, isSelected: Boolean): Component\n")
bw.write(" def getListCellRendererComponent(list: JList, value: Object, index: Int, isSelected: Boolean, cellHasFocus: Boolean): Component = {\n")
bw.write(" val renderer: JLabel = defaultRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus).asInstanceOf[JLabel]\n")
bw.write(" decorate(renderer, value, isSelected)\n")
bw.write(" }")
bw.write("}\n")
}
}
finally {
bw.flush()
bw.close()
}
java6ClassesFiles.toSeq ++ Seq(file)
}

def main(args: Array[String]) {
Expand Down
Loading

0 comments on commit e68db71

Please sign in to comment.