0

This may be more of an application-based question, so please migrate it, if appropriate. However, I found these two questions, which were also asked here.

On to the question:

I'm using Visual Studio Code on Ubuntu 20.04, with the CMake Tools extension. With the latter, I can run "CMake: Build", which directs its output to vscode's own output console. I have a custom command executing my unit tests after a build. The testing framework is Catch2. The output then looks like this: weird characters If I instead run it via the integrated terminal (bash), it looks like this: correct output

I have two different unit test executables. One for serial code, one for the portion of my code that uses MPI. The odd characters like [1;31m only appear when running the latter one (in parallel).

Does anyone know how to fix this?

Gama11
  • 31,714
  • 9
  • 78
  • 100
RL-S
  • 734
  • 6
  • 21
  • 1
    The "weird" characters are terminal control codes, used for the coloring of the output. It seems that VS Code's output console can't handle such codes, but a terminal of course can. – Some programmer dude Jun 21 '20 at 19:49
  • Then why don't they appear when it's not in parallel? I just checked again to make sure, output is normal, though not coloured, when running the sequential unit tests. – RL-S Jun 21 '20 at 19:57
  • I think, this extension might help https://marketplace.visualstudio.com/items?itemName=IBM.output-colorizer – tHeSiD Jun 21 '20 at 19:58
  • @RL-S read the issue here https://github.com/microsoft/vscode/issues/1801 – tHeSiD Jun 21 '20 at 19:59
  • @tHeSiD thanks, but unfortunately, it doesn't. The output is now coloured, but not like the console output. Rather, this extension detects key words and literals. Also, the weird characters are still present. – RL-S Jun 21 '20 at 20:01
  • Those characters are not weird, they are [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). – PaulMcKenzie Jun 21 '20 at 20:42
  • @PaulMcKenzie Thank you very much, that's good to know! In that output, however, they are clearly not intended to be displayed, and thus, I find the description "weird" rather appropriate - especially, because you apparently knew, which characters I was referring to ;) – RL-S Jun 21 '20 at 21:22
  • 2
    Believe it or not, this issue has been around since the earliest days of terminals and ANSI codes. It is that the software you're using doesn't know what to do with the codes, no different than back in the day when terminals / software didn't know what to do with those codes. – PaulMcKenzie Jun 21 '20 at 21:27
  • The "integrated terminal" is probably using an actual terminal which can recognize and handle such escape sequences. The VSCode output console doesn't seem to have such handling which means it just print whatever is printed, without any specific filtering. – Some programmer dude Jun 22 '20 at 09:41
  • "which directs its output to vscode's own output console." This might be the problem. I have noticed that first level shell works with proper colors. However if you start a second level shell (e.g. cmd -> bash ) then the ANSI color codes seem to not be processed properly by windows terminal. You might be running into the same issue with vscode here. – stardust Jun 22 '20 at 15:07

0 Answers0