diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | circle.yml | 1 | ||||
-rw-r--r-- | examples/build-scalatest/build/build.scala | 14 | ||||
-rw-r--r-- | examples/build-scalatest/build/build/build.scala | 14 | ||||
-rw-r--r-- | examples/build-scalatest/src/main/scala/Hello.scala | 7 | ||||
-rw-r--r-- | examples/build-scalatest/src/test/scala/Test.scala | 24 | ||||
-rw-r--r-- | plugins/scalatest/ScalaTest.scala | 5 |
7 files changed, 65 insertions, 2 deletions
@@ -7,3 +7,5 @@ scala_classes target/ *.login cache_ +.idea +realpath/realpath @@ -15,3 +15,4 @@ test: override: - ./cbt direct test -Dlog=all - ./cbt test -Dlog=all + - cd examples/build-scalatest && ../../cbt test -Dlog=all && cd ../.. diff --git a/examples/build-scalatest/build/build.scala b/examples/build-scalatest/build/build.scala new file mode 100644 index 0000000..ed486f0 --- /dev/null +++ b/examples/build-scalatest/build/build.scala @@ -0,0 +1,14 @@ +import cbt._ +import java.net.URL +import java.io.File +import scala.collection.immutable.Seq + +class Build( context: Context ) extends BasicBuild( context ) with SbtLayout { + + override def dependencies = ( + super.dependencies ++ + Resolver( mavenCentral ).bind( + ScalaDependency("org.scalatest","scalatest","2.2.4") + ) + ) +}
\ No newline at end of file diff --git a/examples/build-scalatest/build/build/build.scala b/examples/build-scalatest/build/build/build.scala new file mode 100644 index 0000000..6b1a98e --- /dev/null +++ b/examples/build-scalatest/build/build/build.scala @@ -0,0 +1,14 @@ +import cbt._ +import java.net.URL +import java.io.File +import scala.collection.immutable.Seq + +class Build( context: Context ) extends BuildBuild( context ){ + + override def dependencies = ( + super.dependencies ++ + Resolver( mavenCentral ).bind( + ScalaDependency("org.scalatest","scalatest","2.2.4") + ) :+ BuildDependency(new File(context.cbtHome + "/plugins/scalatest")) + ) +} diff --git a/examples/build-scalatest/src/main/scala/Hello.scala b/examples/build-scalatest/src/main/scala/Hello.scala new file mode 100644 index 0000000..5e56da4 --- /dev/null +++ b/examples/build-scalatest/src/main/scala/Hello.scala @@ -0,0 +1,7 @@ +object Main extends App{ + + println("Hell") + + def square(x: Int) = x * x + +} diff --git a/examples/build-scalatest/src/test/scala/Test.scala b/examples/build-scalatest/src/test/scala/Test.scala new file mode 100644 index 0000000..d176080 --- /dev/null +++ b/examples/build-scalatest/src/test/scala/Test.scala @@ -0,0 +1,24 @@ +import collection.mutable.Stack +import org.scalatest._ + +class Test extends FlatSpec with Matchers { + + "A Stack" should "pop values in last-in-first-out order" in { + val stack = new Stack[Int] + stack.push(1) + stack.push(2) + stack.pop() should be (2) + stack.pop() should be (1) + } + + it should "throw NoSuchElementException if an empty stack is popped" in { + val emptyStack = new Stack[Int] + a [NoSuchElementException] should be thrownBy { + emptyStack.pop() + } + } + + "square" should "return double" in { + Main.square(2) should be (4) + } +}
\ No newline at end of file diff --git a/plugins/scalatest/ScalaTest.scala b/plugins/scalatest/ScalaTest.scala index 0959087..53c6446 100644 --- a/plugins/scalatest/ScalaTest.scala +++ b/plugins/scalatest/ScalaTest.scala @@ -16,8 +16,9 @@ trait SbtLayout extends BasicBuild{ override def sources = Seq( projectDirectory ++ "/src/main/scala" ) def testSources = projectDirectory ++ "/src/test/scala" def testDependencies: Seq[Dependency] = Nil - lazy val testBuild = - new BasicBuild(context.copy(projectDirectory = testSources)) with ScalaTest{ + lazy val testBuild = + new BasicBuild(context) with ScalaTest{ + override def sources = Seq(testSources) override def target = outer.target override def compileTarget = outer.scalaTarget ++ "/test-classes" override def dependencies = (outer +: testDependencies) ++ super.dependencies |