aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-02-23 16:09:06 -0600
committerJesse Luehrs <doy@tozt.net>2013-02-23 16:15:11 -0600
commit073d5a06c07c85c0d1794c4a15d564e8463b31fc (patch)
treedfb53af9f24d8cec55f41ea7024de1060be07c36 /src/test
parent18854928e8697f733d2758d274151999bcc4a238 (diff)
downloadscala-test-more-073d5a06c07c85c0d1794c4a15d564e8463b31fc.tar.gz
scala-test-more-073d5a06c07c85c0d1794c4a15d564e8463b31fc.zip
tests shouldn't produce anything other than tap
the harness can parse the tap to figure out whatever it needs from that
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/org/perl8/test/ExtensionTest.scala10
-rw-r--r--src/test/scala/org/perl8/test/TestMoreTest.scala32
-rw-r--r--src/test/scala/org/perl8/test/tap/TestBuilderTest.scala66
3 files changed, 65 insertions, 43 deletions
diff --git a/src/test/scala/org/perl8/test/ExtensionTest.scala b/src/test/scala/org/perl8/test/ExtensionTest.scala
index e616d3e..6455e16 100644
--- a/src/test/scala/org/perl8/test/ExtensionTest.scala
+++ b/src/test/scala/org/perl8/test/ExtensionTest.scala
@@ -2,6 +2,8 @@ package org.perl8.test
import java.io.ByteArrayOutputStream
+import org.perl8.test.tap.Consumer
+
trait NumberZero { this: TestMore =>
def is_zero (i: Int, desc: String): Boolean = {
withLevel(1) {
@@ -27,25 +29,25 @@ class ExtensionTest extends TestMore {
}
val out = new ByteArrayOutputStream
- val exitCode = Console.withOut(out) {
+ Console.withOut(out) {
Console.withErr(out) {
(new ExtensionTestTest).run
}
}
- is(exitCode, 2)
+ is(Consumer.parse(out).exitCode, 2)
val tap =
"ok 1 - it's zero\n" +
"not ok 2 - it's not zero\n" +
"# Failed test 'it's not zero'\n" +
- "# at ExtensionTest.scala line 24.\n" +
+ "# at ExtensionTest.scala line 26.\n" +
"# got: '1'\n" +
"# expected: '0'\n" +
"ok 3 - the number is zero\n" +
"not ok 4 - the number is zero\n" +
"# Failed test 'the number is zero'\n" +
- "# at ExtensionTest.scala line 26.\n" +
+ "# at ExtensionTest.scala line 28.\n" +
"# got: '1'\n" +
"# expected: '0'\n" +
"1..4\n" +
diff --git a/src/test/scala/org/perl8/test/TestMoreTest.scala b/src/test/scala/org/perl8/test/TestMoreTest.scala
index 61bacad..a72c18b 100644
--- a/src/test/scala/org/perl8/test/TestMoreTest.scala
+++ b/src/test/scala/org/perl8/test/TestMoreTest.scala
@@ -2,6 +2,8 @@ package org.perl8.test
import java.io.ByteArrayOutputStream
+import org.perl8.test.tap.Consumer
+
class TestMoreTest extends TestMore {
private object OutputContainer {
val output = new ByteArrayOutputStream
@@ -56,76 +58,76 @@ class TestMoreTest extends TestMore {
}
}
- val exitCode = Console.withOut(OutputContainer.output) {
+ Console.withOut(OutputContainer.output) {
Console.withErr(OutputContainer.output) {
(new MyBasicTest).run
}
}
- is(exitCode, 9, "got the right plan")
+ is(Consumer.parse(OutputContainer.output).exitCode, 9, "got the right plan")
val expected =
"# ok\n" +
"ok 1 - it works!\n" +
"not ok 2 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 13.\n" +
+ "# at TestMoreTest.scala line 15.\n" +
"ok 3\n" +
"not ok 4\n" +
- "# Failed test at TestMoreTest.scala line 15.\n" +
+ "# Failed test at TestMoreTest.scala line 17.\n" +
"# is\n" +
"ok 5 - it works!\n" +
"not ok 6 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 19.\n" +
+ "# at TestMoreTest.scala line 21.\n" +
"# got: '1'\n" +
"# expected: '0'\n" +
"ok 7\n" +
"not ok 8\n" +
- "# Failed test at TestMoreTest.scala line 21.\n" +
+ "# Failed test at TestMoreTest.scala line 23.\n" +
"# got: '1'\n" +
"# expected: '0'\n" +
"# isnt\n" +
"ok 9 - it works!\n" +
"not ok 10 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 25.\n" +
+ "# at TestMoreTest.scala line 27.\n" +
"# got: '1'\n" +
"# expected: anything else\n" +
"ok 11\n" +
"not ok 12\n" +
- "# Failed test at TestMoreTest.scala line 27.\n" +
+ "# Failed test at TestMoreTest.scala line 29.\n" +
"# got: '1'\n" +
"# expected: anything else\n" +
"# like\n" +
"ok 13 - it works!\n" +
"not ok 14 - it doesn't work!\n" +
"# Failed test 'it doesn't work!'\n" +
- "# at TestMoreTest.scala line 31.\n" +
+ "# at TestMoreTest.scala line 33.\n" +
"# 'foo'\n" +
"# doesn't match 'bar'\n" +
"ok 15\n" +
"not ok 16\n" +
- "# Failed test at TestMoreTest.scala line 33.\n" +
+ "# Failed test at TestMoreTest.scala line 35.\n" +
"# 'foo'\n" +
"# doesn't match 'bar'\n" +
" # unlike\n" +
" ok 1 - it works!\n" +
" not ok 2 - it doesn't work!\n" +
" # Failed test 'it doesn't work!'\n" +
- " # at TestMoreTest.scala line 38.\n" +
+ " # at TestMoreTest.scala line 40.\n" +
" # 'foo'\n" +
" # matches 'foo'\n" +
" ok 3\n" +
" not ok 4\n" +
- " # Failed test at TestMoreTest.scala line 40.\n" +
+ " # Failed test at TestMoreTest.scala line 42.\n" +
" # 'foo'\n" +
" # matches 'foo'\n" +
" 1..4\n" +
" # Looks like you failed 2 tests of 4.\n" +
"not ok 17 - unlikes\n" +
"# Failed test 'unlikes'\n" +
- "# at TestMoreTest.scala line 35.\n" +
+ "# at TestMoreTest.scala line 37.\n" +
"# pass\n" +
"ok 18 - it works!\n" +
"ok 19\n" +
@@ -134,9 +136,9 @@ class TestMoreTest extends TestMore {
"# fail\n" +
"not ok 22 - it doesn't work # TODO not working yet\n" +
"# Failed (TODO) test 'it doesn't work'\n" +
- "# at TestMoreTest.scala line 54.\n" +
+ "# at TestMoreTest.scala line 56.\n" +
"not ok 23 # TODO not working yet\n" +
- "# Failed (TODO) test at TestMoreTest.scala line 55.\n" +
+ "# Failed (TODO) test at TestMoreTest.scala line 57.\n" +
"1..23\n" +
"# Looks like you failed 9 tests of 23.\n"
diff --git a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala
index 8eab0d2..423b823 100644
--- a/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala
+++ b/src/test/scala/org/perl8/test/tap/TestBuilderTest.scala
@@ -102,34 +102,52 @@ class TestBuilderTest extends TestMore {
val output = new ByteArrayOutputStream
val oldOut = Console.out
val oldErr = Console.err
- Console.withOut(output) {
- Console.withErr(output) {
- val builder = new TestBuilder
- Console.withOut(oldOut) {
- Console.withErr(oldErr) {
- ok(!builder.isPassing)
- }
+
+ is(
+ Console.withOut(output) {
+ Console.withErr(output) {
+ val builder = new TestBuilder
+ builder.doneTesting
}
- builder.ok(true)
- Console.withOut(oldOut) {
- Console.withErr(oldErr) {
- ok(builder.isPassing)
- }
+ },
+ false
+ )
+
+ is(
+ Console.withOut(output) {
+ Console.withErr(output) {
+ val builder = new TestBuilder
+ builder.ok(true)
+ builder.doneTesting
}
- builder.ok(false)
- Console.withOut(oldOut) {
- Console.withErr(oldErr) {
- ok(!builder.isPassing)
- }
+ },
+ true
+ )
+
+ is(
+ Console.withOut(output) {
+ Console.withErr(output) {
+ val builder = new TestBuilder
+ builder.ok(true)
+ builder.ok(false)
+ builder.doneTesting
}
- builder.ok(true)
- Console.withOut(oldOut) {
- Console.withErr(oldErr) {
- ok(!builder.isPassing)
- }
+ },
+ false
+ )
+
+ is(
+ Console.withOut(output) {
+ Console.withErr(output) {
+ val builder = new TestBuilder
+ builder.ok(true)
+ builder.ok(false)
+ builder.ok(true)
+ builder.doneTesting
}
- }
- }
+ },
+ false
+ )
}
subtest ("bail out") {