* Fix issue with 'run' improperly interpreting System.exit(0) as a non-zero code

* Updating more tests for 0.6.x
This commit is contained in:
Mark Harrah 2009-12-15 19:11:59 -05:00
parent bad073408d
commit 4ee8c92bec
40 changed files with 148 additions and 272 deletions

View File

@ -29,7 +29,15 @@ object TrapExit
* the threads that were created by 'execute'.*/ * the threads that were created by 'execute'.*/
val originalThreads = allThreads val originalThreads = allThreads
val code = new ExitCode val code = new ExitCode
def executeMain = try { execute } catch { case x => code.set(1); throw x } def executeMain =
try { execute }
catch
{
case e: TrapExitSecurityException => throw e
case x =>
code.set(1) //exceptions in the main thread cause the exit code to be 1
throw x
}
val customThreadGroup = new ExitThreadGroup(new ExitHandler(Thread.getDefaultUncaughtExceptionHandler, originalThreads, code, log)) val customThreadGroup = new ExitThreadGroup(new ExitHandler(Thread.getDefaultUncaughtExceptionHandler, originalThreads, code, log))
val executionThread = new Thread(customThreadGroup, "run-main") { override def run() { executeMain } } val executionThread = new Thread(customThreadGroup, "run-main") { override def run() { executeMain } }

View File

@ -1,2 +1 @@
> update > update
[success]

View File

@ -1,48 +1,40 @@
# publish a jar with Published with managedStyle = ManagedStyle.Maven # publish a jar with Published with managedStyle = ManagedStyle.Maven
$ copy-file changes/maven/Published.scala src/main/scala/Published.scala [success] $ copy-file changes/maven/Published.scala src/main/scala/Published.scala
> publish > publish
[success] $ delete src project lib_managed
$ delete src project lib_managed [success]
# get and compile against each published jar with managedStyle = ManagedStyle.Maven # get and compile against each published jar with managedStyle = ManagedStyle.Maven
$ copy-file changes/maven/TestUse.scala project/build/TestUse.scala [success] $ copy-file changes/maven/TestUse.scala project/build/TestUse.scala
$ copy-file changes/maven/use.build.properties project/build.properties [success] $ copy-file changes/maven/use.build.properties project/build.properties
$ reload [success] > reload
$ copy-file changes/maven/Use.scala src/main/scala/Use.scala [success] $ copy-file changes/maven/Use.scala src/main/scala/Use.scala
> compile -> compile
[failure]
> update > update
[success]
> compile > compile
[success] $ delete src project lib_managed repo
$ delete src project lib_managed repo [success]
# publish a jar with PublishedIvy with managedStyle = ManagedStyle.Ivy # publish a jar with PublishedIvy with managedStyle = ManagedStyle.Ivy
$ copy-file changes/ivy/publish.build.properties project/build.properties [success] $ copy-file changes/ivy/publish.build.properties project/build.properties
$ copy-file changes/ivy/TestPublish.scala project/build/TestPublish.scala [success] $ copy-file changes/ivy/TestPublish.scala project/build/TestPublish.scala
$ reload [success] > reload
$ copy-file changes/ivy/Published.scala src/main/scala/Published.scala [success] $ copy-file changes/ivy/Published.scala src/main/scala/Published.scala
> publish > publish
[success]
# get and compile against each published jar with managedStyle = ManagedStyle.Ivy # get and compile against each published jar with managedStyle = ManagedStyle.Ivy
$ delete src project lib_managed [success] $ delete src project lib_managed
$ copy-file changes/ivy/TestUse.scala project/build/TestUse.scala [success] $ copy-file changes/ivy/TestUse.scala project/build/TestUse.scala
$ copy-file changes/ivy/use.build.properties project/build.properties [success] $ copy-file changes/ivy/use.build.properties project/build.properties
$ reload [success] > reload
$ copy-file changes/ivy/Use.scala src/main/scala/Use.scala [success] $ copy-file changes/ivy/Use.scala src/main/scala/Use.scala
> compile -> compile
[failure]
> update > update
[success] > compile
> compile
[success]

View File

@ -1,29 +1,23 @@
# load the project definition with transitive dependencies enabled # load the project definition with transitive dependencies enabled
# and check that they are not downloaded # and check that they are not downloaded
$ touch transitive [success] $ touch transitive
$ reload [success] $ reload
> update > update
[success]
> check-transitive > check-transitive
[success] -> check-intransitive
> check-intransitive
[failure]
# load the project definition with transitive dependencies disabled # load the project definition with transitive dependencies disabled
# and check that they are not downloaded # and check that they are not downloaded
$ delete ivy-cache $ delete ivy-cache
$ delete transitive [success] $ delete transitive
$ reload [success] > reload
> update > update
[success]
> check-transitive -> check-transitive
[failure] > check-intransitive
> check-intransitive
[success]

View File

@ -1,21 +1,12 @@
> publish > publish
[success]
$ delete project/build/ $ delete project/build/
[success]
$ copy-file changes/UseColor.scala project/build/UseColor.scala $ copy-file changes/UseColor.scala project/build/UseColor.scala
[success]
$ copy-file changes/blue color $ copy-file changes/blue color
[success]
$ copy-file changes/build.properties project/build.properties $ copy-file changes/build.properties project/build.properties
[success] > reload
$ reload
[success]
> update -> update
[failure]
$ copy-file changes/red color $ copy-file changes/red color
[success] > update
> update
[success]

View File

@ -7,7 +7,7 @@ class InfoTest(info: ProjectInfo) extends DefaultProject(info)
override def ivyXML = override def ivyXML =
if(customInfo) if(customInfo)
(<info organisation="test" module="test" revision="1.0"> (<info organisation={organization} module={moduleID} revision="1.0">
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" /> <license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
<description homepage="http://github.com/szeiger/scala-query/"> <description homepage="http://github.com/szeiger/scala-query/">
ScalaQuery is a type-safe database query API for Scala. ScalaQuery is a type-safe database query API for Scala.

View File

@ -1,13 +1,13 @@
> update [success] > update
> check-download [success] > check-download
> deliver-local [success] > deliver-local
> check-info [success] > check-info
> clean [success] > clean
> clean-lib [success] > clean-lib
$ touch info [success] $ touch info
> update [success] > update
> check-download [success] > check-download
> deliver-local [success] > deliver-local
> check-info [success] > check-info

View File

@ -1,31 +1,21 @@
# This should fail because the sub project declares a dependency that exists in an extra repository, which we haven't declared # This should fail because the sub project declares a dependency that exists in an extra repository, which we haven't declared
> update > update
[failure]
# Copy the project definition with the extra repository declared in the parent and reload # Copy the project definition with the extra repository declared in the parent and reload
$ copy-file changes/CorrectProject.scala project/build/src/TestProject.scala $ copy-file changes/CorrectProject.scala project/build/src/TestProject.scala
[success]
$ reload $ reload
[success]
# Try updating again, which should work because the repository declared in the parent should be inherited by the child # Try updating again, which should work because the repository declared in the parent should be inherited by the child
> update > update
[success]
# Copy the project definition with the extra repository declared in the child and parent and reload # Copy the project definition with the extra repository declared in the child and parent and reload
$ copy-file changes/CorrectProject2.scala project/build/src/TestProject.scala $ copy-file changes/CorrectProject2.scala project/build/src/TestProject.scala
[success]
$ reload $ reload
[success]
> update > update
[success]
# Copy the project definition with the extra repository declared in the child and reload # Copy the project definition with the extra repository declared in the child and reload
$ copy-file changes/CorrectProject3.scala project/build/src/TestProject.scala $ copy-file changes/CorrectProject3.scala project/build/src/TestProject.scala
[success]
$ reload $ reload
[success]
> update > update
[success]

View File

@ -5,8 +5,7 @@ class TestProject(info: ProjectInfo) extends DefaultProject(info)
val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0-beta2" intransitive() val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0-beta2" intransitive()
override def useDefaultConfigurations = override def useDefaultConfigurations =
if("useDefaultConfigurations".asFile.exists) true if("useDefaultConfigurations".asFile.exists) true else false
else false
lazy val checkDefault = task { check(Configurations.Default) } lazy val checkDefault = task { check(Configurations.Default) }
lazy val checkCompile = task { check(Configurations.Compile) } lazy val checkCompile = task { check(Configurations.Compile) }

View File

@ -2,41 +2,40 @@
# Download jars. If successful, httpclient should be downloaded to the 'default' configuration # Download jars. If successful, httpclient should be downloaded to the 'default' configuration
> update > update
[success]
# The jar should exist in the 'default' configuration ... # The jar should exist in the 'default' configuration ...
> check-default > check-default
[success]
# but not in the 'compile' configuration ... # but not in the 'compile' configuration ...
> check-compile -> check-compile
[failure]
# It should be present on the compile classpath # It should be present on the compile classpath
> check-classpath > check-classpath
[success]
# reset test # reset test
> clean-lib > clean-lib
[success]
# Indicate to the project definition that we now want useDefaultConfigurations = true # Indicate to the project definition that we now want useDefaultConfigurations = true
$ touch useDefaultConfigurations $ touch useDefaultConfigurations
[success]
# Reload for change to take effect # Reload for change to take effect
$ reload $ reload
[success]
## Rerun test with useDefaultConfigurations=true ## Rerun test with useDefaultConfigurations=true
# Download jars. If successful, httpclient should be downloaded to the 'compile' configuration # Download jars. If successful, httpclient should be downloaded to the 'compile' configuration
> update > update
[success]
# The jar should not exist in the 'default' configuration ... # The jar should not exist in the 'default' configuration ...
> check-default -> check-default
[failure]
# It should exist in the 'compile' configuration # It should exist in the 'compile' configuration
> check-compile > check-compile
[success]
# It should be present on the compile classpath # It should be present on the compile classpath
> check-classpath > check-classpath
[success]

View File

@ -5,4 +5,5 @@ class UpdateTestProject(info: ProjectInfo) extends DefaultProject(info)
val sc = "org.scalacheck" % "scalacheck" % "1.5" val sc = "org.scalacheck" % "scalacheck" % "1.5"
def ivyCacheDirectory = outputPath / "ivy-cache" def ivyCacheDirectory = outputPath / "ivy-cache"
override def updateOptions = CacheDirectory(ivyCacheDirectory) :: super.updateOptions.toList override def updateOptions = CacheDirectory(ivyCacheDirectory) :: super.updateOptions.toList
override def disableCrossPaths = true
} }

View File

@ -1,5 +1,3 @@
> update > update
[success]
$ exists lib_managed/compile/scalacheck-1.5.jar $ exists lib_managed/compile/scalacheck-1.5.jar
[success]

View File

@ -0,0 +1,6 @@
import sbt._
class TestProject(info: ProjectInfo) extends DefaultProject(info)
{
override def disableCrossPaths = true
}

View File

@ -1,20 +1,9 @@
> update > update
[success]
$ copy-file changes/scalacheck-ivy.xml ivy.xml $ copy-file changes/scalacheck-ivy.xml ivy.xml
[success] -> update
> update
[failure]
$ absent lib_managed/default/scalacheck-1.5.jar $ absent lib_managed/default/scalacheck-1.5.jar
[success]
$ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml $ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml
[success]
> update > update
[success] $ exists lib_managed/default/scalacheck-1.5.jar
$ exists lib_managed/default/scalacheck-1.5.jar
[success]

View File

@ -3,4 +3,5 @@ import sbt._
class UpdateTestProject(info: ProjectInfo) extends DefaultProject(info) class UpdateTestProject(info: ProjectInfo) extends DefaultProject(info)
{ {
val sc = "org.scalacheck" % "scalacheck" % "1.5" val sc = "org.scalacheck" % "scalacheck" % "1.5"
override def disableCrossPaths = true
} }

View File

@ -1,14 +1,6 @@
> update -> update
[error]
$ absent lib_managed/compile/scalacheck-1.5.jar $ absent lib_managed/compile/scalacheck-1.5.jar
[success]
$ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml $ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml
[success]
> update > update
[success]
$ exists lib_managed/compile/scalacheck-1.5.jar $ exists lib_managed/compile/scalacheck-1.5.jar
[success]

View File

@ -1,2 +1 @@
> update > update
[success]

View File

@ -1,25 +1,14 @@
> update > update
[success]
> clean > clean
[success]
$ copy-file changes/WrongOrg.scala project/build/Test.scala $ copy-file changes/WrongOrg.scala project/build/Test.scala
[success]
$ reload $ reload
[success] -> update
> update
[failure]
$ copy-file changes/WrongVersion.scala project/build/Test.scala $ copy-file changes/WrongVersion.scala project/build/Test.scala
[success]
$ reload $ reload
[success] -> update
> update
[failure]
$ copy-file changes/WrongPattern.scala project/build/Test.scala $ copy-file changes/WrongPattern.scala project/build/Test.scala
[success]
$ reload $ reload
[success] -> update
> update
[failure]

View File

@ -1,23 +1,13 @@
> update -> update
[failure]
> clean-lib > clean-lib
[success]
$ copy-file changes/ivysettings.xml sub/ivysettings.xml $ copy-file changes/ivysettings.xml sub/ivysettings.xml
[success]
> update > update
[success]
> clean-lib > clean-lib
[success]
$ delete sub/ivysettings.xml $ delete sub/ivysettings.xml
[success] -> update
> update
[failure]
> clean-lib > clean-lib
[success]
$ copy-file changes/ivysettings.xml ivysettings.xml $ copy-file changes/ivysettings.xml ivysettings.xml
[success] > update
> update
[success]

View File

@ -1,2 +1 @@
> publish-local > publish-local
[success]

View File

@ -1,51 +1,30 @@
# verify that the classpaths are correct for when a dependency is in the provided configuration # verify that the classpaths are correct for when a dependency is in the provided configuration
$ touch useProvided $ touch useProvided
[success] > reload
$ reload
[success]
> update > update
[success]
> check-run > check-run
[success]
> check-compile > check-compile
[success]
> check-provided > check-provided
[success]
> check-public > check-public
[success]
> package > package
[success]
> check-war > check-war
[success]
# verify that the classpaths are correct for when a dependency is in the compile configuration # verify that the classpaths are correct for when a dependency is in the compile configuration
$ delete useProvided $ delete useProvided
[success] > reload
$ reload
[success]
> update > update
[success]
> check-run > check-run
[success]
> check-compile > check-compile
[success]
> check-provided > check-provided
[success]
> check-public > check-public
[success]
# prepare-webapp is last modified based, so we need to force it to do work # prepare-webapp is last modified based, so we need to force it to do work
$ delete target $ delete target
[success]
> package > package
[success] > check-war
> check-war
[success]

View File

@ -1,20 +1,16 @@
> publish-local > publish-local
[success]
> clean [success] > clean
$ touch mavenStyle [success] $ touch mavenStyle
$ reload [success] > reload
> publish-local > publish-local
[success]
> clean [success] > clean
$ touch sub/mavenStyle [success] $ touch sub/mavenStyle
$ reload [success] > reload
> publish-local > publish-local
[success]
> clean [success] > clean
$ delete mavenStyle [success] $ delete mavenStyle
$ reload [success] > reload
> publish-local > publish-local
[success]

View File

@ -1,5 +1,2 @@
> update > update
[success] > check
> check
[success]

View File

@ -1,12 +1,7 @@
> check-in-test -> check-in-test
[failure] -> check-in-compile
> check-in-compile
[failure]
> update > update
[success]
> check-in-test > check-in-test
[success] -> check-in-compile
> check-in-compile
[failure]

View File

@ -0,0 +1,6 @@
import sbt._
class Test(info: ProjectInfo) extends DefaultProject(info)
{
override def disableCrossPaths = true
}

View File

@ -1,26 +1,11 @@
> package > package
[success]
$ exists "target/lazy-package-name-0.1.1.jar" $ exists "target/lazy-package-name-0.1.1.jar"
[success]
> clean > clean
[success]
> increment-version > increment-version
[success]
> package > package
[success]
$ exists "target/lazy-package-name-0.1.2.jar" $ exists "target/lazy-package-name-0.1.2.jar"
[success]
> increment-version > increment-version
[success]
> package > package
[success] $ exists "target/lazy-package-name-0.1.3.jar"
$ exists "target/lazy-package-name-0.1.3.jar"
[success]

View File

@ -2,15 +2,14 @@ import sbt._
class ManifestTestProject(info: ProjectInfo) extends DefaultProject(info) class ManifestTestProject(info: ProjectInfo) extends DefaultProject(info)
{ {
val scalaHome = system[String]("scala.home")
override def mainClass = Some("jartest.Main") override def mainClass = Some("jartest.Main")
def manifestExtra = def manifestExtra =
{ {
import java.util.jar._ import java.util.jar._
val mf = new Manifest val mf = new Manifest
for(scalaH <- scalaHome.get) mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, buildScalaInstance.libraryJar.getAbsolutePath)
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, scalaH + "/lib/scala-library.jar")
mf mf
} }
override def packageOptions = JarManifest(manifestExtra) :: super.packageOptions.toList override def packageOptions = JarManifest(manifestExtra) :: super.packageOptions.toList
override def disableCrossPaths = true
} }

View File

@ -1,11 +1,4 @@
> package > package
[success] $ exists "./target/jar-manifest-test-0.2.jar"
$ "exists" "./target/jar-manifest-test-0.2.jar"
[success]
$ exec java -jar "./target/jar-manifest-test-0.2.jar" $ exec java -jar "./target/jar-manifest-test-0.2.jar"
[success] > run
> run
[success]

View File

@ -2,15 +2,14 @@ import sbt._
class ManifestTestProject(info: ProjectInfo) extends DefaultProject(info) class ManifestTestProject(info: ProjectInfo) extends DefaultProject(info)
{ {
val scalaHome = system[String]("scala.home")
override def mainClass = Some("jartest.Main") override def mainClass = Some("jartest.Main")
def manifestExtra = def manifestExtra =
{ {
import java.util.jar._ import java.util.jar._
val mf = new Manifest val mf = new Manifest
for(scalaH <- scalaHome.get) mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, buildScalaInstance.libraryJar.getAbsolutePath)
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, scalaH + "/lib/scala-library.jar")
mf mf
} }
override def packageOptions = JarManifest(manifestExtra) :: super.packageOptions.toList override def packageOptions = JarManifest(manifestExtra) :: super.packageOptions.toList
override def disableCrossPaths = true
} }

View File

@ -4,33 +4,27 @@
# This should fail because the Main object is in package jartest and the resource is directly # This should fail because the Main object is in package jartest and the resource is directly
# in src/main/resources # in src/main/resources
> run -> run
[failure]
> package > package
[success]
# This should fail because sbt should include the resource in the jar but it won't have the right # This should fail because sbt should include the resource in the jar but it won't have the right
# directory structure # directory structure
$ exec java -jar "./target/main-resources-test-0.1.jar" -$ exec java -jar "./target/main-resources-test-0.1.jar"
[failure]
# Give the resource the right directory structure # Give the resource the right directory structure
$ mkdir src/main/resources/jartest [success] $ mkdir src/main/resources/jartest
$ copy-file src/main/resources/main_resource_test src/main/resources/jartest/main_resource_test [success] $ copy-file src/main/resources/main_resource_test src/main/resources/jartest/main_resource_test
$ delete src/main/resources/main_resource_test [success] $ delete src/main/resources/main_resource_test
# This should succeed because sbt should put the resource on the runClasspath # This should succeed because sbt should put the resource on the runClasspath
> run > run
[success]
# This is necessary because package bases whether or not to run on last modified times, which don't have # This is necessary because package bases whether or not to run on last modified times, which don't have
# high enough resolution to notice the above move of main_resource_test # high enough resolution to notice the above move of main_resource_test
> clean [success] > clean
> package > package
[success]
# This should succeed because sbt should include the resource in the jar with the right directory structure # This should succeed because sbt should include the resource in the jar with the right directory structure
$ exec java -jar "./target/main-resources-test-0.1.jar" $ exec java -jar "./target/main-resources-test-0.1.jar"
[success]

View File

@ -1,5 +1,4 @@
> project "Sub project A"
> get sbt.version
$ absent a/project $ absent a/project
[success] $ absent b/project
$ absent b/project
[success]

View File

@ -1,5 +1,4 @@
> project "Sub project A"
> get sbt.version
$ absent a/project $ absent a/project
[success] $ absent b/project
$ absent b/project
[success]

View File

@ -1,2 +1 @@
> run > run
[success]

View File

@ -1,2 +1 @@
> run > run
[success]

View File

@ -0,0 +1,4 @@
object Spawn
{
def main(args: Array[String]) { System.exit(1); }
}

View File

@ -0,0 +1,4 @@
object Spawn
{
def main(args: Array[String]) { System.exit(0); }
}

View File

@ -1,16 +1,18 @@
$ copy-file changes/RunSuccess.scala src/main/scala/Run.scala $ copy-file changes/RunSuccess.scala src/main/scala/Run.scala
[success]
> run > run
[success]
# an exception in the main thread should be a nonzero exit code # an exception in the main thread should be a nonzero exit code
$ copy-file changes/RunFailureMain.scala src/main/scala/Run.scala $ copy-file changes/RunFailureMain.scala src/main/scala/Run.scala
[success] -> run
> run
[failure]
# an exception in a non-main thread should still be exit code 0 # an exception in a non-main thread should still be exit code 0
$ copy-file changes/ThreadRunError.scala src/main/scala/Run.scala $ copy-file changes/ThreadRunError.scala src/main/scala/Run.scala
[success]
> run > run
[success]
# explicitly calling System.exit(0) should succeed
$ copy-file changes/RunExplicitSuccess.scala src/main/scala/Run.scala
> run
# explicitly calling System.exit(1) should fail the 'run' task
$ copy-file changes/RunExplicitFailure.scala src/main/scala/Run.scala
-> run

View File

@ -1,2 +1 @@
> run > run
[success]

View File

@ -1,2 +1 @@
> run > run
[success]

View File

@ -1,11 +1,4 @@
> update > update
[success]
> jetty-run > jetty-run
[success]
> check-page > check-page
[success] > jetty-stop
> jetty-stop
[success]