-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix flaky tests #434
base: series/2.x
Are you sure you want to change the base?
Fix flaky tests #434
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zio.process | ||
|
||
import zio.test._ | ||
import zio.{ durationInt, Chunk } | ||
|
||
trait ZIOProcessBaseSpec extends ZIOSpecDefault { | ||
override def aspects = Chunk(TestAspect.timeout(30.seconds), TestAspect.flaky) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zio.process | ||
|
||
import zio.test._ | ||
import zio.{ durationInt, Chunk } | ||
|
||
trait ZIOProcessBaseSpec extends ZIOSpecDefault { | ||
override def aspects = Chunk(TestAspect.timeout(30.seconds), TestAspect.flaky) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,13 @@ final case class ProcessStream( | |
private[process] val outputStream: Option[OutputStream] = None | ||
) { | ||
|
||
private def close: ZIO[Any, Nothing, Unit] = | ||
private def close: ZIO[Any, CommandError, Unit] = | ||
outputStream match { | ||
case None => ZIO.unit | ||
case Some(out) => ZIO.succeed(out.close()) | ||
case Some(out) => | ||
ZIO.attemptBlocking(out.close()).mapError { case e: Throwable => | ||
CommandError.Error(e) | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -94,9 +97,12 @@ final case class ProcessStream( | |
* Note: Needs Java 9 or greater. | ||
*/ | ||
def string(charset: Charset): ZIO[Any, CommandError, String] = | ||
ZIO.attemptBlockingCancelable { | ||
new String(inputStream.readAllBytes(), charset) | ||
}(ZIO.succeed(inputStream.close())).refineOrDie { case CommandThrowable.IOError(e) => | ||
ZIO.scoped { | ||
close *> ProcessPlatformSpecific.wait(inputStream) *> ZIO.attemptBlockingCancelable { | ||
Comment on lines
+100
to
+101
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand the purpose of the initial (for {
_ <- ProcessPlatformSpecific.wait(inputStream)
s <- ZIO.attemptBlockingCancelable {
new String(inputStream.readAllBytes(), charset)
}(ZIO.succeed(inputStream.close()))
} yield s).refineOrDie { case CommandThrowable.IOError(e) =>
e
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried the code I pasted locally and it seems like all the tests pass. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, |
||
new String(inputStream.readAllBytes(), charset) | ||
}(ZIO.succeed(inputStream.close())) | ||
}.refineOrDie { case CommandThrowable.IOError(e) => | ||
e | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't think we want to make the default
TestAspect.flaky
. That could cover up legitimate problems. If any tests are flaky (and can't easily be fixed), I'd rather mark them@@ TestAspect.flaky
at the individual level so that it's clear which tests have problems.But maybe this was unintentional or temporary code? Because I see you also do
@@ TestAspect.nonFlaky
at the suite level below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, this is a typo, it was intended to be
nonFlaky
... ThenonFlaky
at suite level is just for one suite because inCommandSpec
for Scala Native thenonFlaky
times out and it passed it anyway.