Skip to content

Commit ef6a16e

Browse files
committed
test(mps-sync-plugin): require sync in test to run without exceptions
While it's useful to continue synchronization in production, tests are there to find these exceptions.
1 parent 41393ae commit ef6a16e

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/BindingWorker.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class BindingWorker(
4343
val serverConnection: ModelSyncService.Connection,
4444
val branchRef: BranchReference,
4545
val initialVersionHash: String?,
46+
val continueOnError: () -> Boolean,
4647
) {
4748
companion object {
4849
val LOG = KotlinLogging.logger { }
@@ -274,7 +275,10 @@ class BindingWorker(
274275
nodeAssociation = NodeAssociationFromModelServer(branch, targetRoot.getModel()),
275276
sourceMask = MPSProjectSyncMask(listOf(mpsProject), false),
276277
targetMask = MPSProjectSyncMask(listOf(mpsProject), true),
277-
onException = { getMPSListener().synchronizationErrorHappened() },
278+
onException = {
279+
if (!continueOnError()) throw it
280+
getMPSListener().synchronizationErrorHappened()
281+
},
278282
).executeSync()
279283
}
280284
}
@@ -335,6 +339,7 @@ class BindingWorker(
335339
nodeAssociation = nodeAssociation,
336340
sourceMask = MPSProjectSyncMask(listOf(mpsProject), true),
337341
targetMask = MPSProjectSyncMask(listOf(mpsProject), false),
342+
onException = { if (!continueOnError()) throw it },
338343
).executeSync()
339344
}
340345
}

mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/IModelSyncService.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import java.io.Closeable
1111

1212
interface IModelSyncService {
1313
companion object {
14+
var continueOnError: Boolean? = null
15+
1416
@JvmStatic
1517
fun getInstance(project: com.intellij.openapi.project.Project): IModelSyncService {
1618
return project.service<ModelSyncService>()

mps-sync-plugin3/src/main/kotlin/org/modelix/mps/sync3/ModelSyncService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class ModelSyncService(val project: Project) :
168168
serverConnection = addServer(id.url),
169169
branchRef = id.branchRef,
170170
initialVersionHash = state?.versionHash,
171+
continueOnError = { IModelSyncService.continueOnError ?: true },
171172
)
172173
}
173174
}

mps-sync-plugin3/src/test/kotlin/org/modelix/mps/sync3/MPSTestBase.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ abstract class MPSTestBase : UsefulTestCase() {
3131
override fun setUp() {
3232
super.setUp()
3333
TestApplicationManager.getInstance()
34+
IModelSyncService.continueOnError = false
3435
}
3536

3637
@OptIn(ExperimentalPathApi::class)

0 commit comments

Comments
 (0)