From b74645256ed43b605a171d37d1f0a9ad5e4ff673 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Thu, 9 Jul 2015 22:18:35 -0700 Subject: [PATCH 1/4] Fix #51 Test compat for -Xxml:coalescing Rather than maintain a test to compile under multiple regimes, just build under `-Xxml:coalescing`. A few other flags are supplied. Deprecation is not yet possible because of `WordExp` et al. Renamed test classes `A` and `B` because sometimes it's nice to have a type parameter called `A` or `B`. --- build.sbt | 5 +++- .../scala/scala/xml/dtd/ContentModel.scala | 23 ++++++++++++++----- .../scala/xml/dtd/impl/WordBerrySethi.scala | 1 + .../scala/scala/xml/pull/XMLEventReader.scala | 2 +- src/test/scala/scala/xml/ShouldCompile.scala | 6 ++--- src/test/scala/scala/xml/XMLTest.scala | 2 ++ 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index f38d0da04..97a1ae4b7 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,10 @@ version := "1.0.5-SNAPSHOT" scalaVersion := crossScalaVersions.value.head -crossScalaVersions := Seq("2.11.6", "2.12.0-M1") +crossScalaVersions := Seq("2.11.7", "2.12.0-M1") + +//scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xfatal-warnings -Xxml:coalescing".split("\\s+").to[Seq] +scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xxml:coalescing".split("\\s+").to[Seq] // important!! must come here (why?) scalaModuleOsgiSettings diff --git a/src/main/scala/scala/xml/dtd/ContentModel.scala b/src/main/scala/scala/xml/dtd/ContentModel.scala index 73dcb8fc2..afd47ed8e 100644 --- a/src/main/scala/scala/xml/dtd/ContentModel.scala +++ b/src/main/scala/scala/xml/dtd/ContentModel.scala @@ -14,11 +14,21 @@ import scala.xml.dtd.impl._ import scala.xml.Utility.sbToString import PartialFunction._ +/* +@deprecated("Avoidance", since="2.10") +trait ContentModelLaundry extends WordExp +object ContentModelLaundry extends ContentModelLaundry { +} +*/ + object ContentModel extends WordExp { + type _labelT = ElemName type _regexpT = RegExp - object Translator extends WordBerrySethi { + @deprecated("Avoidance", since="2.10") + trait Translator extends WordBerrySethi + object Translator extends Translator { override val lang: ContentModel.this.type = ContentModel.this } @@ -72,7 +82,6 @@ object ContentModel extends WordExp { case Letter(ElemName(name)) => sb.append(name) } - } sealed abstract class ContentModel { @@ -80,6 +89,8 @@ sealed abstract class ContentModel { def buildString(sb: StringBuilder): StringBuilder } +import ContentModel.RegExp + case object PCDATA extends ContentModel { override def buildString(sb: StringBuilder): StringBuilder = sb.append("(#PCDATA)") } @@ -91,7 +102,7 @@ case object ANY extends ContentModel { } sealed abstract class DFAContentModel extends ContentModel { import ContentModel.{ ElemName, Translator } - def r: ContentModel.RegExp + def r: RegExp lazy val dfa: DetWordAutom[ElemName] = { val nfa = Translator.automatonFrom(r, 1) @@ -99,8 +110,8 @@ sealed abstract class DFAContentModel extends ContentModel { } } -case class MIXED(r: ContentModel.RegExp) extends DFAContentModel { - import ContentModel.{ Alt, RegExp } +case class MIXED(r: RegExp) extends DFAContentModel { + import ContentModel.Alt override def buildString(sb: StringBuilder): StringBuilder = { val newAlt = r match { case Alt(rs@_*) => Alt(rs drop 1: _*) } @@ -111,7 +122,7 @@ case class MIXED(r: ContentModel.RegExp) extends DFAContentModel { } } -case class ELEMENTS(r: ContentModel.RegExp) extends DFAContentModel { +case class ELEMENTS(r: RegExp) extends DFAContentModel { override def buildString(sb: StringBuilder): StringBuilder = ContentModel.buildString(r, sb) } diff --git a/src/main/scala/scala/xml/dtd/impl/WordBerrySethi.scala b/src/main/scala/scala/xml/dtd/impl/WordBerrySethi.scala index 3acc06435..2a5a5ce30 100644 --- a/src/main/scala/scala/xml/dtd/impl/WordBerrySethi.scala +++ b/src/main/scala/scala/xml/dtd/impl/WordBerrySethi.scala @@ -19,6 +19,7 @@ import scala.collection.{ immutable, mutable } * @version 1.0 */ // TODO: still used in ContentModel -- @deprecated("This class will be removed", "2.10.0") +@deprecated("This class will be removed", "2.10.0") private[dtd] abstract class WordBerrySethi extends BaseBerrySethi { override val lang: WordExp diff --git a/src/main/scala/scala/xml/pull/XMLEventReader.scala b/src/main/scala/scala/xml/pull/XMLEventReader.scala index 60843ed33..a2c266276 100755 --- a/src/main/scala/scala/xml/pull/XMLEventReader.scala +++ b/src/main/scala/scala/xml/pull/XMLEventReader.scala @@ -122,7 +122,7 @@ trait ProducerConsumerIterator[T >: Null] extends Iterator[T] { // defaults to unbounded - override to positive Int if desired val MaxQueueSize = -1 - def interruptibly[T](body: => T): Option[T] = try Some(body) catch { + def interruptibly[A](body: => A): Option[A] = try Some(body) catch { case _: InterruptedException => Thread.currentThread.interrupt(); None case _: ClosedChannelException => None diff --git a/src/test/scala/scala/xml/ShouldCompile.scala b/src/test/scala/scala/xml/ShouldCompile.scala index f2ddffce5..c05bdc503 100644 --- a/src/test/scala/scala/xml/ShouldCompile.scala +++ b/src/test/scala/scala/xml/ShouldCompile.scala @@ -22,11 +22,11 @@ class Foo { } // t2281 -class A { +class t2281A { def f(x: Boolean) = if (x)

else
} -class B { +class t2281B { def splitSentences(text: String): ArrayBuffer[String] = { val outarr = new ArrayBuffer[String] var outstr = new StringBuffer @@ -92,4 +92,4 @@ object shouldCompile { case 1 => case 2 =>

} -} \ No newline at end of file +} diff --git a/src/test/scala/scala/xml/XMLTest.scala b/src/test/scala/scala/xml/XMLTest.scala index 23c143396..6ab741390 100644 --- a/src/test/scala/scala/xml/XMLTest.scala +++ b/src/test/scala/scala/xml/XMLTest.scala @@ -1,5 +1,7 @@ package scala.xml +import language.postfixOps + import org.junit.{Test => UnitTest} import org.junit.Ignore import org.junit.runner.RunWith From 5fae850bebf4f404d957d6fd888c9adc78caf4da Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Tue, 21 Jul 2015 16:57:49 -0400 Subject: [PATCH 2/4] build for 2.12.0-M2 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 97a1ae4b7..e33592798 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ version := "1.0.5-SNAPSHOT" scalaVersion := crossScalaVersions.value.head -crossScalaVersions := Seq("2.11.7", "2.12.0-M1") +crossScalaVersions := Seq("2.11.7", "2.12.0-M2") //scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xfatal-warnings -Xxml:coalescing".split("\\s+").to[Seq] scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xxml:coalescing".split("\\s+").to[Seq] From bc859b1b046baac19c474d325c500d7bf3d8f9d2 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Tue, 21 Jul 2015 17:09:37 -0400 Subject: [PATCH 3/4] better to confine -Xxml:coalescing to `in Test` --- build.sbt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e33592798..ee6011de4 100644 --- a/build.sbt +++ b/build.sbt @@ -11,7 +11,9 @@ scalaVersion := crossScalaVersions.value.head crossScalaVersions := Seq("2.11.7", "2.12.0-M2") //scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xfatal-warnings -Xxml:coalescing".split("\\s+").to[Seq] -scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xxml:coalescing".split("\\s+").to[Seq] +scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_".split("\\s+").to[Seq] + +scalacOptions in Test += "-Xxml:coalescing" // important!! must come here (why?) scalaModuleOsgiSettings From 38fbbbeeff6bc97c4438e3e37041894c93538e46 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Tue, 21 Jul 2015 17:16:09 -0400 Subject: [PATCH 4/4] redo how crossScalaVersions works the old scheme was: run tests on openjdk7 too, but only publish (for all Scala versions) from openjdk6 this is no longer appropriate now that Scala 2.12.0-M2 requires Java 8. now we want to publish for older Scala versions using JDK 6, but newer versions (M2 and above) using JDK 8. this commit does that. currently Travis doesn't offer OpenJDK 8, so we use Oracle. leaving our JDK 6 setting as "openjdk6" since that's what it's historically been so why rock the boat. what happened to running tests on JDK 7? well, neither Lukas nor I knows why it was even doing that. --- .travis.yml | 3 +-- admin/README.md | 5 ++--- admin/build.sh | 2 +- build.sbt | 14 +++++++++++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9a80fe916..80dde716f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: scala env: global: - - PUBLISH_JDK=openjdk6 # PGP_PASSPHRASE - secure: "BYC1kEnHjNrINrHYWPGEuTTJ2V340/0ByzqeihLecjoZ75yrjWdsh6MI1JEUWgv5kb+58vLzib21JfnjsPK6Yb2bSXuCFCsEtJNh6RJKgxkWlCOzfTSh5I2wl7PCjRClRL6gseX2uTSvFjL4Z//pmxwxeXlLp7voQe4QAUq1+sE=" # SONA_USER @@ -14,7 +13,7 @@ script: admin/build.sh jdk: - openjdk6 - - openjdk7 + - oraclejdk8 notifications: email: adriaan.moors@typesafe.com diff --git a/admin/README.md b/admin/README.md index 55ae9c8ae..d84727a74 100644 --- a/admin/README.md +++ b/admin/README.md @@ -19,7 +19,8 @@ To configure tag driven releases from Travis CI. Edit `.travis.yml` as prompted. 4. Edit `.travis.yml` to use `./admin/build.sh` as the build script, and edit that script to use the tasks required for this project. - 5. Edit `.travis.yml` to select which JDK will be used for publishing. + 5. Edit `build.sbt` to select which JDK will be used for publishing + for which Scala versions. It is important to add comments in .travis.yml to identify the name of each environment variable encoded in a `:secure` section. @@ -30,7 +31,6 @@ form: language: scala env: global: - - PUBLISH_JDK=openjdk6 # PGP_PASSPHRASE - secure: "XXXXXX" # SONA_USER @@ -58,4 +58,3 @@ Be sure to use SBT 0.13.7 or higher to avoid [#1430](https://github.com/sbt/sbt/ 3. Log into https://oss.sonatype.org/ and identify the staging repository. 4. Sanity check its contents 5. Release staging repository to Maven and send out release announcement. - diff --git a/admin/build.sh b/admin/build.sh index 34f5ccda1..bdd8490de 100755 --- a/admin/build.sh +++ b/admin/build.sh @@ -7,7 +7,7 @@ set -e # git on travis does not fetch tags, but we have TRAVIS_TAG # headTag=$(git describe --exact-match ||:) -if [ "$TRAVIS_JDK_VERSION" == "$PUBLISH_JDK" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then +if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then echo "Going to release from tag $TRAVIS_TAG!" myVer=$(echo $TRAVIS_TAG | sed -e s/^v//) publishVersion='set every version := "'$myVer'"' diff --git a/build.sbt b/build.sbt index ee6011de4..dc924849d 100644 --- a/build.sbt +++ b/build.sbt @@ -8,9 +8,17 @@ version := "1.0.5-SNAPSHOT" scalaVersion := crossScalaVersions.value.head -crossScalaVersions := Seq("2.11.7", "2.12.0-M2") - -//scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_ -Xfatal-warnings -Xxml:coalescing".split("\\s+").to[Seq] +crossScalaVersions := { + val java = System.getProperty("java.version") + if (java.startsWith("1.6.")) + Seq("2.11.7", "2.12.0-M1") + else if (java.startsWith("1.8.")) + Seq("2.12.0-M2") + else + sys.error(s"don't know what Scala versions to build on $java") +} + +//reenable -Xfatal-warnings? scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_".split("\\s+").to[Seq] scalacOptions in Test += "-Xxml:coalescing"