Skip stdout silencing based on env variable

What does this MR do and why?

Add condition to skip stdout silencing based on env variable

Problem: When the example metadata :silence_stdout is used then the standard output is redirected to reduce console output noise. But, it can be problematic when you want to debug tests and implementaion code with the debugger command. In this cases, interactive debugger console does not behave correctly because the standard output is redirected, too.

Solution: Add an environment variable SKIP_SILENCE_STDOUT that allows skipping the output silencing.

Changelog: other

🛠️ with ❤️ at Siemens

References

Screenshots or screen recordings

The screencast demonstrate the difference in behavior when debugging with the new environment variable: https://cap.so/s/ca159qksf14vbm9

Before: When running a test with the example metadata :silence_stdout enabled , all console output is redirected and not visible in the terminal, making it difficult to debug issues.

After: By setting the new environment variable (SKIP_STDOUT_SILENCING=true), the console output remains visible in the terminal while executing, allowing developers to see debug messages and track execution flow.

How to set up and validate locally

  1. Run the test spec/tasks/gitlab/x509/update_rake_spec.rb as usual => Only the rspec output is shown in console; all output from the test it self is redirected, e.g. logger output, debug puts, etc.
    bundle exec bin/rspec spec/tasks/gitlab/x509/update_rake_spec.rb:30
  2. Run the test spec/tasks/gitlab/x509/update_rake_spec.rb as usual => You should now see the logger statement in the console output
    SKIP_SILENCE_STDOUT=1 bundle exec bin/rspec spec/tasks/gitlab/x509/update_rake_spec.rb:30

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

MR Checklist (@gerardo-navarro)
Edited by Gerardo Navarro

Merge request reports

Loading