Skip to content

Commit 33551bd

Browse files
authored
Merge pull request #2671 from wiacekm/2669_resource_not_found_from_tests
add test that tries to reproduce an issue
2 parents 1379773 + 509a706 commit 33551bd

File tree

8 files changed

+78
-0
lines changed

8 files changed

+78
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Dependencies._
2+
bloopConfigDir in Global := baseDirectory.value / "bloop-config"
3+
4+
ThisBuild / scalaVersion := "2.12.20"
5+
ThisBuild / version := "0.1.0-SNAPSHOT"
6+
ThisBuild / organization := "com.example"
7+
ThisBuild / organizationName := "example"
8+
9+
lazy val root = (project in file("."))
10+
.settings(
11+
name := "resources-test-project",
12+
libraryDependencies += munit % Test,
13+
fork in Test := true
14+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import sbt._
2+
3+
object Dependencies {
4+
lazy val munit = "org.scalameta" %% "munit" % "1.1.1"
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.10.11
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
val pluginVersion = sys.props.getOrElse(
2+
"bloopVersion",
3+
throw new RuntimeException("Unable to find -DbloopVersion")
4+
)
5+
6+
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % pluginVersion)
7+
8+
updateOptions := updateOptions.value.withLatestSnapshots(false)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.nio.file.{Files, Path, Paths}
2+
import munit.FunSuite
3+
4+
class ResourcesTest extends FunSuite {
5+
6+
test("resources") {
7+
val p: Path = Paths.get(getClass.getResource("test.txt").toURI)
8+
assert(Files.exists(p))
9+
}
10+
11+
}

frontend/src/test/scala/bloop/TestSpec.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,21 @@ object SeedTestSpec extends BaseTestSpec("root-test", "scala-seed-project") {
5656
|""".stripMargin
5757
}
5858

59+
object ResourcesTestSpec extends BaseTestSpec("root-test", "resources-test-project") {
60+
val expectedFullTestsOutput: String =
61+
s"""|[32mResourcesTest:
62+
| + resources ???
63+
|Execution took ???
64+
|1 tests, 1 passed
65+
|All tests in ResourcesTest passed
66+
|
67+
|$delimiter
68+
|Total duration: ???
69+
|All 1 test suites passed.
70+
|$delimiter
71+
|""".stripMargin
72+
}
73+
5974
object JsTestSpec extends BaseTestSpec("test-projectJS-test", "cross-test-build-scalajs-0.6") {
6075
val expectedFullTestsOutput: String = {
6176
s"""|Execution took ???

frontend/src/test/scala/bloop/bsp/BspMetalsClientSpec.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,29 @@ class BspMetalsClientSpec(
807807
}
808808
}
809809

810+
test("resource not found in tests") {
811+
TestUtil.withinWorkspace { workspace =>
812+
val logger = new RecordingLogger(ansiCodesSupported = false)
813+
val projectDir = "resources-test-project"
814+
val projectName = "root-test"
815+
loadBspBuildFromResources(
816+
projectDir,
817+
workspace,
818+
logger,
819+
"Metals"
820+
) { build =>
821+
val project = build.projectFor(projectName)
822+
val projectPath = project.baseDir
823+
val state = build.state
824+
assertNoDiff(logger.warnings.mkString(lineSeparator), "")
825+
val compiledState = state.compile(project)
826+
val testState = compiledState.test(project)
827+
assert(compiledState.status == ExitStatus.Ok)
828+
assert(testState.status == ExitStatus.Ok)
829+
}
830+
}
831+
}
832+
810833
private val dummyFooScalaSources = List(
811834
"""/Foo.scala
812835
|class Foo

0 commit comments

Comments
 (0)