* 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'.*/
val originalThreads = allThreads
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 executionThread = new Thread(customThreadGroup, "run-main") { override def run() { executeMain } }

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class InfoTest(info: ProjectInfo) extends DefaultProject(info)
override def ivyXML =
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" />
<description homepage="http://github.com/szeiger/scala-query/">
ScalaQuery is a type-safe database query API for Scala.

View File

@ -1,13 +1,13 @@
> update [success]
> check-download [success]
> deliver-local [success]
> check-info [success]
> update
> check-download
> deliver-local
> check-info
> clean [success]
> clean-lib [success]
$ touch info [success]
> clean
> clean-lib
$ touch info
> update [success]
> check-download [success]
> deliver-local [success]
> check-info [success]
> update
> check-download
> deliver-local
> 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
> update
[failure]
# Copy the project definition with the extra repository declared in the parent and reload
$ copy-file changes/CorrectProject.scala project/build/src/TestProject.scala
[success]
$ reload
[success]
# Try updating again, which should work because the repository declared in the parent should be inherited by the child
> update
[success]
# 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
[success]
$ reload
[success]
> update
[success]
# Copy the project definition with the extra repository declared in the child and reload
$ copy-file changes/CorrectProject3.scala project/build/src/TestProject.scala
[success]
$ reload
[success]
> update
[success]
> update

View File

@ -5,8 +5,7 @@ class TestProject(info: ProjectInfo) extends DefaultProject(info)
val httpclient = "org.apache.httpcomponents" % "httpclient" % "4.0-beta2" intransitive()
override def useDefaultConfigurations =
if("useDefaultConfigurations".asFile.exists) true
else false
if("useDefaultConfigurations".asFile.exists) true else false
lazy val checkDefault = task { check(Configurations.Default) }
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
> update
[success]
# The jar should exist in the 'default' configuration ...
> check-default
[success]
# but not in the 'compile' configuration ...
> check-compile
[failure]
-> check-compile
# It should be present on the compile classpath
> check-classpath
[success]
# reset test
> clean-lib
[success]
# Indicate to the project definition that we now want useDefaultConfigurations = true
$ touch useDefaultConfigurations
[success]
# Reload for change to take effect
$ reload
[success]
## Rerun test with useDefaultConfigurations=true
# Download jars. If successful, httpclient should be downloaded to the 'compile' configuration
> update
[success]
# The jar should not exist in the 'default' configuration ...
> check-default
[failure]
-> check-default
# It should exist in the 'compile' configuration
> check-compile
[success]
# It should be present on the compile classpath
> check-classpath
[success]

View File

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

View File

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

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
[success]
$ copy-file changes/scalacheck-ivy.xml ivy.xml
[success]
> update
[failure]
-> update
$ absent lib_managed/default/scalacheck-1.5.jar
[success]
$ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml
[success]
> update
[success]
$ exists lib_managed/default/scalacheck-1.5.jar
[success]
$ exists lib_managed/default/scalacheck-1.5.jar

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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
[success]
$ exists "target/lazy-package-name-0.1.1.jar"
[success]
> clean
[success]
> increment-version
[success]
> package
[success]
$ exists "target/lazy-package-name-0.1.2.jar"
[success]
> increment-version
[success]
> package
[success]
$ exists "target/lazy-package-name-0.1.3.jar"
[success]
$ exists "target/lazy-package-name-0.1.3.jar"

View File

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

View File

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

View File

@ -2,15 +2,14 @@ import sbt._
class ManifestTestProject(info: ProjectInfo) extends DefaultProject(info)
{
val scalaHome = system[String]("scala.home")
override def mainClass = Some("jartest.Main")
def manifestExtra =
{
import java.util.jar._
val mf = new Manifest
for(scalaH <- scalaHome.get)
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, scalaH + "/lib/scala-library.jar")
mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, buildScalaInstance.libraryJar.getAbsolutePath)
mf
}
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
# in src/main/resources
> run
[failure]
-> run
> package
[success]
# This should fail because sbt should include the resource in the jar but it won't have the right
# directory structure
$ exec java -jar "./target/main-resources-test-0.1.jar"
[failure]
-$ exec java -jar "./target/main-resources-test-0.1.jar"
# Give the resource the right directory structure
$ mkdir src/main/resources/jartest [success]
$ copy-file src/main/resources/main_resource_test src/main/resources/jartest/main_resource_test [success]
$ delete src/main/resources/main_resource_test [success]
$ mkdir src/main/resources/jartest
$ copy-file src/main/resources/main_resource_test src/main/resources/jartest/main_resource_test
$ delete src/main/resources/main_resource_test
# This should succeed because sbt should put the resource on the runClasspath
> run
[success]
# 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
> clean [success]
> clean
> package
[success]
# 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"
[success]
$ exec java -jar "./target/main-resources-test-0.1.jar"

View File

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

View File

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

View File

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

View File

@ -1,2 +1 @@
> 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
[success]
> run
[success]
# an exception in the main thread should be a nonzero exit code
$ copy-file changes/RunFailureMain.scala src/main/scala/Run.scala
[success]
> run
[failure]
-> run
# an exception in a non-main thread should still be exit code 0
$ copy-file changes/ThreadRunError.scala src/main/scala/Run.scala
[success]
> 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
[success]
> run

View File

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

View File

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