mirror of https://github.com/sbt/sbt.git
Add scala-stm file for unit test.
This commit is contained in:
parent
50ed84b748
commit
ddc80357dc
|
|
@ -23,10 +23,13 @@ private[sbt] object SbtParser {
|
||||||
sealed trait ParsedSbtFileExpressions {
|
sealed trait ParsedSbtFileExpressions {
|
||||||
/** The set of parsed import expressions. */
|
/** The set of parsed import expressions. */
|
||||||
def imports: Seq[(String, Int)]
|
def imports: Seq[(String, Int)]
|
||||||
|
|
||||||
/** The set of parsed defintions and/or sbt build settings. */
|
/** The set of parsed defintions and/or sbt build settings. */
|
||||||
def settings: Seq[(String, LineRange)]
|
def settings: Seq[(String, LineRange)]
|
||||||
|
|
||||||
/** The set of scala tree's for parsed definitions/settings and the underlying string representation.. */
|
/** The set of scala tree's for parsed definitions/settings and the underlying string representation.. */
|
||||||
def settingsTrees: Seq[(String, Tree)]
|
def settingsTrees: Seq[(String, Tree)]
|
||||||
|
|
||||||
/** Represents the changes we had to perform to the sbt file so that XML will parse correctly. */
|
/** Represents the changes we had to perform to the sbt file so that XML will parse correctly. */
|
||||||
def modifiedContent: String
|
def modifiedContent: String
|
||||||
}
|
}
|
||||||
|
|
@ -229,13 +232,17 @@ private[sbt] object XmlContent {
|
||||||
(accSeqIndex, el) =>
|
(accSeqIndex, el) =>
|
||||||
val (statement, startIndex, endIndex) = el
|
val (statement, startIndex, endIndex) = el
|
||||||
val (accSeq, index) = accSeqIndex
|
val (accSeq, index) = accSeqIndex
|
||||||
val textStatementOption = if (index >= startIndex) {
|
val (st, textStatementOption) = if (index >= startIndex) {
|
||||||
None
|
(statement, None)
|
||||||
} else {
|
} else {
|
||||||
val s = content.substring(index, startIndex)
|
val s = content.substring(index, startIndex)
|
||||||
Some((s, false))
|
if (s.trim.isEmpty) {
|
||||||
|
(statement + s, None)
|
||||||
|
} else {
|
||||||
|
(statement, Some((s, false)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
val newAccSeq = (statement, true) +: addOptionToCollection(accSeq, textStatementOption)
|
val newAccSeq = (st, true) +: addOptionToCollection(accSeq, textStatementOption)
|
||||||
(newAccSeq, endIndex)
|
(newAccSeq, endIndex)
|
||||||
}
|
}
|
||||||
val endOfFile = content.substring(index, content.length)
|
val endOfFile = content.substring(index, content.length)
|
||||||
|
|
@ -352,18 +359,22 @@ private[sbt] object XmlContent {
|
||||||
* @return content with xml with brackets
|
* @return content with xml with brackets
|
||||||
*/
|
*/
|
||||||
private def addExplicitXmlContent(content: String, xmlParts: Seq[(String, Int, Int)]): String = {
|
private def addExplicitXmlContent(content: String, xmlParts: Seq[(String, Int, Int)]): String = {
|
||||||
val statements: Seq[(String, Boolean)] = splitFile(content, xmlParts)
|
val statementsXml = splitFile(content, xmlParts)
|
||||||
val (correctedStmt, shouldAddCloseBrackets, wasXml, _) = addBracketsIfNecessary(statements)
|
val (correctedStmt, shouldAddCloseBrackets, wasXml, _) = addBracketsIfNecessary(statementsXml)
|
||||||
val closeIfNecessaryCorrectedStmt =
|
val closeIfNecessaryCorrectedStmt =
|
||||||
if (shouldAddCloseBrackets && wasXml) {
|
if (shouldAddCloseBrackets && wasXml) {
|
||||||
correctedStmt.head +: CLOSE_BRACKET +: correctedStmt.tail
|
if (correctedStmt.head.trim.isEmpty) {
|
||||||
|
CLOSE_BRACKET +: correctedStmt
|
||||||
|
} else {
|
||||||
|
correctedStmt.head +: CLOSE_BRACKET +: correctedStmt.tail
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
correctedStmt
|
correctedStmt
|
||||||
}
|
}
|
||||||
closeIfNecessaryCorrectedStmt.reverse.mkString
|
closeIfNecessaryCorrectedStmt.reverse.mkString
|
||||||
}
|
}
|
||||||
|
|
||||||
def addBracketsIfNecessary(statements: Seq[(String, Boolean)]): (Seq[String], Boolean, Boolean, String) = {
|
private def addBracketsIfNecessary(statements: Seq[(String, Boolean)]): (Seq[String], Boolean, Boolean, String) = {
|
||||||
statements.foldLeft((Seq.empty[String], false, false, "")) {
|
statements.foldLeft((Seq.empty[String], false, false, "")) {
|
||||||
case ((accStmt, shouldAddCloseBracket, prvWasXml, prvStmt), (stmt, isXml)) =>
|
case ((accStmt, shouldAddCloseBracket, prvWasXml, prvStmt), (stmt, isXml)) =>
|
||||||
if (stmt.trim.isEmpty) {
|
if (stmt.trim.isEmpty) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
*
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
|
||||||
|
name := "scala-stm"
|
||||||
|
|
||||||
|
organization := "org.scala-stm"
|
||||||
|
|
||||||
|
version := "0.8-SNAPSHOT"
|
||||||
|
|
||||||
|
scalaVersion := "2.11.2"
|
||||||
|
|
||||||
|
crossScalaVersions := Seq("2.11.2", "2.10.4", "2.9.3")
|
||||||
|
|
||||||
|
libraryDependencies += ("org.scalatest" %% "scalatest" % "[1.5,)" % "test")
|
||||||
|
|
||||||
|
libraryDependencies += ("junit" % "junit" % "4.5" % "test")
|
||||||
|
|
||||||
|
// skip exhaustive tests
|
||||||
|
testOptions += Tests.Argument("-l", "slow")
|
||||||
|
|
||||||
|
// test of TxnExecutor.transformDefault must be run by itself
|
||||||
|
parallelExecution in Test := false
|
||||||
|
|
||||||
|
////////////////////
|
||||||
|
// publishing
|
||||||
|
|
||||||
|
pomExtra :=
|
||||||
|
<url>http://nbronson.github.com/scala-stm/</url>
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>BSD</name>
|
||||||
|
<url>https://github.com/nbronson/scala-stm/blob/master/LICENSE.txt</url>
|
||||||
|
<distribution>repo</distribution>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:git@github.com:nbronson/scala-stm.git</connection>
|
||||||
|
<url>git@github.com:nbronson/scala-stm.git</url>
|
||||||
|
</scm>
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<id>nbronson</id>
|
||||||
|
<name>Nathan Bronson</name>
|
||||||
|
<email>ngbronson@gmail.com</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
publishMavenStyle := true
|
||||||
|
|
||||||
|
publishTo <<= (version) { v: String =>
|
||||||
|
val base = "https://oss.sonatype.org/"
|
||||||
|
if (v.trim.endsWith("SNAPSHOT"))
|
||||||
|
Some("snapshots" at base + "content/repositories/snapshots/")
|
||||||
|
else
|
||||||
|
Some("releases" at base + "service/local/staging/deploy/maven2/")
|
||||||
|
}
|
||||||
|
|
||||||
|
// exclude scalatest from the Maven POM
|
||||||
|
pomPostProcess := { xi: scala.xml.Node =>
|
||||||
|
import scala.xml._
|
||||||
|
val badDeps = (xi \\ "dependency") filter {
|
||||||
|
x => (x \ "artifactId").text != "scala-library"
|
||||||
|
} toSet
|
||||||
|
def filt(root: Node): Node = root match {
|
||||||
|
case x: Elem => {
|
||||||
|
val ch = x.child filter { !badDeps(_) } map { filt(_) }
|
||||||
|
Elem(x.prefix, x.label, x.attributes, x.scope, ch: _*)
|
||||||
|
}
|
||||||
|
case x => x
|
||||||
|
}
|
||||||
|
filt(xi)
|
||||||
|
}
|
||||||
|
|
||||||
|
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
|
||||||
Loading…
Reference in New Issue