mirror of https://github.com/sbt/sbt.git
Move tests with external requirements to it tests
This commit is contained in:
parent
1b0dd4e899
commit
72d0ac9728
|
|
@ -41,7 +41,7 @@ function isMasterOrDevelop() {
|
|||
|
||||
# TODO Add coverage once https://github.com/scoverage/sbt-scoverage/issues/111 is fixed
|
||||
|
||||
SBT_COMMANDS="compile test"
|
||||
SBT_COMMANDS="compile test it:test"
|
||||
|
||||
if echo "$TRAVIS_SCALA_VERSION" | grep -q "^2\.10"; then
|
||||
SBT_COMMANDS="$SBT_COMMANDS publishLocal" # to make the scripted tests happy
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ build_script:
|
|||
- sbt ++2.10.6 coreJVM/publishLocal cache/publishLocal # to make the scripted tests happy
|
||||
test_script:
|
||||
- ps: Start-Job { & java -jar -noverify C:\projects\coursier\coursier launch -r http://dl.bintray.com/scalaz/releases io.get-coursier:http-server-java7_2.11:1.0.0-SNAPSHOT -- -d /C:/projects/coursier/tests/jvm/src/test/resources/test-repo/http/abc.com -u user -P pass -r realm -v }
|
||||
- sbt ++2.11.8 testsJVM/test # Would node be around for testsJS/test?
|
||||
- sbt ++2.10.6 testsJVM/test plugin/scripted
|
||||
- sbt ++2.11.8 testsJVM/test testsJVM/it:test # Would node be around for testsJS/test?
|
||||
- sbt ++2.10.6 testsJVM/test testsJVM/it:test plugin/scripted
|
||||
cache:
|
||||
- C:\sbt\
|
||||
- C:\Users\appveyor\.ivy2
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import MimaKeys.{ previousArtifacts, binaryIssueFilters }
|
|||
|
||||
val binaryCompatibilityVersion = "1.0.0-M7"
|
||||
|
||||
lazy val IntegrationTest = config("it") extend Test
|
||||
|
||||
lazy val releaseSettings = Seq(
|
||||
publishMavenStyle := true,
|
||||
licenses := Seq("Apache 2.0" -> url("http://opensource.org/licenses/Apache-2.0")),
|
||||
|
|
@ -249,11 +251,13 @@ lazy val tests = crossProject
|
|||
.dependsOn(core)
|
||||
.settings(commonSettings: _*)
|
||||
.settings(noPublishSettings: _*)
|
||||
.configs(IntegrationTest)
|
||||
.settings(Defaults.itSettings: _*)
|
||||
.settings(
|
||||
name := "coursier-tests",
|
||||
libraryDependencies ++= Seq(
|
||||
"org.scala-lang.modules" %% "scala-async" % "0.9.5" % "provided",
|
||||
"com.lihaoyi" %%% "utest" % "0.4.3" % "test"
|
||||
"com.lihaoyi" %%% "utest" % "0.4.3" % "test,it"
|
||||
),
|
||||
unmanagedResourceDirectories in Test += (baseDirectory in LocalRootProject).value / "tests" / "shared" / "src" / "test" / "resources",
|
||||
testFrameworks += new TestFramework("utest.runner.Framework")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,70 @@
|
|||
package coursier.test
|
||||
|
||||
import utest._
|
||||
|
||||
import coursier.core.Authentication
|
||||
import coursier.maven.MavenRepository
|
||||
|
||||
object HttpAuthenticationTests extends TestSuite {
|
||||
|
||||
val tests = TestSuite {
|
||||
'httpAuthentication - {
|
||||
// requires an authenticated HTTP server to be running on localhost:8080 with user 'user'
|
||||
// and password 'pass'
|
||||
|
||||
val address = "localhost:8080"
|
||||
val user = "user"
|
||||
val password = "pass"
|
||||
|
||||
def printErrorMessage() =
|
||||
Console.err.println(
|
||||
Console.RED +
|
||||
s"HTTP authentication tests require a running HTTP server on $address, requiring " +
|
||||
s"basic authentication with user '$user' and password '$password', serving the right " +
|
||||
"files.\n" + Console.RESET +
|
||||
"Run one from the coursier sources with\n" +
|
||||
" ./coursier launch -r http://dl.bintray.com/scalaz/releases " +
|
||||
"io.get-coursier:simple-web-server_2.11:1.0.0-M12 -- " +
|
||||
"-d tests/jvm/src/test/resources/test-repo/http/abc.com -u user -P pass -r realm -v"
|
||||
)
|
||||
|
||||
* - {
|
||||
// no authentication -> should fail
|
||||
|
||||
val failed = try {
|
||||
CacheFetchTests.check(
|
||||
MavenRepository(
|
||||
s"http://$address"
|
||||
)
|
||||
)
|
||||
|
||||
printErrorMessage()
|
||||
false
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
true
|
||||
}
|
||||
|
||||
assert(failed)
|
||||
}
|
||||
|
||||
* - {
|
||||
// with authentication -> should work
|
||||
|
||||
try {
|
||||
CacheFetchTests.check(
|
||||
MavenRepository(
|
||||
s"http://$address",
|
||||
authentication = Some(Authentication(user, password))
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
printErrorMessage()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,55 +13,55 @@ import scala.util.Try
|
|||
|
||||
object CacheFetchTests extends TestSuite {
|
||||
|
||||
val tests = TestSuite {
|
||||
def check(extraRepo: Repository): Unit = {
|
||||
|
||||
def check(extraRepo: Repository): Unit = {
|
||||
val tmpDir = Files.createTempDirectory("coursier-cache-fetch-tests").toFile
|
||||
|
||||
val tmpDir = Files.createTempDirectory("coursier-cache-fetch-tests").toFile
|
||||
def cleanTmpDir() = {
|
||||
def delete(f: File): Boolean =
|
||||
if (f.isDirectory) {
|
||||
val removedContent = Option(f.listFiles()).toSeq.flatten.map(delete).forall(x => x)
|
||||
val removedDir = f.delete()
|
||||
|
||||
def cleanTmpDir() = {
|
||||
def delete(f: File): Boolean =
|
||||
if (f.isDirectory) {
|
||||
val removedContent = Option(f.listFiles()).toSeq.flatten.map(delete).forall(x => x)
|
||||
val removedDir = f.delete()
|
||||
removedContent && removedDir
|
||||
} else
|
||||
f.delete()
|
||||
|
||||
removedContent && removedDir
|
||||
} else
|
||||
f.delete()
|
||||
|
||||
if (!delete(tmpDir))
|
||||
Console.err.println(s"Warning: unable to remove temporary directory $tmpDir")
|
||||
}
|
||||
|
||||
val res = try {
|
||||
val fetch = Fetch.from(
|
||||
Seq(
|
||||
extraRepo,
|
||||
MavenRepository("https://repo1.maven.org/maven2")
|
||||
),
|
||||
Cache.fetch(
|
||||
tmpDir
|
||||
)
|
||||
)
|
||||
|
||||
val startRes = Resolution(
|
||||
Set(
|
||||
Dependency(
|
||||
Module("com.github.alexarchambault", "coursier_2.11"), "1.0.0-M9-test"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
startRes.process.run(fetch).run
|
||||
} finally {
|
||||
cleanTmpDir()
|
||||
}
|
||||
|
||||
val errors = res.errors
|
||||
|
||||
assert(errors.isEmpty)
|
||||
if (!delete(tmpDir))
|
||||
Console.err.println(s"Warning: unable to remove temporary directory $tmpDir")
|
||||
}
|
||||
|
||||
val res = try {
|
||||
val fetch = Fetch.from(
|
||||
Seq(
|
||||
extraRepo,
|
||||
MavenRepository("https://repo1.maven.org/maven2")
|
||||
),
|
||||
Cache.fetch(
|
||||
tmpDir
|
||||
)
|
||||
)
|
||||
|
||||
val startRes = Resolution(
|
||||
Set(
|
||||
Dependency(
|
||||
Module("com.github.alexarchambault", "coursier_2.11"), "1.0.0-M9-test"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
startRes.process.run(fetch).run
|
||||
} finally {
|
||||
cleanTmpDir()
|
||||
}
|
||||
|
||||
val errors = res.errors
|
||||
|
||||
assert(errors.isEmpty)
|
||||
}
|
||||
|
||||
val tests = TestSuite {
|
||||
|
||||
// using scala-test would allow to put the below comments in the test names...
|
||||
|
||||
* - {
|
||||
|
|
@ -84,64 +84,6 @@ object CacheFetchTests extends TestSuite {
|
|||
check(MavenRepository(s"${TestprotocolHandler.protocol}://foo/"))
|
||||
}
|
||||
}
|
||||
|
||||
'httpAuthentication - {
|
||||
// requires an authenticated HTTP server to be running on localhost:8080 with user 'user'
|
||||
// and password 'pass'
|
||||
|
||||
val address = "localhost:8080"
|
||||
val user = "user"
|
||||
val password = "pass"
|
||||
|
||||
def printErrorMessage() =
|
||||
Console.err.println(
|
||||
Console.RED +
|
||||
s"HTTP authentication tests require a running HTTP server on $address, requiring " +
|
||||
s"basic authentication with user '$user' and password '$password', serving the right " +
|
||||
"files.\n" + Console.RESET +
|
||||
"Run one from the coursier sources with\n" +
|
||||
" ./coursier launch -r http://dl.bintray.com/scalaz/releases " +
|
||||
"io.get-coursier:simple-web-server_2.11:1.0.0-M12 -- " +
|
||||
"-d tests/jvm/src/test/resources/test-repo/http/abc.com -u user -P pass -r realm -v"
|
||||
)
|
||||
|
||||
* - {
|
||||
// no authentication -> should fail
|
||||
|
||||
val failed = try {
|
||||
check(
|
||||
MavenRepository(
|
||||
s"http://$address"
|
||||
)
|
||||
)
|
||||
|
||||
printErrorMessage()
|
||||
false
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
true
|
||||
}
|
||||
|
||||
assert(failed)
|
||||
}
|
||||
|
||||
* - {
|
||||
// with authentication -> should work
|
||||
|
||||
try {
|
||||
check(
|
||||
MavenRepository(
|
||||
s"http://$address",
|
||||
authentication = Some(Authentication(user, password))
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
printErrorMessage()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue