mirror of
https://github.com/2dust/v2rayNG.git
synced 2026-10-29 14:39:25 +00:00
test(root): fix flaky RootProcessRunner inherited-stdout test (#6282)
The test gave RootProcessRunner.run a 250 ms deadline. When sh takes longer than that to start and finish, the runner hits the deadline, destroys it and returns -1, and the test fails with "expected: <0> but was: <-1>". With the sh from Git for Windows this happened in 6 of 30 runs. The test's real guard is the 1500 ms elapsed bound against the background "sleep 5". A 3000 ms deadline leaves that bound alone to decide the result, so a runner that keeps a finished command open until its deadline now fails the test as well; with 250 ms it passed.
This commit is contained in:
1 parent
4a1510eb65
commit
61c4e40ec1
1 file changed
+1
-1
@@ -13,7 +13,7 @@ class RootProcessRunnerTest {
|
||||
}
|
||||
@Test fun `inherited stdout cannot hold a completed command open`() {
|
||||
val start = System.nanoTime()
|
||||
val result = RootProcessRunner.run(listOf("sh", "-c", "sleep 5 & echo complete"), 250)
|
||||
val result = RootProcessRunner.run(listOf("sh", "-c", "sleep 5 & echo complete"), 3000)
|
||||
assertEquals(0, result.code)
|
||||
assertTrue(result.output.contains("complete"))
|
||||
assertTrue(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) < 1500)
|
||||
|
||||
Reference in new issue
Block a user