Permalink
Browse files

Updated to latest Scala 2.10 (RC5)

  • Loading branch information...
1 parent b6e54cf commit 0a99a3816aad3d0e884d43aa74d58d87c40ef0b0 @davewhittaker davewhittaker committed Dec 17, 2012
@@ -11,6 +11,7 @@ object SquerylBuild extends Build {
description := "A Scala ORM and DSL for talking with Databases using minimum verbosity and maximum type safety",
organization := "org.squeryl",
version := "0.9.5-5",
+ javacOptions := Seq("-source", "1.6", "-target", "1.6"),
version <<= version { v => //only release *if* -Drelease=true is passed to JVM
val release = Option(System.getProperty("release")) == Some("true")
if (release)
@@ -26,7 +27,7 @@ object SquerylBuild extends Build {
publishMavenStyle := true,
scalaVersion := "2.9.2",
scalaBinaryVersion <<= scalaVersion { sv => sv },
- crossScalaVersions := Seq("2.10.0-RC3", "2.9.2", "2.9.1", "2.9.0-1", "2.9.0", "2.8.2", "2.8.1", "2.8.0"),
+ crossScalaVersions := Seq("2.10.0-RC5", "2.9.2", "2.9.1", "2.9.0-1", "2.9.0", "2.8.2", "2.8.1", "2.8.0"),
crossVersion := CrossVersion.full,
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(url("http://squeryl.org")),
@@ -74,8 +75,7 @@ object SquerylBuild extends Build {
Seq("org.scala-lang" % "scalap" % sv,
sv match {
case sv if sv startsWith "2.10" =>
- "org.scalatest" % "scalatest_2.10.0-RC1" % "2.0.M4" % "test"
- //"org.scalatest" % "scalatest_2.10.0-M6" % "1.9-2.10.0-M6-B2" % "test"
+ "org.scalatest" % ("scalatest_" + sv) % "1.8-B1" % "test"
case sv if sv startsWith "2.9" =>
"org.scalatest" % "scalatest_2.9.2" % "1.6.1" % "test"
case _ =>
@@ -2,24 +2,29 @@ package org.squeryl.framework
import org.scalatest.{ Reporter, Stopper, Tracker }
import org.squeryl.PrimitiveTypeMode.transaction
-import org.squeryl.{ SessionFactory, Session }
+import org.squeryl.Session
trait RunTestsInsideTransaction extends DbTestBase {
-
- override def withFixture(test: NoArgTest) = {
- super.withFixture(new NoArgTest {
- def name = test.name
- def configMap = test.configMap
- def apply() {
- if(SessionFactory.concreteFactory.isDefined) {
- //println("Running " + test.name + " in a transaction")
- transaction {
- test.apply()
- Session.currentSession.connection.rollback()
- }
- }
- }
- })
+
+ override def runTest(
+ testName: String,
+ reporter: Reporter,
+ stopper: Stopper,
+ configMap: Map[String, Any],
+ tracker: Tracker): Unit = {
+ if(!notIgnored){
+ super.runTest(testName, reporter, stopper, configMap, tracker)
+ return
+ }
+
+ // each test occur from within a transaction, that way when the test completes _all_ changes
+ // made during the test are reverted so each test gets a clean enviroment to test against
+ transaction {
+ super.runTest(testName, reporter, stopper, configMap, tracker)
+
+ // we abort the transaction if we get to here, so changes get rolled back
+ Session.currentSession.connection.rollback
+ }
}
}
@@ -12,21 +12,10 @@ abstract class SchemaTester extends DbTestBase{
def schema : Schema
def prePopulate() = {}
-
- override def withFixture(test: NoArgTest) {
- super.withFixture(new NoArgTest {
- def name = test.name
- def configMap = test.configMap
- def apply() {
- _initSchema
- test.apply()
- }
- })
- }
- lazy val _initSchema = {
- if(SessionFactory.concreteFactory.isDefined){
- //println("Creating schema")
+ override def beforeAll(){
+ super.beforeAll
+ if(notIgnored){
transaction{
schema.drop
schema.create
@@ -43,7 +32,7 @@ abstract class SchemaTester extends DbTestBase{
override def afterAll(){
super.afterAll
- if(SessionFactory.concreteFactory.isDefined){
+ if(notIgnored){
transaction{
schema.drop
}
@@ -55,26 +44,37 @@ abstract class DbTestBase extends FunSuite with ShouldMatchers with BeforeAndAft
def connectToDb : Option[() => Session]
+ var notIgnored = true
+
val ignoredTests : List[String] = Nil
-
- lazy val _initFactory = {
- //println("Initializing session factory")
- SessionFactory.concreteFactory = connectToDb
+
+ override def beforeAll(){
+ super.beforeAll
+ SessionFactory.concreteFactory = connectWrapper()
}
-
- override def withFixture(test: NoArgTest) = {
- super.withFixture(new NoArgTest {
- override def name = test.name
- override def configMap = test.configMap
- override def apply() = {
- _initFactory
- if(SessionFactory.concreteFactory.isDefined && !ignoredTests.exists(_ == test.name)) {
- //println("Running " + test.name + " with session factory " + SessionFactory.concreteFactory)
- test.apply()
- }
- }
- })
+
+ private def connectWrapper() : Option[() => Session] = {
+ val connector = connectToDb
+ if(connector.isEmpty){
+ notIgnored = false
+ None
+ }else{
+ Some(connector.get)
+ }
}
+ override def runTest(
+ testName: String,
+ reporter: Reporter,
+ stopper: Stopper,
+ configMap: Map[String, Any],
+ tracker: Tracker): Unit = {
+
+ if(!notIgnored || ignoredTests.find(_ == testName).isDefined){
+ //reporter(TestIgnored(new Ordinal(0), suiteName, Some(this.getClass.getName),testName))
+ return
+ }
+ super.runTest(testName, reporter, stopper, configMap, tracker)
+ }
}

0 comments on commit 0a99a38

Please sign in to comment.