Skip to content

Failing test for broken ANSI escape handling in LinePrefixOutputStream #4951

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,34 @@
}

test("colors") {
val baos = new ByteArrayOutputStream()
val lpos = new LinePrefixOutputStream("PREFIX", baos)
lpos.write(fansi.Color.Red("hello").render.getBytes)
lpos.write('\n')
lpos.flush()
lpos.write(fansi.Color.Green("world").render.getBytes)
lpos.write('\n')
lpos.flush()
for (chunkSize <- Seq(1, 2, 3, 4, 5, 6, 7)) {

Check failure on line 78 in core/internal/test/src/mill/internal/LinePrefixOutputStreamTests.scala

View workflow job for this annotation

GitHub Actions / linux (17, '{core,main,scalalib,testrunner,bsp,testkit}.__.test', false, true) / run

LinePrefixOutputStreamTests.colors

baos.toString == expected baos: java.io.ByteArrayOutputStream = PREFIX[31mhello[39m PREFIX[32mworld[39m PREFIX[34mone PREFIXtwo PREFIXthree PREFIXfour PREFIXfive[39m expected: String = PREFIX[31mhello[39m PREFIX[32mworld[39m PREFIX[34mone [39mPREFIX[34mtwo [39mPREFIX[34mthree [39mPREFIX[34mfour [39mPREFIX[34mfive[39m
val baos = new ByteArrayOutputStream()
val lpos = new LinePrefixOutputStream("PREFIX", baos)
lpos.write(fansi.Color.Red("hello").render.getBytes)
lpos.write('\n')
lpos.flush()
lpos.write(fansi.Color.Green("world").render.getBytes)
lpos.write('\n')
lpos.flush()

val blueText = fansi.Color.Blue("one\ntwo\nthree\nfour\nfive").render.getBytes
val blueText = fansi.Color.Blue("one\ntwo\nthree\nfour\nfive").render.getBytes

blueText.grouped(7).foreach { chunk =>
lpos.write(chunk)
lpos.flush()
}
blueText.grouped(chunkSize).foreach { chunk =>
lpos.write(chunk)
lpos.flush()
}

val expected =
"PREFIX" + fansi.Color.Red("hello").render + "\n" +
"PREFIX" + fansi.Color.Green("world").render + "\n" +
"PREFIX" + fansi.Color.Blue("one\n") +
"PREFIX" + fansi.Color.Blue("two\n") +
"PREFIX" + fansi.Color.Blue("three\n") +
"PREFIX" + fansi.Color.Blue("four\n") +
"PREFIX" + fansi.Color.Blue("five")
val expected =
"PREFIX" + fansi.Color.Red("hello").render + "\n" +
"PREFIX" + fansi.Color.Green("world").render + "\n" +
"PREFIX" + fansi.Color.Blue("one\n") +
"PREFIX" + fansi.Color.Blue("two\n") +
"PREFIX" + fansi.Color.Blue("three\n") +
"PREFIX" + fansi.Color.Blue("four\n") +
"PREFIX" + fansi.Color.Blue("five")

assert(baos.toString == expected)
assert(baos.toString == expected)
}
}

}
Expand Down
Loading