Skip to content

Commit 55cce77

Browse files
committed
Merge branch 'cheeseng-module-projects' into 3.1.x
2 parents 6ca0fe0 + fa0ee13 commit 55cce77

File tree

15 files changed

+1937
-1072
lines changed

15 files changed

+1937
-1072
lines changed

build.sbt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,16 @@ lazy val genEmptyTests = ScalatestBuild.genEmptyTests
4747
lazy val gentests = ScalatestBuild.gentests
4848
lazy val examples = ScalatestBuild.examples
4949
lazy val examplesJS = ScalatestBuild.examplesJS
50+
lazy val scalatestCompatible = ScalatestBuild.scalatestCompatible
51+
lazy val scalatestCore = ScalatestBuild.scalatestCore
52+
lazy val scalatestFeatureSpec = ScalatestBuild.scalatestFeatureSpec
53+
lazy val scalatestFlatSpec = ScalatestBuild.scalatestFlatSpec
54+
lazy val scalatestFreeSpec = ScalatestBuild.scalatestFreeSpec
55+
lazy val scalatestFunSuite = ScalatestBuild.scalatestFunSuite
56+
lazy val scalatestPropSpec = ScalatestBuild.scalatestPropSpec
57+
lazy val scalatestRefSpec = ScalatestBuild.scalatestRefSpec
58+
lazy val scalatestWordSpec = ScalatestBuild.scalatestWordSpec
59+
lazy val scalatestDiagrams = ScalatestBuild.scalatestDiagrams
60+
lazy val scalatestMatchersCore = ScalatestBuild.scalatestMatchersCore
61+
lazy val scalatestShouldMatchers = ScalatestBuild.scalatestShouldMatchers
62+
lazy val scalatestMustMatchers = ScalatestBuild.scalatestMustMatchers
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2001-2018 Artima, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.scalatest
17+
18+
/**
19+
* Classes and traits supporting ScalaTest's "fixture" style traits, which
20+
* allow you to pass fixture objects into tests.
21+
*
22+
* This package is released as part of the `scalatest-core` module.
23+
*/
24+
package object fixture
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright 2001-2013 Artima, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org
17+
18+
/**
19+
* ScalaTest's main traits, classes, and other members, including members supporting ScalaTest's DSL for the Scala interpreter.
20+
*/
21+
package object scalatest {
22+
23+
// SKIP-SCALATESTJS,NATIVE-START
24+
private val defaultShell = ShellImpl()
25+
26+
/**
27+
* Returns a copy of this <code>Shell</code> with <code>colorPassed</code> configuration parameter set to <code>true</code>.
28+
*/
29+
lazy val color: Shell = defaultShell.color
30+
31+
/**
32+
* Returns a copy of this <code>Shell</code> with <code>durationsPassed</code> configuration parameter set to <code>true</code>.
33+
*/
34+
lazy val durations: Shell = defaultShell.durations
35+
36+
/**
37+
* Returns a copy of this <code>Shell</code> with <code>shortStacksPassed</code> configuration parameter set to <code>true</code>.
38+
*/
39+
lazy val shortstacks: Shell = defaultShell.shortstacks
40+
41+
/**
42+
* Returns a copy of this <code>Shell</code> with <code>fullStacksPassed</code> configuration parameter set to <code>true</code>.
43+
*/
44+
lazy val fullstacks: Shell = defaultShell.fullstacks
45+
46+
/**
47+
* Returns a copy of this <code>Shell</code> with <code>statsPassed</code> configuration parameter set to <code>true</code>.
48+
*/
49+
lazy val stats: Shell = defaultShell.stats
50+
51+
/**
52+
* Returns a copy of this <code>Shell</code> with <code>colorPassed</code> configuration parameter set to <code>false</code>.
53+
*/
54+
lazy val nocolor: Shell = defaultShell.nocolor
55+
56+
/**
57+
* Returns a copy of this <code>Shell</code> with <code>durationsPassed</code> configuration parameter set to <code>false</code>.
58+
*/
59+
lazy val nodurations: Shell = defaultShell.nodurations
60+
61+
/**
62+
* Returns a copy of this <code>Shell</code> with <code>shortStacksPassed</code> configuration parameter set to <code>false</code>.
63+
*/
64+
lazy val nostacks: Shell = defaultShell.nostacks
65+
66+
/**
67+
* Returns a copy of this <code>Shell</code> with <code>statsPassed</code> configuration parameter set to <code>false</code>.
68+
*/
69+
lazy val nostats: Shell = defaultShell.nostats
70+
// SKIP-SCALATESTJS,NATIVE-END
71+
72+
/**
73+
* The version number of ScalaTest.
74+
*
75+
* @return the ScalaTest version number.
76+
*/
77+
val ScalaTestVersion: String = ScalaTestVersions.ScalaTestVersion
78+
79+
private[scalatest] type Expectation = Fact
80+
81+
/**
82+
* Marker trait that serves as the result type of <code>assert</code>, <code>assume</code>, and <code>pending</code> methods of
83+
* trait <code>Assertions</code>, which return its only instance, the <code>Succeeded</code> singleton, or throw
84+
* an exception that indicates a failed, canceled, or pending test.
85+
*/
86+
type Assertion = compatible.Assertion
87+
}

project/BuildCommons.scala

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import sbt._
2+
import Keys._
3+
import java.io.PrintWriter
4+
import scala.io.Source
5+
6+
trait BuildCommons {
7+
8+
lazy val supportedScalaVersions = List("2.13.0", "2.12.8", "2.11.12", "2.10.7")
9+
10+
val releaseVersion = "3.1.0-SNAP13"
11+
12+
val previousReleaseVersion = "3.0.5"
13+
14+
def rootProject: Project
15+
16+
def scalaXmlDependency(theScalaVersion: String): Seq[ModuleID]
17+
18+
def scalatestLibraryDependencies: Seq[ModuleID]
19+
20+
def scalaLibraries(theScalaVersion: String): Seq[ModuleID]
21+
22+
def sharedSettings: Seq[Setting[_]]
23+
24+
def scalacticDocSettings: Seq[Setting[_]]
25+
26+
def scalatestDocSettings: Seq[Setting[_]]
27+
28+
def scalatestJSDocTaskSetting: Setting[_]
29+
30+
def crossBuildTestLibraryDependencies: sbt.Def.Initialize[Seq[sbt.ModuleID]]
31+
32+
def scalatestTestOptions: Seq[sbt.TestOption]
33+
34+
lazy val projectTitle = settingKey[String]("Name of project to display in doc titles")
35+
36+
val javaSourceManaged: SettingKey[java.io.File] = sbt.SettingKey[java.io.File]("javaSourceManaged")
37+
38+
//
39+
// Prepares source files for running scaladoc.
40+
//
41+
def genDocSources(srcFiles: Seq[File],
42+
srcDirs: Seq[File],
43+
docsrcDir: File): Seq[File] =
44+
{
45+
val scalaFiles =
46+
for {
47+
srcFile <- srcFiles
48+
if srcFile.name.endsWith(".scala")
49+
} yield {
50+
val srcPath = srcFile.getPath
51+
val maybeSourceFile = srcDirs.flatMap(srcFile.relativeTo).headOption
52+
maybeSourceFile match {
53+
case Some(docsrcFile) => copyDocFile(srcFile, new File(docsrcDir.asFile, docsrcFile.getPath))
54+
case None =>
55+
throw new RuntimeException("unexpected source path ["+ srcPath +"] not relative to " + srcDirs.mkString("[", ", ", "]"))
56+
}
57+
}
58+
59+
val javaSources = srcFiles.filter(_.name.endsWith(".java")).toSet
60+
val javaTagFiles = JavaTagDocumenter.docJavaTags(javaSources)
61+
62+
scalaFiles ++ javaTagFiles
63+
}
64+
65+
//
66+
// Copies a file, doing a little filtering along the way to make
67+
// destination file suitable for use in generating scaladocs.
68+
//
69+
// Returns destination file.
70+
//
71+
private def copyDocFile(srcFile: File, destFile: File): File = {
72+
if (!destFile.exists || (destFile.lastModified < srcFile.lastModified)) {
73+
IO.createDirectory(file(destFile.getParent))
74+
75+
val writer = new PrintWriter(destFile)
76+
77+
try {
78+
for (line <- Source.fromFile(srcFile).getLines)
79+
writer.println(line.replaceFirst("@Finders(.*)", ""))
80+
}
81+
finally { writer.close }
82+
}
83+
destFile
84+
}
85+
86+
//
87+
// Adds customization to scaladocs.
88+
//
89+
// Appends additional css to template.css file and copies
90+
// additional gifs into lib directory.
91+
//
92+
// Note: found that adding new gifs into lib directory causes
93+
// doc task to rebuild scaladocs from scratch each time.
94+
// Without that it only rebuilds if needed.
95+
//
96+
def docTask(docDir: File, resDir: File, projectName: String): File = {
97+
val docLibDir = docDir / "lib"
98+
val htmlSrcDir = resDir / "html"
99+
val cssFile = docLibDir / "template.css"
100+
val addlCssFile = htmlSrcDir / "addl.css"
101+
102+
val css = Source.fromFile(cssFile).mkString
103+
val addlCss = Source.fromFile(addlCssFile).mkString
104+
105+
if (!css.contains("pre.stHighlighted")) {
106+
val writer = new PrintWriter(cssFile)
107+
108+
try {
109+
writer.println(css)
110+
writer.println(addlCss)
111+
}
112+
finally { writer.close }
113+
}
114+
115+
if (projectName.contains("scalatest")) {
116+
(htmlSrcDir * "*.gif").get.foreach { gif =>
117+
IO.copyFile(gif, docLibDir / gif.name)
118+
}
119+
}
120+
docDir
121+
}
122+
123+
lazy val docsrcDir =
124+
settingKey[File](
125+
"Directory to hold processed source files for generating scaladocs")
126+
127+
val docsrcDirSetting =
128+
docsrcDir := target.value / "docsrc"
129+
130+
val docTaskSetting =
131+
doc in Compile := docTask((doc in Compile).value,
132+
(sourceDirectory in Compile).value,
133+
name.value)
134+
}

0 commit comments

Comments
 (0)