Skip to content

Commit

Permalink
test: Enable Raptor module-test debug from CMD line
Browse files Browse the repository at this point in the history
Run Raptor module tests in debug mode if "debugRaptor" is set(any value)
as a system property or an environment variable.
  • Loading branch information
t2gran committed Jul 28, 2023
1 parent 1cb1319 commit 3c9e7a6
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@
* Accept | Access | 0 | 2 | 00:08:30 | 12 000 | | Accepted element: Walk 30s ~ 2 (cost: 12000)
* </pre>
* <p>
* Enable debugging by setting the DEBUG to true.
* You can enable debugging by setting variable DEBUG, an environment variable, or a system
* property. If {@code debugRaptor} exist as either a system property or an environment variable
* the module tests will log debug events.
* <p>
* Remember to revert to {@code DEBUG=false} before committing or use the other options.
* <p>
* Tip! Setting the system properties can be done on individual test in intellij, or in the JUnit
* template. Add {@code -DdebugRaptorOff} or {@code -DdebugRaptor} to the JUnit template. You can
* easily change it when needed in the specific unit-test config, since the template is copied
* before the first test run, and not before re-runs.
*/
public final class ModuleTestDebugLogging {

Expand All @@ -37,6 +46,10 @@ public static void setupDebugLogging(
) {
// We always run with debugging enabled, but be skip logging(dryRun=true).
// We do this to make sure the logging works for all test-cases, and do not throw exceptions.
data.debugToStdErr(requestBuilder, !DEBUG);
boolean sysDebug = System.getProperties().containsKey("debugRaptor");
boolean envDebug = System.getenv().containsKey("debugRaptor");

var dryRun = !(DEBUG || sysDebug || envDebug);
data.debugToStdErr(requestBuilder, dryRun);
}
}

0 comments on commit 3c9e7a6

Please sign in to comment.