Skip to content

Commit 518c559

Browse files
committed
Merge branch 'cheeseng-3.1.x-cherry-pick-20171024' into 3.1.x
2 parents b6350f2 + 8a88f88 commit 518c559

31 files changed

+1523
-1171
lines changed

.travis.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
language: scala
22
scala:
3-
- 2.11.8
43
- 2.10.6
5-
- 2.12.0
4+
- 2.11.11
5+
- 2.12.4
6+
- 2.13.0-M2
7+
addons:
8+
apt:
9+
packages:
10+
- openjdk-6-jdk
11+
612
jdk:
7-
- oraclejdk7
813
- openjdk6
914
- oraclejdk8
1015

16+
dist: trusty
1117
sudo: false
1218

1319
env:
@@ -46,10 +52,14 @@ env:
4652

4753
matrix:
4854
exclude:
49-
- scala: "2.12.0"
50-
jdk: oraclejdk7
51-
- scala: "2.12.0"
55+
- scala: "2.13.0-M2"
56+
jdk: openjdk6
57+
- scala: "2.12.4"
5258
jdk: openjdk6
59+
- scala: "2.11.11"
60+
jdk: oraclejdk8
61+
- scala: "2.10.6"
62+
jdk: oraclejdk8
5363

5464
branches:
5565
only:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ With Sonatype credentials and GPG file in place, you can now publish to Sonatype
118118

119119
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:
120120

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

123123
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:
124124

125-
`$ sbt ++2.12.0 clean publishSigned "project scalatestAppJS" clean publishSigned ++2.13.0-M2 clean publishSigned "project scalatestAppJS" clean publishSigned`
125+
`$ sbt clean publishSigned "project scalatestAppJS" clean publishSigned ++2.13.0-M2 clean publishSigned "project scalatestAppJS" clean publishSigned`

examples/src/test/scala/org/scalatest/examples/asynctimelimitedtests/ExampleSpec.scala

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import org.scalatest.AsyncFunSpec
1919
import org.scalatest.concurrent.AsyncTimeLimitedTests
2020
import org.scalatest.time.SpanSugar._
2121

22+
import scala.concurrent.Future
23+
2224
class ExampleSpec extends AsyncFunSpec with AsyncTimeLimitedTests {
2325

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

2931
describe("An asynchronous time-limited test") {
3032
it("should succeed if it completes within the time limit") {
31-
Thread.sleep(100)
32-
succeed
33+
Future {
34+
// Your code should run here, the following is just an example
35+
// code of filling a buffer and assert its content that should
36+
// not take more than 200 millis
37+
val buffer = new StringBuilder
38+
buffer.append("test")
39+
assert(buffer.toString == "test")
40+
}
3341
}
3442
it("should fail if it is taking too darn long") {
35-
Thread.sleep(300)
36-
succeed
43+
Future {
44+
// Your code should run here, the following is just an example
45+
// code of filling buffer in loop that will take more than 200 millis
46+
val startTime = scala.compat.Platform.currentTime
47+
var stop = false
48+
val buffer = new StringBuilder
49+
while (!stop) {
50+
for (i <- 1 to 100)
51+
buffer.append(i.toString)
52+
if ((scala.compat.Platform.currentTime - startTime) > 200)
53+
stop = true
54+
else
55+
buffer.clear()
56+
}
57+
assert(buffer.length == 5050)
58+
}
3759
}
3860
}
3961
}

examples/src/test/scala/org/scalatest/examples/timelimitedtests/ExampleSignalerSpec.scala

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,28 @@ class ExampleSignalerSpec extends FunSpec with TimeLimitedTests {
2727

2828
describe("A time-limited test") {
2929
it("should succeed if it completes within the time limit") {
30-
Thread.sleep(100)
30+
// Your code should run here, the following is just an example
31+
// code of filling a buffer and assert its content that should
32+
// not take more than 200 millis
33+
val buffer = new StringBuilder
34+
buffer.append("test")
35+
assert(buffer.toString == "test")
3136
}
3237
it("should fail if it is taking too darn long") {
33-
Thread.sleep(300)
38+
// Your code should run here, the following is just an example
39+
// code of filling buffer in loop that will take more than 200 millis
40+
val startTime = scala.compat.Platform.currentTime
41+
var stop = false
42+
val buffer = new StringBuilder
43+
while (!stop) {
44+
for (i <- 1 to 100)
45+
buffer.append(i.toString)
46+
if ((scala.compat.Platform.currentTime - startTime) > 200)
47+
stop = true
48+
else
49+
buffer.clear()
50+
}
51+
assert(buffer.length == 5050)
3452
}
3553
}
3654
}

examples/src/test/scala/org/scalatest/examples/timelimitedtests/ExampleSpec.scala

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,28 @@ class ExampleSpec extends FunSpec with TimeLimitedTests {
2828

2929
describe("A time-limited test") {
3030
it("should succeed if it completes within the time limit") {
31-
Thread.sleep(100)
31+
// Your code should run here, the following is just an example
32+
// code of filling a buffer and assert its content that should
33+
// not take more than 200 millis
34+
val buffer = new StringBuilder
35+
buffer.append("test")
36+
assert(buffer.toString == "test")
3237
}
3338
it("should fail if it is taking too darn long") {
34-
Thread.sleep(300)
39+
// Your code should run here, the following is just an example
40+
// code of filling buffer in loop that will take more than 200 millis
41+
val startTime = scala.compat.Platform.currentTime
42+
var stop = false
43+
val buffer = new StringBuilder
44+
while (!stop) {
45+
for (i <- 1 to 100)
46+
buffer.append(i.toString)
47+
if ((scala.compat.Platform.currentTime - startTime) > 200)
48+
stop = true
49+
else
50+
buffer.clear()
51+
}
52+
assert(buffer.length == 5050)
3553
}
3654
}
3755
}

project/GenCompatibleClasses.scala

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import java.io.{FileWriter, BufferedWriter, File}
22

33
object GenCompatibleClasses {
44

5-
def genMain(targetDir: File, version: String, scalaVersion: String) {
5+
def genMain(targetDir: File, version: String, scalaVersion: String): Seq[File] = {
66
targetDir.mkdirs()
77
val listCellRendererClass = Class.forName("javax.swing.ListCellRenderer")
88
val isJava7 = listCellRendererClass.getTypeParameters.length > 0
@@ -13,23 +13,25 @@ object GenCompatibleClasses {
1313
"EventHolderDefaultListModel" -> "private[tools] class EventHolderDefaultListModel extends DefaultListModel"
1414
)
1515

16-
java6Classes.foreach { case (name, cls) =>
17-
val file = new File(targetDir, name + ".scala")
18-
val bw = new BufferedWriter(new FileWriter(file))
19-
try {
20-
bw.write("package org.scalatest.tools\n")
21-
bw.write("import javax.swing._\n")
22-
if (isJava7)
23-
bw.write(cls + "[EventHolder]")
24-
else
25-
bw.write(cls)
16+
val java6ClassesFiles =
17+
java6Classes.map { case (name, cls) =>
18+
val file = new File(targetDir, name + ".scala")
19+
val bw = new BufferedWriter(new FileWriter(file))
20+
try {
21+
bw.write("package org.scalatest.tools\n")
22+
bw.write("import javax.swing._\n")
23+
if (isJava7)
24+
bw.write(cls + "[EventHolder]")
25+
else
26+
bw.write(cls)
27+
}
28+
finally {
29+
bw.flush()
30+
bw.close()
31+
}
32+
println("Generated " + file.getAbsolutePath)
33+
file
2634
}
27-
finally {
28-
bw.flush()
29-
bw.close()
30-
}
31-
println("Generated " + file.getAbsolutePath)
32-
}
3335

3436
val file = new File(targetDir, "EventHolderListCellRenderer.scala")
3537
val bw = new BufferedWriter(new FileWriter(file))
@@ -63,6 +65,8 @@ object GenCompatibleClasses {
6365
bw.flush()
6466
bw.close()
6567
}
68+
69+
java6ClassesFiles.toSeq ++ Seq(file)
6670
}
6771

6872
def main(args: Array[String]) {

0 commit comments

Comments
 (0)