This repository was archived by the owner on Sep 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Add a mode to reuse JVM for test execution #99
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/scala/scala/tools/partest/nest/DelegatingSecurityManager.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package scala.tools.partest.nest | ||
|
||
import java.io.FileDescriptor | ||
import java.net.InetAddress | ||
import java.security.Permission | ||
|
||
class DelegatingSecurityManager(delegate: SecurityManager) extends SecurityManager { | ||
override def checkExit(status: Int): Unit = if (delegate ne null) delegate.checkExit(status) | ||
override def checkPermission(perm: Permission): Unit = if (delegate ne null) delegate.checkPermission(perm) | ||
override def checkPermission(perm: Permission, context: AnyRef): Unit = if (delegate ne null) delegate.checkPermission(perm, context) | ||
override def checkExec(cmd: String): Unit = if (delegate ne null) delegate.checkExec(cmd) | ||
override def checkWrite(file: String): Unit = if (delegate ne null) delegate.checkWrite(file) | ||
override def checkDelete(file: String): Unit = if (delegate ne null) delegate.checkDelete(file) | ||
override def checkRead(file: String): Unit = if (delegate ne null) delegate.checkRead(file) | ||
override def checkRead(file: String, context: scala.Any): Unit = if (delegate ne null) delegate.checkRead(file, context) | ||
override def checkPropertyAccess(key: String): Unit = if (delegate ne null) delegate.checkPropertyAccess(key) | ||
override def checkAccept(host: String, port: Int): Unit = if (delegate ne null) delegate.checkAccept(host, port) | ||
override def checkWrite(fd: FileDescriptor): Unit = if (delegate ne null) delegate.checkWrite(fd) | ||
override def checkPrintJobAccess(): Unit = if (delegate ne null) delegate.checkPrintJobAccess() | ||
override def checkMulticast(maddr: InetAddress): Unit = if (delegate ne null) delegate.checkMulticast(maddr) | ||
override def checkSetFactory(): Unit = if (delegate ne null) delegate.checkSetFactory() | ||
override def checkLink(lib: String): Unit = if (delegate ne null) delegate.checkLink(lib) | ||
override def checkSecurityAccess(target: String): Unit = if (delegate ne null) delegate.checkSecurityAccess(target) | ||
override def checkListen(port: Int): Unit = if (delegate ne null) delegate.checkListen(port) | ||
override def checkAccess(t: Thread): Unit = if (delegate ne null) delegate.checkAccess(t) | ||
override def checkAccess(g: ThreadGroup): Unit = if (delegate ne null) delegate.checkAccess(g) | ||
override def checkCreateClassLoader(): Unit = if (delegate ne null) delegate.checkCreateClassLoader() | ||
override def checkPackageDefinition(pkg: String): Unit = if (delegate ne null) delegate.checkPackageDefinition(pkg) | ||
override def checkConnect(host: String, port: Int): Unit = if (delegate ne null) delegate.checkConnect(host, port) | ||
override def checkConnect(host: String, port: Int, context: scala.Any): Unit = if (delegate ne null) delegate.checkConnect(host, port, context) | ||
override def checkPackageAccess(pkg: String): Unit = if (delegate ne null) delegate.checkPackageAccess(pkg) | ||
override def checkPropertiesAccess(): Unit = if (delegate ne null) delegate.checkPropertiesAccess() | ||
override def checkRead(fd: FileDescriptor): Unit = if (delegate ne null) delegate.checkRead(fd) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package scala.tools.partest.nest | ||
|
||
class Stopwatch { | ||
private var base: Option[Long] = None | ||
private var elapsed = 0L | ||
def pause(): Unit = { | ||
assert(base.isDefined) | ||
val now = System.nanoTime | ||
elapsed += (now - base.get) | ||
base = None | ||
} | ||
def start(): Unit = { | ||
base = Some(System.nanoTime()) | ||
} | ||
|
||
def stop(): Long = { | ||
pause() | ||
(1.0 * elapsed / 1000 / 1000).toLong | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a quick comment to document the unit