Skip to content

Commit da5813d

Browse files
Merge pull request #116 from alexarchambault/merge-upstream
Merge upstream changes
2 parents a8b6296 + 244ec0c commit da5813d

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ abstract class BspBaseSuite extends BaseSuite with BspClientTest {
100100
def findBuildTarget(project: TestProject): bsp.BuildTarget = {
101101
val workspaceTargetTask = {
102102
Workspace.buildTargets.request(bsp.WorkspaceBuildTargetsRequest()).map {
103-
case Left(_) => fail("The request for build targets in ${state.build.origin} failed!")
103+
case Left(_) => fail(s"The request for build targets in ${state.build.origin} failed!")
104104
case Right(ts) =>
105105
ts.targets.map(t => t.id -> t).find(_._1 == project.bspId) match {
106106
case Some((_, target)) => target
@@ -128,7 +128,7 @@ abstract class BspBaseSuite extends BaseSuite with BspClientTest {
128128
project: TestProject
129129
)(f: bsp.BuildTargetIdentifier => Task[T]): Task[T] = {
130130
Workspace.buildTargets.request(bsp.WorkspaceBuildTargetsRequest()).flatMap {
131-
case Left(_) => fail("The request for build targets in ${state.build.origin} failed!")
131+
case Left(_) => fail(s"The request for build targets in ${state.build.origin} failed!")
132132
case Right(ts) =>
133133
ts.targets.map(_.id).find(_ == project.bspId) match {
134134
case Some(target) => f(target)

frontend/src/test/scala/bloop/testing/BloopHelpers.scala

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ trait BloopHelpers {
9898
val all = files.map { f =>
9999
Task {
100100
val configFile = f.path.underlying
101-
val oldWorkspace = AbsolutePath(baseDir)
102-
loadTestProjectFromDisk(configFile, oldWorkspace.syntax, workspace.syntax)
101+
loadTestProjectFromDisk(configFile, workspace.syntax)
103102
}
104103
}
105104

@@ -117,25 +116,28 @@ trait BloopHelpers {
117116

118117
private def loadTestProjectFromDisk(
119118
configFile: Path,
120-
previousBaseDir: String,
121119
newBaseDir: String
122120
): TestProject = {
123121
val bytes = Files.readAllBytes(configFile)
124-
val contents = new String(bytes, StandardCharsets.UTF_8)
125-
val newContents = contents.replace(previousBaseDir, newBaseDir)
126-
import java.nio.file.StandardOpenOption
127-
Files.write(
128-
configFile,
129-
newContents.getBytes(StandardCharsets.UTF_8),
130-
StandardOpenOption.TRUNCATE_EXISTING,
131-
StandardOpenOption.SYNC,
132-
StandardOpenOption.WRITE
133-
)
134-
135-
bloop.config.read(newContents.getBytes(StandardCharsets.UTF_8)) match {
122+
val contents = new String(bytes)
123+
124+
bloop.config.read(contents.getBytes()).flatMap { cfg =>
125+
import java.nio.file.StandardOpenOption
126+
val previousBaseDir = cfg.project.workspaceDir.get.toString()
127+
val newContents = contents.replace("\"" + previousBaseDir, "\"" + newBaseDir)
128+
Files.write(
129+
configFile,
130+
newContents.getBytes,
131+
StandardOpenOption.TRUNCATE_EXISTING,
132+
StandardOpenOption.SYNC,
133+
StandardOpenOption.WRITE
134+
)
135+
bloop.config.read(newContents.getBytes())
136+
} match {
136137
case Left(error) => throw error
137138
case Right(file) => TestProject(file.project, None)
138139
}
140+
139141
}
140142

141143
final class TestState(val state: State) {

0 commit comments

Comments
 (0)