Skip to content

Commit 7301c53

Browse files
committed
Merge branch 'cheeseng-feature-ssr-tsr-enhancements' into 3.1.x
2 parents c3a966e + 1d7c406 commit 7301c53

File tree

15 files changed

+414
-254
lines changed

15 files changed

+414
-254
lines changed

common-test.js/src/main/scala/org/scalatest/TestConcurrentDistributor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.scalatest
22

33
import _root_.org.scalatest.tools.SuiteRunner
44

5-
class TestConcurrentDistributor(poolSize: Int) extends Distributor {
5+
class TestConcurrentDistributor extends Distributor {
66
def apply(suite: Suite, tracker: Tracker) {
77
throw new UnsupportedOperationException("Please use apply with args.")
88
}

common-test.native/src/main/scala/org/scalatest/TestConcurrentDistributor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.scalatest
22

33
import _root_.org.scalatest.tools.SuiteRunner
44

5-
class TestConcurrentDistributor(poolSize: Int) extends Distributor {
5+
class TestConcurrentDistributor extends Distributor {
66
def apply(suite: Suite, tracker: Tracker) {
77
throw new UnsupportedOperationException("Please use apply with args.")
88
}

common-test/src/main/scala/org/scalatest/SharedHelpers.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import scala.collection.GenTraversable
2424
import scala.collection.SortedMap
2525
import scala.collection.SortedSet
2626
import FailureMessages.decorateToStringValue
27-
import java.util.concurrent.Executors
2827
import org.scalactic.Prettifier
2928
import org.scalactic.ArrayHelper.deep
3029

common-test/src/main/scala/org/scalatest/TestConcurrentDistributor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.scalatest
22

33
import org.scalatest.SharedHelpers.SilentReporter
4-
import java.util.concurrent.Executors
4+
import java.util.concurrent.ExecutorService
55

6-
class TestConcurrentDistributor(poolSize: Int) extends tools.ConcurrentDistributor(Args(reporter = SilentReporter), Executors.newFixedThreadPool(poolSize)) {
6+
class TestConcurrentDistributor(execService: ExecutorService) extends tools.ConcurrentDistributor(Args(reporter = SilentReporter), execService) {
77
override def apply(suite: Suite, tracker: Tracker): Unit = {
88
throw new UnsupportedOperationException("Please use apply with args.")
99
}

scalatest-test/src/test/scala/org/scalatest/BeforeAndAfterAllConfigMapSpec.scala

Lines changed: 58 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -106,49 +106,71 @@ class BeforeAndAfterAllConfigMapSpec extends FunSpec {
106106

107107
describe("BeforeAndAfterAll") {
108108
it ("should call beforeAll before any test starts, and call afterAll after all tests completed") {
109-
val suite = new ExampleSuite()
110-
val rep = new EventRecordingReporter()
111-
val dist = new TestConcurrentDistributor(2)
112-
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
113-
dist.waitUntilDone()
109+
// SKIP-SCALATESTJS,NATIVE-START
110+
val execService = java.util.concurrent.Executors.newFixedThreadPool(2)
111+
val dist = new TestConcurrentDistributor(execService)
112+
// SKIP-SCALATESTJS,NATIVE-END
113+
//SCALATESTJS,NATIVE-ONLY val dist = new TestConcurrentDistributor()
114+
try {
115+
val suite = new ExampleSuite()
116+
val rep = new EventRecordingReporter()
117+
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
118+
dist.waitUntilDone()
114119

115-
// should call beforeAll before any test starts
116-
val beforeAllTime = suite.beforeAllTime
117-
val testStartingEvents = rep.testStartingEventsReceived
118-
testStartingEvents should have size 3
119-
testStartingEvents.foreach { testStarting =>
120-
beforeAllTime should be <= testStarting.timeStamp
121-
}
120+
// should call beforeAll before any test starts
121+
val beforeAllTime = suite.beforeAllTime
122+
val testStartingEvents = rep.testStartingEventsReceived
123+
testStartingEvents should have size 3
124+
testStartingEvents.foreach { testStarting =>
125+
beforeAllTime should be <= testStarting.timeStamp
126+
}
122127

123-
// should call afterAll after all tests completed
124-
val afterAllTime = suite.afterAllTime
125-
val testSucceededEvents = rep.testSucceededEventsReceived
126-
testSucceededEvents should have size 3
127-
testSucceededEvents.foreach { testSucceeded =>
128-
afterAllTime should be >= testSucceeded.timeStamp
128+
// should call afterAll after all tests completed
129+
val afterAllTime = suite.afterAllTime
130+
val testSucceededEvents = rep.testSucceededEventsReceived
131+
testSucceededEvents should have size 3
132+
testSucceededEvents.foreach { testSucceeded =>
133+
afterAllTime should be >= testSucceeded.timeStamp
134+
}
135+
}
136+
finally {
137+
// SKIP-SCALATESTJS,NATIVE-START
138+
execService.shutdown()
139+
// SKIP-SCALATESTJS,NATIVE-END
129140
}
130141
}
131142
it ("should call beforeAll before any test starts in nested suite, and call afterAll after all tests in nested suites completed") {
132-
val suite = new ExampleSuites
133-
val rep = new EventRecordingReporter
134-
val dist = new TestConcurrentDistributor(2)
135-
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
136-
dist.waitUntilDone()
143+
// SKIP-SCALATESTJS,NATIVE-START
144+
val execService = java.util.concurrent.Executors.newFixedThreadPool(2)
145+
val dist = new TestConcurrentDistributor(execService)
146+
// SKIP-SCALATESTJS,NATIVE-END
147+
//SCALATESTJS,NATIVE-ONLY val dist = new TestConcurrentDistributor()
148+
try {
149+
val suite = new ExampleSuites
150+
val rep = new EventRecordingReporter
151+
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
152+
dist.waitUntilDone()
137153

138-
// should call beforeAll before any test in nested suite starts
139-
val beforeAllTime = suite.beforeAllTime
140-
val testStartingEvents = rep.testStartingEventsReceived
141-
testStartingEvents should have size 3
142-
testStartingEvents.foreach { testStarting =>
143-
beforeAllTime should be <= testStarting.timeStamp
144-
}
154+
// should call beforeAll before any test in nested suite starts
155+
val beforeAllTime = suite.beforeAllTime
156+
val testStartingEvents = rep.testStartingEventsReceived
157+
testStartingEvents should have size 3
158+
testStartingEvents.foreach { testStarting =>
159+
beforeAllTime should be <= testStarting.timeStamp
160+
}
145161

146-
// should call afterAll after all tests completed
147-
val afterAllTime = suite.afterAllTime
148-
val testSucceededEvents = rep.testSucceededEventsReceived
149-
testSucceededEvents should have size 3
150-
testSucceededEvents.foreach { testSucceeded =>
151-
afterAllTime should be >= testSucceeded.timeStamp
162+
// should call afterAll after all tests completed
163+
val afterAllTime = suite.afterAllTime
164+
val testSucceededEvents = rep.testSucceededEventsReceived
165+
testSucceededEvents should have size 3
166+
testSucceededEvents.foreach { testSucceeded =>
167+
afterAllTime should be >= testSucceeded.timeStamp
168+
}
169+
}
170+
finally {
171+
// SKIP-SCALATESTJS,NATIVE-START
172+
execService.shutdown()
173+
// SKIP-SCALATESTJS,NATIVE-END
152174
}
153175
}
154176
it ("should be called once for beforeAll and afterAll when used with OneInstancePerTest") {

scalatest-test/src/test/scala/org/scalatest/BeforeAndAfterAllProp.scala

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,36 @@ class BeforeAndAfterAllProp extends AllSuiteProp {
5757
test("BeforeAndAfterAll should call beforeAll before any test starts, and call afterAll after all tests completed") {
5858
forAll(examples.filter(_.included)) { suite =>
5959
if (suite.included) {
60-
val rep = new EventRecordingReporter()
61-
val dist = new TestConcurrentDistributor(2)
62-
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
63-
dist.waitUntilDone()
64-
65-
// should call beforeAll before any test starts
66-
val beforeAllTime = suite.beforeAllTime
67-
val testStartingEvents = rep.testStartingEventsReceived
68-
testStartingEvents should have size 3
69-
testStartingEvents.foreach { testStarting =>
70-
beforeAllTime should be <= testStarting.timeStamp
60+
// SKIP-SCALATESTJS,NATIVE-START
61+
val execService = java.util.concurrent.Executors.newFixedThreadPool(2)
62+
val dist = new TestConcurrentDistributor(execService)
63+
// SKIP-SCALATESTJS,NATIVE-END
64+
//SCALATESTJS,NATIVE-ONLY val dist = new TestConcurrentDistributor()
65+
try {
66+
val rep = new EventRecordingReporter()
67+
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
68+
dist.waitUntilDone()
69+
70+
// should call beforeAll before any test starts
71+
val beforeAllTime = suite.beforeAllTime
72+
val testStartingEvents = rep.testStartingEventsReceived
73+
testStartingEvents should have size 3
74+
testStartingEvents.foreach { testStarting =>
75+
beforeAllTime should be <= testStarting.timeStamp
76+
}
77+
78+
// should call afterAll after all tests completed
79+
val afterAllTime = suite.afterAllTime
80+
val testSucceededEvents = rep.testSucceededEventsReceived
81+
testSucceededEvents should have size 3
82+
testSucceededEvents.foreach { testSucceeded =>
83+
afterAllTime should be >= testSucceeded.timeStamp
84+
}
7185
}
72-
73-
// should call afterAll after all tests completed
74-
val afterAllTime = suite.afterAllTime
75-
val testSucceededEvents = rep.testSucceededEventsReceived
76-
testSucceededEvents should have size 3
77-
testSucceededEvents.foreach { testSucceeded =>
78-
afterAllTime should be >= testSucceeded.timeStamp
86+
finally {
87+
// SKIP-SCALATESTJS,NATIVE-START
88+
execService.shutdown()
89+
// SKIP-SCALATESTJS,NATIVE-END
7990
}
8091
}
8192
}

scalatest-test/src/test/scala/org/scalatest/BeforeAndAfterAllSpec.scala

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -107,49 +107,74 @@ class BeforeAndAfterAllSpec extends FunSpec {
107107

108108
describe("BeforeAndAfterAll") {
109109
it ("should call beforeAll before any test starts, and call afterAll after all tests completed") {
110-
val suite = new ExampleSuite()
111-
val rep = new EventRecordingReporter()
112-
val dist = new TestConcurrentDistributor(2)
113-
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
114-
dist.waitUntilDone()
110+
// SKIP-SCALATESTJS,NATIVE-START
111+
val execService = java.util.concurrent.Executors.newFixedThreadPool(2)
112+
val dist = new TestConcurrentDistributor(execService)
113+
// SKIP-SCALATESTJS,NATIVE-END
114+
//SCALATESTJS,NATIVE-ONLY val dist = new TestConcurrentDistributor()
115+
try {
116+
val suite = new ExampleSuite()
117+
val rep = new EventRecordingReporter()
118+
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
119+
dist.waitUntilDone()
115120

116-
// should call beforeAll before any test starts
117-
val beforeAllTime = suite.beforeAllTime
118-
val testStartingEvents = rep.testStartingEventsReceived
119-
testStartingEvents should have size 3
120-
testStartingEvents.foreach { testStarting =>
121-
beforeAllTime should be <= testStarting.timeStamp
122-
}
121+
// should call beforeAll before any test starts
122+
val beforeAllTime = suite.beforeAllTime
123+
val testStartingEvents = rep.testStartingEventsReceived
124+
testStartingEvents should have size 3
125+
testStartingEvents.foreach { testStarting =>
126+
beforeAllTime should be <= testStarting.timeStamp
127+
}
123128

124-
// should call afterAll after all tests completed
125-
val afterAllTime = suite.afterAllTime
126-
val testSucceededEvents = rep.testSucceededEventsReceived
127-
testSucceededEvents should have size 3
128-
testSucceededEvents.foreach { testSucceeded =>
129-
afterAllTime should be >= testSucceeded.timeStamp
129+
// should call afterAll after all tests completed
130+
val afterAllTime = suite.afterAllTime
131+
val testSucceededEvents = rep.testSucceededEventsReceived
132+
testSucceededEvents should have size 3
133+
testSucceededEvents.foreach { testSucceeded =>
134+
afterAllTime should be >= testSucceeded.timeStamp
135+
}
130136
}
137+
finally {
138+
// SKIP-SCALATESTJS,NATIVE-START
139+
execService.shutdown()
140+
// SKIP-SCALATESTJS,NATIVE-END
141+
}
142+
131143
}
132144
it ("should call beforeAll before any test starts in nested suite, and call afterAll after all tests in nested suites completed") {
133145
val suite = new ExampleSuites
134146
val rep = new EventRecordingReporter
135-
val dist = new TestConcurrentDistributor(2)
136-
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
137-
dist.waitUntilDone()
147+
148+
// SKIP-SCALATESTJS,NATIVE-START
149+
val execService = java.util.concurrent.Executors.newFixedThreadPool(2)
150+
val dist = new TestConcurrentDistributor(execService)
151+
// SKIP-SCALATESTJS,NATIVE-END
152+
//SCALATESTJS,NATIVE-ONLY val dist = new TestConcurrentDistributor()
153+
154+
try {
155+
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
156+
dist.waitUntilDone()
138157

139-
// should call beforeAll before any test in nested suite starts
140-
val beforeAllTime = suite.beforeAllTime
141-
val testStartingEvents = rep.testStartingEventsReceived
142-
testStartingEvents should have size 3
143-
testStartingEvents.foreach { testStarting =>
144-
beforeAllTime should be <= testStarting.timeStamp
145-
}
158+
// should call beforeAll before any test in nested suite starts
159+
val beforeAllTime = suite.beforeAllTime
160+
val testStartingEvents = rep.testStartingEventsReceived
161+
testStartingEvents should have size 3
162+
testStartingEvents.foreach { testStarting =>
163+
beforeAllTime should be <= testStarting.timeStamp
164+
}
146165

147-
// should call afterAll after all tests completed
148-
val afterAllTime = suite.afterAllTime
149-
val testSucceededEvents = rep.testSucceededEventsReceived
150-
testSucceededEvents should have size 3
151-
testSucceededEvents.foreach { testSucceeded =>
152-
afterAllTime should be >= testSucceeded.timeStamp
166+
// should call afterAll after all tests completed
167+
val afterAllTime = suite.afterAllTime
168+
val testSucceededEvents = rep.testSucceededEventsReceived
169+
testSucceededEvents should have size 3
170+
testSucceededEvents.foreach { testSucceeded =>
171+
afterAllTime should be >= testSucceeded.timeStamp
172+
}
173+
}
174+
finally {
175+
// SKIP-SCALATESTJS,NATIVE-START
176+
execService.shutdown()
177+
// SKIP-SCALATESTJS,NATIVE-END
153178
}
154179
}
155180
it ("should be called once for beforeAll and afterAll when used with OneInstancePerTest") {

scalatest-test/src/test/scala/org/scalatest/DeprecatedBeforeAndAfterAllProp.scala

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,25 +57,36 @@ class DeprecatedBeforeAndAfterAllProp extends AllSuiteProp {
5757
test("BeforeAndAfterAll should call beforeAll before any test starts, and call afterAll after all tests completed") {
5858
forAll(examples.filter(_.included)) { suite =>
5959
if (suite.included) {
60-
val rep = new EventRecordingReporter()
61-
val dist = new TestConcurrentDistributor(2)
62-
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
63-
dist.waitUntilDone()
64-
65-
// should call beforeAll before any test starts
66-
val beforeAllTime = suite.beforeAllTime
67-
val testStartingEvents = rep.testStartingEventsReceived
68-
testStartingEvents should have size 3
69-
testStartingEvents.foreach { testStarting =>
70-
beforeAllTime should be <= testStarting.timeStamp
60+
// SKIP-SCALATESTJS,NATIVE-START
61+
val execService = java.util.concurrent.Executors.newFixedThreadPool(2)
62+
val dist = new TestConcurrentDistributor(execService)
63+
// SKIP-SCALATESTJS,NATIVE-END
64+
//SCALATESTJS,NATIVE-ONLY val dist = new TestConcurrentDistributor()
65+
try {
66+
val rep = new EventRecordingReporter()
67+
suite.run(None, Args(reporter = rep, distributor = Some(dist)))
68+
dist.waitUntilDone()
69+
70+
// should call beforeAll before any test starts
71+
val beforeAllTime = suite.beforeAllTime
72+
val testStartingEvents = rep.testStartingEventsReceived
73+
testStartingEvents should have size 3
74+
testStartingEvents.foreach { testStarting =>
75+
beforeAllTime should be <= testStarting.timeStamp
76+
}
77+
78+
// should call afterAll after all tests completed
79+
val afterAllTime = suite.afterAllTime
80+
val testSucceededEvents = rep.testSucceededEventsReceived
81+
testSucceededEvents should have size 3
82+
testSucceededEvents.foreach { testSucceeded =>
83+
afterAllTime should be >= testSucceeded.timeStamp
84+
}
7185
}
72-
73-
// should call afterAll after all tests completed
74-
val afterAllTime = suite.afterAllTime
75-
val testSucceededEvents = rep.testSucceededEventsReceived
76-
testSucceededEvents should have size 3
77-
testSucceededEvents.foreach { testSucceeded =>
78-
afterAllTime should be >= testSucceeded.timeStamp
86+
finally {
87+
// SKIP-SCALATESTJS,NATIVE-START
88+
execService.shutdown()
89+
// SKIP-SCALATESTJS,NATIVE-END
7990
}
8091
}
8192
}

0 commit comments

Comments
 (0)