question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Console output (e.g., println) not redirected to sbt client

See original GitHub issue

Was: Logs of test not redirected to sbt client

Reproduction Steps

# project/build.properties
sbt.version = 1.5.5
// plugins.sbt
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.0")
// build.sbt
lazy val example = project.in(file("."))
  .enablePlugins(ScalaJSPlugin)
  .settings(
    scalaVersion := "3.0.2",
    libraryDependencies ++= Seq(
      "org.scalameta" %%% "munit" % "0.7.29" % Test
    ),
    Test / scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule))
  )
// src/test/scala/example/ExampleTest.scala
package example

class ExampleTest extends munit.FunSuite {
  test("test 1") {
    assertEquals("123".size, 3)
  }
}
  1. Start sbt client with sbt -client
  2. Run test

The output is:

sbt:example> test
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 1 s, completed Sep 29, 2021 10:37:06 AM

Expected output

sbt:example> test
example.ExampleTest:
  + test 1 0.00s
[info] Passed: Total 1, Failed 0, Errors 0, Passed 1
[success] Total time: 0 s, completed Sep 29, 2021 10:37:16 AM

Notes

We probably need to investigate the code in the sbt-scalajs to determine if the cause of the bug is there or in sbt.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
gzm0commented, Oct 11, 2021

I would like to point out that both the ExternalJSEnv and the SeleniumJSEnv behave correctly according to the specification of the interface: https://github.com/scala-js/scala-js-js-envs/blob/f0dc9bdcdeb5eb9b40032df3e2d1528b83b457db/js-envs/src/main/scala/org/scalajs/jsenv/RunConfig.scala#L31-L32

More seriously: Since we actually won’t need different behavior from any JSEnv (we’ll always use onOutputStream), we might simply not touch it.

1reaction
gzm0commented, Oct 11, 2021

I agree that #4580 is the cleaner solution and it seems that we can actually make it work. So we probably want to go with that one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange issue with SBT, println, and scala console application
It seems like it's stacking up the print() statements and only displaying them when it runs a different command. If I use println()...
Read more >
Remove forced background log · Issue #8 · sbt/sbt-core-next
My guess is System.err (used BackgroundRunPlugin) is replaced to another one which redirects the error message to java.util.loging.Logger. And ...
Read more >
Why does the ">" command in a Windows console not redirect ...
I am trying to build a Scala project with sbt, so I run a command: sbt clean test ...
Read more >
sbt Reference Manual — Combined Pages
Running sbt with no command line arguments starts sbt shell. sbt shell has a command prompt (with tab completion and history!). For example,...
Read more >
Scala: How to handle the STDOUT and STDERR of external ...
Solution. The simplest way to do this is to run your commands as shown in previous recipes, and then capture the output with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found