-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes how giter8 deals with scripted test #408
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,9 @@ object Giter8Plugin extends sbt.AutoPlugin { | |
} else Nil | ||
|
||
// copy test script or generate one | ||
val script = new File(out, "test") | ||
// the final script should always be called "test.script" | ||
// no matter how it was originally called by user | ||
val script = new File(out, finalScriptName) | ||
if (ts.exists) IO.copyFile(ts, script) | ||
else IO.write(script, """>test""") | ||
|
||
|
@@ -141,15 +143,25 @@ object Giter8Plugin extends sbt.AutoPlugin { | |
val dir = (sourceDirectory in Test).value | ||
val metadir = (baseDirectory in LocalRootProject).value / "project" | ||
val file0 = dir / "g8" / "test" | ||
val files = List( | ||
file0, | ||
dir / "g8" / "giter8.test", | ||
dir / "g8" / "g8.test", | ||
metadir / "test", | ||
metadir / "giter8.test", | ||
metadir / "g8.test" | ||
) | ||
files.find(_.exists).getOrElse(file0) | ||
|
||
// we should only use file0 if its an exisiting file | ||
// if it exists and is a dir we should fallback to test.script | ||
val defaultTestScript = | ||
if (file0.isDirectory) dir / "g8" / "test.script" | ||
else file0 | ||
|
||
val files = List(file0, | ||
dir / "g8" / "test.script", | ||
dir / "g8" / "giter8.test", | ||
dir / "g8" / "g8.test", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know how "giter8.test" and "g8.test" could possibly be used. If we add such a file, for instace, giter8 will pick it, but it won't work with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, now I see why "giter8.test" and "g8.test" can work. The user can define the test in such a file, but then when it gets run, the content of the file is copied to In the end, the test script is always copied to a file called "test". The 'fix' I did here make it impossible to use "giter8.test" or "g8.test", because it makes the final script to be named as such which sbt-scripted won't recognize. |
||
metadir / "test", | ||
metadir / "test.script", | ||
metadir / "giter8.test", | ||
metadir / "g8.test") | ||
|
||
files | ||
.find(_.isFile) | ||
.getOrElse(defaultTestScript) | ||
}, | ||
scriptedBufferLog in (Test, g8) := true | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
enablePlugins(ScriptedPlugin) | ||
|
||
scriptedBufferLog in (Test, g8) := false | ||
|
||
TaskKey[Unit]("writeInvalidFile") := { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
|
||
enablePlugins(ScriptedPlugin) | ||
|
||
scriptedBufferLog in (Test, g8) := false | ||
|
||
val javaVmArgs: List[String] = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally thought this was a bug, but the final script is always called "test". That's what allows users to have scripts called "giter8.test" or "g8.test".
Unfortunately that conflicts with Play applications using default Play layout (see sbt/sbt#630).
Since, sbt 1.2.1, scripted tests recognize "test.script" as a valid script name. We can workaround this situation by forcing it to be "test.script" when using sbt 1.x.