-
Notifications
You must be signed in to change notification settings - Fork 12
Add testProcess{Config} task to accept user options #581
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -376,10 +376,67 @@ public final void registerCurrentThreadForWallClockProfiling() { | |
| profiler.addThread(); | ||
| } | ||
|
|
||
| /** | ||
| * Merges two profiler command strings. Options in overrides take precedence | ||
| * over options in base for matching keys. | ||
| * | ||
| * @param base The base profiler command (from test's getProfilerCommand()) | ||
| * @param overrides The override options (from -Pprofiler.options) | ||
| * @return Merged command string with overrides taking precedence | ||
| */ | ||
| private static String mergeProfilerOptions(String base, String overrides) { | ||
| if (overrides == null || overrides.isEmpty()) { | ||
| return base; | ||
| } | ||
|
|
||
| // Parse base options into ordered map | ||
| Map<String, String> options = new java.util.LinkedHashMap<>(); | ||
| for (String part : base.split(",")) { | ||
| int eq = part.indexOf('='); | ||
| if (eq > 0) { | ||
| options.put(part.substring(0, eq), part.substring(eq + 1)); | ||
| } else if (!part.isEmpty()) { | ||
| options.put(part, ""); | ||
| } | ||
| } | ||
|
|
||
| // Apply overrides | ||
| for (String part : overrides.split(",")) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 LOW · robustness A valueless override token (e.g. Suggestion: Document this behavior in the else if (!part.isEmpty()) {
options.putIfAbsent(part, "");
} |
||
| int eq = part.indexOf('='); | ||
| if (eq > 0) { | ||
| options.put(part.substring(0, eq), part.substring(eq + 1)); | ||
| } else if (!part.isEmpty()) { | ||
| options.put(part, ""); | ||
| } | ||
| } | ||
|
|
||
| // Rebuild command | ||
| StringBuilder result = new StringBuilder(); | ||
| for (Map.Entry<String, String> entry : options.entrySet()) { | ||
| if (result.length() > 0) { | ||
| result.append(","); | ||
| } | ||
|
zhengyu123 marked this conversation as resolved.
|
||
| // Skip key with empty value | ||
| if (!entry.getValue().isEmpty()) { | ||
|
Comment on lines
+419
to
+420
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| result.append(entry.getKey()); | ||
| result.append("=").append(entry.getValue()); | ||
| } | ||
| } | ||
| return result.toString(); | ||
| } | ||
|
|
||
| private String getAmendedProfilerCommand() { | ||
| String profilerCommand = getProfilerCommand(); | ||
|
|
||
| // Apply user-provided options from -Pprofiler.options (override test defaults) | ||
| String userOptions = System.getProperty("ddprof.test.options"); | ||
| if (userOptions != null && !userOptions.isEmpty()) { | ||
| profilerCommand = mergeProfilerOptions(profilerCommand, userOptions); | ||
|
Comment on lines
+432
to
+434
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎. |
||
| System.out.println("[TEST] Applied profiler.options: " + userOptions); | ||
| } | ||
|
|
||
| String testCstack = (String)testParams.get("cstack"); | ||
| if (testCstack != null) { | ||
| if (testCstack != null && !profilerCommand.contains("cstack=")) { | ||
| profilerCommand += ",cstack=" + testCstack; | ||
|
zhengyu123 marked this conversation as resolved.
|
||
| } else if(!(ALLOW_NATIVE_CSTACKS || profilerCommand.contains("cstack="))) { | ||
| profilerCommand += ",cstack=fp"; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.