Merge pull request #245 from eed3si9n/wip/offline

Fix flaky OfflineModeSpec
This commit is contained in:
eugene yokota 2018-06-18 04:46:03 -04:00 committed by GitHub
commit ff16f3b39e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -2,10 +2,10 @@ package sbt.internal.librarymanagement
import sbt.librarymanagement._
import sbt.librarymanagement.ivy.UpdateOptions
import org.scalatest.Assertion
import org.scalatest.{ Assertion, DiagrammedAssertions }
import sbt.io.IO
class OfflineModeSpec extends BaseIvySpecification {
class OfflineModeSpec extends BaseIvySpecification with DiagrammedAssertions {
private final def targetDir = Some(currentDependency)
private final def onlineConf = makeUpdateConfiguration(false, targetDir)
private final def offlineConf = makeUpdateConfiguration(true, targetDir)
@ -37,18 +37,13 @@ class OfflineModeSpec extends BaseIvySpecification {
assert(onlineResolution.isRight)
assert(onlineResolution.right.exists(report => report.stats.resolveTime > 0))
// Compute an estimate to ensure that the second resolution does indeed use the cache
val originalResolveTime = onlineResolution.right.get.stats.resolveTime
val estimatedCachedTime = originalResolveTime * 0.3
val offlineResolution =
IvyActions.updateEither(toResolve, offlineConf, warningConf, log)
assert(offlineResolution.isRight, s"Offline resolution has failed with $offlineResolution.")
assert(offlineResolution.isRight)
val resolveTime = offlineResolution.right.get.stats.resolveTime
// Only check the estimate for the non cached resolution, otherwise resolution is cached
assert(resolveTime <= estimatedCachedTime,
"Offline resolution took more than 15% of normal resolution's running time.")
assert(originalResolveTime > resolveTime)
}
"Offline update configuration" should "reuse the caches when offline is enabled" in {