Skip to content

Commit

Permalink
Adding a lame test for cygwin bash scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuereth committed Jul 15, 2013
1 parent a9029dc commit 37b0460
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/sbt-test/cygwin/java-app-archetype/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import NativePackagerKeys._

packageArchetype.java_application

name := "windows-test"

version := "0.1.0"

TaskKey[Unit]("check-cygwin-script") <<= (stagingDirectory in Universal, name, streams) map { (dir, name, streams) =>
// TODO - FIx our cygwin detection!
val cygwinBash = file("C:\\cygwin\\bin\\bash.exe")
if(!cygwinBash.exists) sys.error("Unable to find the default cygwin (c:\\cygwin) install for testing.")
else {
val script = dir / "bin" / name
val PathParts = "([\\w])+\\:\\\\(.+)".r
val PathParts(drive, path) = script.getAbsolutePath
val cygdriveScriptPath = "/cygdrive/"+drive.toLowerCase+"/" + path.replaceAll("\\\\", "/")
val pathEnv = "C:\\cygwin\\bin"
val cmd = Seq(cygwinBash.getAbsolutePath, cygdriveScriptPath, "-d")
val result =
Process(cmd, Some(dir), "PATH" -> pathEnv) ! streams.log match {
case 0 => ()
case n => sys.error("Failed to run script: " + cygdriveScriptPath + " error code: " + n)
}
val output = Process(cmd, Some(dir), "PATH" -> pathEnv).!!
val expected = "SUCCESS!"
assert(output contains expected, "Failed to correctly run the main script!. Found ["+output+"] wanted ["+expected+"]")
}
}
1 change: 1 addition & 0 deletions src/sbt-test/cygwin/java-app-archetype/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package test

object Test extends App {
println("SUCCESS!")
}
4 changes: 4 additions & 0 deletions src/sbt-test/cygwin/java-app-archetype/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Run the staging and check the script.
> stage
$ exists target/universal/stage/bin/windows-test
> check-cygwin-script

0 comments on commit 37b0460

Please sign in to comment.