-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a lame test for cygwin bash scripts.
- Loading branch information
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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+"]") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
5 changes: 5 additions & 0 deletions
5
src/sbt-test/cygwin/java-app-archetype/src/main/scala/test/Test.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package test | ||
|
||
object Test extends App { | ||
println("SUCCESS!") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |