Skip to content

Commit

Permalink
holy crap scripted testing for sbt
Browse files Browse the repository at this point in the history
  • Loading branch information
softprops committed Sep 19, 2011
1 parent f3b1794 commit 15a3351
Show file tree
Hide file tree
Showing 96 changed files with 2,688 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build.sbt
Expand Up @@ -4,4 +4,6 @@ organization := "me.lessis"

name := "jot"

version <<= sbtVersion(v => "0.1.0-%s-SNAPSHOT".format(v))
version <<= sbtVersion(v => "0.1.0-%s-SNAPSHOT".format(v))

seq(ScriptedPlugin.scriptedSettings: _*)
3 changes: 3 additions & 0 deletions project/plugins/build.sbt
@@ -0,0 +1,3 @@
resolvers += Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)

libraryDependencies <+= sbtVersion("org.scala-tools.sbt" %% "scripted-plugin" % _)
3 changes: 3 additions & 0 deletions src/sbt-test/jot/customfile/build.sbt
@@ -0,0 +1,3 @@
seq(jot.Plugin.options:_*)

(jot.Keys.jotFile in Jot) <<= (baseDirectory)(_ / ".myjots")
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,306 changes: 1,306 additions & 0 deletions src/sbt-test/jot/customfile/project/boot/update.log

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/sbt-test/jot/customfile/project/plugins/build.sbt
@@ -0,0 +1,3 @@
libraryDependencies <+= sbtVersion(v =>
"me.lessis" %% "jot" % "0.1.0-%s-SNAPSHOT".format(v)
)
3 changes: 3 additions & 0 deletions src/sbt-test/jot/customfile/test
@@ -0,0 +1,3 @@
# test for custom file
> jot:down some ideas
$ exists .myjots
35 changes: 35 additions & 0 deletions src/sbt-test/jot/simple/build.sbt
@@ -0,0 +1,35 @@
seq(jot.Plugin.options:_*)

InputKey[Unit]("empty") <<= inputTask { (argsTask: TaskKey[Seq[String]]) =>
(argsTask, streams) map {
(args, out) =>
args match {
case Seq(path) =>
IO.read(file(path)) match {
case "" => out.log.debug("File %s was empty" format path)
case contents => error(
"Empty should have been empty but instead contained %s" format contents
)
}
case xs => error("usage: empty path")
}
}
}

InputKey[Unit]("contents") <<= inputTask { (argsTask: TaskKey[Seq[String]]) =>
(argsTask, streams) map {
(args, out) =>
args match {
case Seq(given, expected) =>
if(IO.read(file(given)).equals(IO.read(file(expected)))) out.log.debug(
"Contents match"
)
else error(
"Contents of (%s)\n%s does not match (%s)\n%s" format(
given, IO.read(file(given)), expected, IO.read(file(expected))
)
)
}
}
}

2 changes: 2 additions & 0 deletions src/sbt-test/jot/simple/fixtures/after-rm
@@ -0,0 +1,2 @@
Write more scripted tests

4 changes: 4 additions & 0 deletions src/sbt-test/jot/simple/fixtures/before-rm
@@ -0,0 +1,4 @@
Write more scripted tests

Verify rm works

Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1,306 changes: 1,306 additions & 0 deletions src/sbt-test/jot/simple/project/boot/update.log

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/sbt-test/jot/simple/project/plugins/build.sbt
@@ -0,0 +1,3 @@
libraryDependencies <+= sbtVersion(v =>
"me.lessis" %% "jot" % "0.1.0-%s-SNAPSHOT".format(v)
)
17 changes: 17 additions & 0 deletions src/sbt-test/jot/simple/test
@@ -0,0 +1,17 @@
# verify .jotfile gets created
$ delete .jot
> jot:down Some idea
$ exists .jot

# check that the file is empty
> jot:clear
> empty .jot

# check content creation
> jot:down Write more scripted tests
> jot:down Verify rm works
> contents .jot fixtures/before-rm

# not rm the second item
> jot:rm 1
> contents .jot fixtures/after-rm

0 comments on commit 15a3351

Please sign in to comment.