- Introduced `withTimeout` to avoid indefinite hangs during test execution (#514) ## Motivation and Context Workaround for #514 in tests ## How Has This Been Tested? Integration test updated, CI ## Breaking Changes No ## Types of changes - [x] Test fix ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [ ] I have added appropriate error handling - [ ] I have added or updated documentation as needed ## Additional context #514
This commit is contained in:
parent
367618d109
commit
efed85ae06
1 changed files with 5 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ import io.modelcontextprotocol.kotlin.test.utils.createTeeProcessBuilder
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
|
import kotlinx.coroutines.withTimeout
|
||||||
import kotlinx.io.asSink
|
import kotlinx.io.asSink
|
||||||
import kotlinx.io.asSource
|
import kotlinx.io.asSource
|
||||||
import kotlinx.io.buffered
|
import kotlinx.io.buffered
|
||||||
|
|
@ -56,9 +57,12 @@ class StdioClientTransportTest : BaseTransportTest() {
|
||||||
)
|
)
|
||||||
|
|
||||||
// The error in stderr should cause connecting to fail
|
// The error in stderr should cause connecting to fail
|
||||||
|
// Use explicit timeout to avoid blocking indefinitely due to kotlinx.io cancellation issue (#514)
|
||||||
assertThrows<McpException> {
|
assertThrows<McpException> {
|
||||||
|
withTimeout(5.seconds) {
|
||||||
client.connect(transport)
|
client.connect(transport)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
process.destroyForcibly()
|
process.destroyForcibly()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue