Skip to content

test: add GUI manager coverage tests#305

Merged
sudip-mondal-2002 merged 16 commits into
sudip-mondal-2002:mainfrom
YASHcode-IIITV:fix/gui-test-coverage
Jun 10, 2026
Merged

test: add GUI manager coverage tests#305
sudip-mondal-2002 merged 16 commits into
sudip-mondal-2002:mainfrom
YASHcode-IIITV:fix/gui-test-coverage

Conversation

@YASHcode-IIITV

@YASHcode-IIITV YASHcode-IIITV commented May 30, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds and enables GUI module test coverage infrastructure for Issue #270.

Changes made

  • Added test_gui_manager.cpp coverage tests.
  • Fixed outdated include paths and API usage in GUI-related tests.
  • Updated the amplitron-tests target to include required GUI sources.
  • Added missing compile definitions required by GUI test builds (AMPLITRON_VERSION).
  • Added Dear ImGui sources and GUI dependencies to the test target so GUI tests compile and link correctly on Windows.
  • Verified successful build of amplitron-tests.exe.

Related Issue

Fixes #270

Type of Change

  • ✅ Tests
  • 🔧 Build / CI / Configuration

How Was This Tested?

  • Platform(s) tested on: Windows 11
  • Build system: CMake + Visual Studio Build Tools
  • Test command run: .\Debug\amplitron-tests.exe

Results

  • 290 tests passed

  • 1 unrelated preset-loading test failed:

    • json_can_load_existing_factory_presets

Checklist

  • Code compiles and builds successfully on my platform
  • All existing tests pass (./amplitron-tests)
  • New tests added for GUI coverage
  • Documentation updated (not applicable)
  • No blocking calls introduced on the audio thread
  • Tested on: Windows 11

Screenshots / Demo

N/A (test and build infrastructure changes)

Summary by CodeRabbit

  • Tests

    • Expanded test coverage for GUI manager, audio backend initialization, and file dialog interactions.
    • Added headless testing infrastructure for improved continuous integration reliability.
  • Chores

    • Enhanced testing framework with mocking utilities for deterministic behavior in non-GUI environments.

@github-actions github-actions Bot added level:intermediate Intermediate task · 25 GSSoC points type:testing Unit tests, integration tests, or test coverage labels May 30, 2026
@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR adds comprehensive test coverage for audio command history, helper function utilities, and GUI manager functionality. It introduces headless testing infrastructure (dialog mocks and WindowContext stubs), refactors PortAudio test mocks with RAII, and expands GuiManager tests from 11 to 800+ lines with extensive headless GUI mocking and branch-focused scenarios.

Changes

Test Infrastructure and Comprehensive GUI Coverage

Layer / File(s) Summary
Audio engine command history unit tests
src/audio/audio_engine.h
Adds shared AudioEngine accessor and clear helper; tests GuiManager lifecycle, shutdown safety, and initialize() return; validates CommandHistory undo/redo state and effect add/remove through command execution.
Version parsing, comparison, and JSON extraction helpers
src/audio/audio_engine.h
Introduces internal static helpers for version component parsing (strip v, split, map non-numeric to 0), version "is newer" comparison, and substring JSON field extraction; includes comprehensive edge-case tests.
Headless dialog mock declarations and wiring
src/gui/dialogs/file_dialog.h, src/gui/dialogs/file_dialog_native.cpp, src/gui/dialogs/file_dialog_native_folder.cpp
Adds AMPLITRON_HEADLESS conditional extern mock-result strings and wires native headless dialog implementations to return configurable mocks instead of empty strings.
WindowContext headless mode and mock failure flags
src/gui/window_context.cpp
Adds AMPLITRON_HEADLESS conditional control flow in initialize(), shutdown(), poll_events(), begin_frame(), and end_frame() to skip SDL/GL/ImGui setup; introduces mock failure flags to force test-specific failures.
PortAudio RAII mock infrastructure and test updates
tests/integration/test_audio_backend_portaudio.cpp
Centralizes PortAudio mock globals, setup/clear, and introduces MockGuard RAII to install comprehensive default mock behaviors; updates lifecycle, restart, enumeration, branch-coverage, and callback tests to use MockGuard.
GuiManager test bootstrap and explicit initialization
tests/ui/test_gui_manager.cpp
Expands bootstrap with POSIX includes, standard header preload (macro-poisoning protection), and defines private/protected as public for white-box access; adds explicit initialize() calls in existing tests.
Headless GUI mock infrastructure and source inclusion
tests/ui/test_gui_manager.cpp
Adds macro-based headless mocking: MockImGui, MockDrawList stubs; MockGuiManager exposing internal methods; macro redirection for GuiManager/ImGui; includes gui/gui_manager_frame.cpp and gui/gui_manager_menu.cpp under mocks; stubs process calls; adds MockUpdateChecker with redirected popen/pclose/fgets.
Comprehensive GuiManager menu-bar, frame, and branch tests
tests/ui/test_gui_manager.cpp
Adds gui_manager_menu_bar_comprehensive_coverage (preset/clipboard/folder/audio/tuner/MIDI flows), gui_manager_frame_comprehensive_coverage (keyboard shortcuts, popups, save callbacks), update_checker_comprehensive_coverage (process failure/success and version parsing), ui_component_full_function_coverage (props/state wiring), and gui_manager_additional_coverage_run (initialize failure, environment defaults, modal closure, fork branches, undo/redo execution, indicator rendering).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • sudip-mondal-2002/Amplitron#22: The main PR adds unit-test coverage for CommandHistory undo/redo state transitions that directly exercise the undo/redo system introduced in this PR.
  • sudip-mondal-2002/Amplitron#342: Both PRs extend unit-test coverage for the same CommandHistory undo/redo behavior with additional scenarios for ClearAll, ResetAll, coalescing, and trimming.
  • sudip-mondal-2002/Amplitron#243: The main PR's CommandHistory and GuiManager unit tests directly exercise the undo/redo command execution behavior introduced by the command-graph undo/redo work in this PR.

Suggested labels

GUI, type:devops, quality:clean

Suggested reviewers

  • sudip-mondal-2002
  • MohitBareja16

Poem

🐰 With tests we build a fortress strong,
Headless mocks that right the wrong,
GUI mocks dance in twilight's glow,
Coverage climbs, our bugs lay low! 🎭

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add GUI manager coverage tests' directly and specifically describes the main change: adding test coverage for GUI manager.
Linked Issues check ✅ Passed The PR adds extensive GUI module test coverage including tests for GuiManager initialization/shutdown, MIDI manager access, menu flows, frame behavior, and update checks, directly addressing Issue #270's goal of improving GUI test coverage to 90%+.
Out of Scope Changes check ✅ Passed All changes support GUI testing infrastructure: test files for GuiManager, headless mock implementations in core files (window_context, file_dialog, audio_engine), and PortAudio test reorganization for deterministic testing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
CMakeLists.txt (1)

526-527: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update comment to reflect GUI sources inclusion.

The comment states "Effect + core sources needed by tests (no GUI, no main)" but the CORE_SOURCES list now includes 21 GUI-related files (gui_manager, pedal_board, gui_snapshots, etc.) needed for the new GUI test coverage. The comment should be updated to accurately describe the expanded scope.

📝 Proposed comment update
-    # Effect + core sources needed by tests (no GUI, no main)
+    # Effect + core sources needed by tests (includes GUI components, no main)
     set(CORE_SOURCES
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CMakeLists.txt` around lines 526 - 527, Update the top comment that currently
reads "Effect + core sources needed by tests (no GUI, no main)" to reflect that
CORE_SOURCES now includes GUI-related files; mention that GUI sources are
included for expanded GUI test coverage and optionally cite examples such as
gui_manager, pedal_board, gui_snapshots to make the intent clear so readers know
GUI code is part of the test build.
🧹 Nitpick comments (3)
tests/test_gui_manager.cpp (3)

243-244: 💤 Low value

Inconsistent cleanup pattern across tests.

Several tests (e.g., lines 243-244, 255, 294) set specific gain values (0.7f, 0.8f) at the end, presumably to leave the shared_engine() in a known state. However, this pattern is applied inconsistently—many tests omit it entirely. If cleanup is necessary, apply it uniformly; if not, remove these statements to reduce noise.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_gui_manager.cpp` around lines 243 - 244, The test suite contains
inconsistent cleanup where some tests call engine.set_input_gain(0.7f) and
engine.set_output_gain(0.8f) on the shared_engine() while others do not; decide
on a single approach and make it consistent: either remove these trailing
set_input_gain/set_output_gain calls from all tests if they are unnecessary, or
add the same cleanup at the end of every test that mutates shared_engine() (use
shared_engine().set_input_gain(...) and shared_engine().set_output_gain(...) and
centralize into a helper like reset_shared_engine() if desired) so tests
uniformly restore engine state.

17-20: 💤 Low value

Consider test isolation implications of shared singleton.

The static AudioEngine instance creates implicit state sharing between tests. While clear_engine() is called appropriately, this pattern could cause issues if tests ever run in parallel or if cleanup is missed. For now, the sequential execution and careful cleanup make this workable, but consider using a fresh instance per test if isolation becomes a concern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_gui_manager.cpp` around lines 17 - 20, The tests currently use a
process-wide static AudioEngine via shared_engine(), which creates implicit
state sharing between tests; to improve isolation, change tests to construct and
use a fresh AudioEngine instance per test (or return a unique_ptr from a
factory) instead of the static in shared_engine(), and update callers to call
the new per-test factory (or pass the instance explicitly) rather than relying
on shared_engine(); if retaining a helper, rename/replace shared_engine() to
make_new_engine() or make_unique_engine() and ensure clear_engine() is no longer
relied upon for cleanup.

320-349: ⚖️ Poor tradeoff

Version parsing logic duplication is acknowledged but creates maintenance debt.

The comments (lines 311-317) correctly note that parse_version and is_version_newer are duplicated from gui_manager_update.cpp because the originals are local lambdas. While this duplication is currently necessary for testing, any future changes to the source must be manually mirrored here, creating maintenance risk.

Consider extracting the version parsing and comparison logic to a separate utility header (e.g., version_utils.h) that both the production code and tests can include directly. This would eliminate duplication and ensure test coverage automatically tracks implementation changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_gui_manager.cpp` around lines 320 - 349, The parse_version and
is_version_newer functions duplicated in tests/test_gui_manager.cpp should be
moved into a shared utility header (e.g., version_utils.h) and used from both
the production file (gui_manager_update.cpp) and the test file to remove
maintenance duplication; create version_utils.h with the parse_version and
is_version_newer declarations/implementations, update gui_manager_update.cpp to
use those functions instead of its local lambdas, and replace the copies in
tests/test_gui_manager.cpp to include and call parse_version/is_version_newer
from the new header.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@CMakeLists.txt`:
- Around line 526-527: Update the top comment that currently reads "Effect +
core sources needed by tests (no GUI, no main)" to reflect that CORE_SOURCES now
includes GUI-related files; mention that GUI sources are included for expanded
GUI test coverage and optionally cite examples such as gui_manager, pedal_board,
gui_snapshots to make the intent clear so readers know GUI code is part of the
test build.

---

Nitpick comments:
In `@tests/test_gui_manager.cpp`:
- Around line 243-244: The test suite contains inconsistent cleanup where some
tests call engine.set_input_gain(0.7f) and engine.set_output_gain(0.8f) on the
shared_engine() while others do not; decide on a single approach and make it
consistent: either remove these trailing set_input_gain/set_output_gain calls
from all tests if they are unnecessary, or add the same cleanup at the end of
every test that mutates shared_engine() (use shared_engine().set_input_gain(...)
and shared_engine().set_output_gain(...) and centralize into a helper like
reset_shared_engine() if desired) so tests uniformly restore engine state.
- Around line 17-20: The tests currently use a process-wide static AudioEngine
via shared_engine(), which creates implicit state sharing between tests; to
improve isolation, change tests to construct and use a fresh AudioEngine
instance per test (or return a unique_ptr from a factory) instead of the static
in shared_engine(), and update callers to call the new per-test factory (or pass
the instance explicitly) rather than relying on shared_engine(); if retaining a
helper, rename/replace shared_engine() to make_new_engine() or
make_unique_engine() and ensure clear_engine() is no longer relied upon for
cleanup.
- Around line 320-349: The parse_version and is_version_newer functions
duplicated in tests/test_gui_manager.cpp should be moved into a shared utility
header (e.g., version_utils.h) and used from both the production file
(gui_manager_update.cpp) and the test file to remove maintenance duplication;
create version_utils.h with the parse_version and is_version_newer
declarations/implementations, update gui_manager_update.cpp to use those
functions instead of its local lambdas, and replace the copies in
tests/test_gui_manager.cpp to include and call parse_version/is_version_newer
from the new header.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f8d75c92-4f6a-49d2-b708-611dd3fff316

📥 Commits

Reviewing files that changed from the base of the PR and between 837ba12 and 4a21b02.

📒 Files selected for processing (2)
  • CMakeLists.txt
  • tests/test_gui_manager.cpp

@github-actions

github-actions Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

🌍 Cross-Platform Coverage Report

Platforms: Linux + macOS + Windows
Merged Line Coverage: 78.1%

✅ Coverage meets threshold: 78.1% >= 60%

Full Merged Coverage Summary
Summary coverage rate:
  lines......: 78.1% (8528 of 10925 lines)
  functions..: 92.3% (837 of 907 functions)
  branches...: no data found

@github-actions

github-actions Bot commented May 31, 2026

Copy link
Copy Markdown
Contributor

PR Preview Removed

The GitHub Pages preview for this PR has been removed because the PR was closed.

@sudip-mondal-2002

Copy link
Copy Markdown
Owner

@YASHcode-IIITV lmk when complete

A huge part is missing test coverage for GUI module
image

@sudip-mondal-2002 sudip-mondal-2002 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests must go to test folder
and coverage is not enough

@sudip-mondal-2002

Copy link
Copy Markdown
Owner

@YASHcode-IIITV are you still working on it?

@github-actions github-actions Bot added the Medium label Jun 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/audio/audio_engine.h`:
- Around line 14-15: The production header currently includes test_framework.h
and contains TEST(...) blocks (test registration) which must be removed from the
header; move the include of test_framework.h and all TEST(...) blocks (and any
test helper functions) into a new test-only translation unit (e.g.,
audio_engine_test.cpp) that `#includes` the original audio_engine.h, leaving
audio_engine.h with only production declarations/definitions and no test
symbols; update build files to compile the new test TU only in test targets and
delete the test include/TEST blocks from the header.

In `@src/gui/dialogs/file_dialog_native.cpp`:
- Around line 90-97: The code builds shell command strings (cmd) using unescaped
user-controlled variables (default_name, filter_desc, filter_ext) and passes
them to popen(), allowing shell injection; replace this by invoking
/usr/bin/osascript (or the AppleScript API) without a shell: construct an argv
array with program "/usr/bin/osascript" and separate "-e" arguments (one per
script fragment) and call posix_spawn/execvp (or use NSTask/NSAppleScript on
macOS) so arguments are passed directly rather than concatenated into a shell
command; update the code paths that build cmd in file_dialog_native.cpp (the
blocks that create the "choose file name" and related osascript commands) to
stop using popen(cmd.c_str(), "r") with interpolated strings and instead spawn
the process with safe argv passing or use native Cocoa APIs to present the
save/open dialogs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ee1191f-114b-433a-8073-b28104da8dee

📥 Commits

Reviewing files that changed from the base of the PR and between 247380a and 585e56e.

📒 Files selected for processing (9)
  • src/audio/audio_engine.h
  • src/gui/dialogs/file_dialog.h
  • src/gui/dialogs/file_dialog_native.cpp
  • src/gui/dialogs/file_dialog_native_folder.cpp
  • src/gui/dialogs/file_dialog_native_open.cpp
  • src/gui/window_context.cpp
  • tests/integration/test_audio_backend_portaudio.cpp
  • tests/ui/test_gui_manager.cpp
  • web/coi-serviceworker.js
💤 Files with no reviewable changes (4)
  • web/coi-serviceworker.js
  • src/gui/window_context.cpp
  • tests/ui/test_gui_manager.cpp
  • tests/integration/test_audio_backend_portaudio.cpp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/audio/audio_engine.h`:
- Around line 14-15: The production header currently includes test_framework.h
and contains TEST(...) blocks (test registration) which must be removed from the
header; move the include of test_framework.h and all TEST(...) blocks (and any
test helper functions) into a new test-only translation unit (e.g.,
audio_engine_test.cpp) that `#includes` the original audio_engine.h, leaving
audio_engine.h with only production declarations/definitions and no test
symbols; update build files to compile the new test TU only in test targets and
delete the test include/TEST blocks from the header.

In `@src/gui/dialogs/file_dialog_native.cpp`:
- Around line 90-97: The code builds shell command strings (cmd) using unescaped
user-controlled variables (default_name, filter_desc, filter_ext) and passes
them to popen(), allowing shell injection; replace this by invoking
/usr/bin/osascript (or the AppleScript API) without a shell: construct an argv
array with program "/usr/bin/osascript" and separate "-e" arguments (one per
script fragment) and call posix_spawn/execvp (or use NSTask/NSAppleScript on
macOS) so arguments are passed directly rather than concatenated into a shell
command; update the code paths that build cmd in file_dialog_native.cpp (the
blocks that create the "choose file name" and related osascript commands) to
stop using popen(cmd.c_str(), "r") with interpolated strings and instead spawn
the process with safe argv passing or use native Cocoa APIs to present the
save/open dialogs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ee1191f-114b-433a-8073-b28104da8dee

📥 Commits

Reviewing files that changed from the base of the PR and between 247380a and 585e56e.

📒 Files selected for processing (9)
  • src/audio/audio_engine.h
  • src/gui/dialogs/file_dialog.h
  • src/gui/dialogs/file_dialog_native.cpp
  • src/gui/dialogs/file_dialog_native_folder.cpp
  • src/gui/dialogs/file_dialog_native_open.cpp
  • src/gui/window_context.cpp
  • tests/integration/test_audio_backend_portaudio.cpp
  • tests/ui/test_gui_manager.cpp
  • web/coi-serviceworker.js
💤 Files with no reviewable changes (4)
  • web/coi-serviceworker.js
  • src/gui/window_context.cpp
  • tests/ui/test_gui_manager.cpp
  • tests/integration/test_audio_backend_portaudio.cpp
🛑 Comments failed to post (2)
src/audio/audio_engine.h (1)

14-15: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Move this test suite out of src/audio/audio_engine.h into a test-only translation unit.

Line 14 and the TEST(...) blocks (Line 36 onward) put test framework dependencies and test registration code in a production header path. This risks leaking test symbols/includes into non-test builds and creates fragile include/build contracts.

Also applies to: 36-385

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/audio/audio_engine.h` around lines 14 - 15, The production header
currently includes test_framework.h and contains TEST(...) blocks (test
registration) which must be removed from the header; move the include of
test_framework.h and all TEST(...) blocks (and any test helper functions) into a
new test-only translation unit (e.g., audio_engine_test.cpp) that `#includes` the
original audio_engine.h, leaving audio_engine.h with only production
declarations/definitions and no test symbols; update build files to compile the
new test TU only in test targets and delete the test include/TEST blocks from
the header.
src/gui/dialogs/file_dialog_native.cpp (1)

90-97: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Eliminate shell command injection in save-dialog command construction.

At Line 90 and Line 124, popen() executes shell commands built from function parameters (default_name, filter_desc, filter_ext) without escaping. A crafted value containing quotes/shell operators can break out of the intended argument and execute arbitrary commands.

Suggested fix direction
- FILE* pipe = popen(cmd.c_str(), "r");
+ // Avoid shell interpolation; use fork/exec (as in other dialog paths)
+ // and pass arguments as discrete argv entries, or strictly escape every
+ // interpolated token before constructing shell command strings.

Also applies to: 124-133, 147-149

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/gui/dialogs/file_dialog_native.cpp` around lines 90 - 97, The code builds
shell command strings (cmd) using unescaped user-controlled variables
(default_name, filter_desc, filter_ext) and passes them to popen(), allowing
shell injection; replace this by invoking /usr/bin/osascript (or the AppleScript
API) without a shell: construct an argv array with program "/usr/bin/osascript"
and separate "-e" arguments (one per script fragment) and call
posix_spawn/execvp (or use NSTask/NSAppleScript on macOS) so arguments are
passed directly rather than concatenated into a shell command; update the code
paths that build cmd in file_dialog_native.cpp (the blocks that create the
"choose file name" and related osascript commands) to stop using
popen(cmd.c_str(), "r") with interpolated strings and instead spawn the process
with safe argv passing or use native Cocoa APIs to present the save/open
dialogs.

Removed the early '#define fork() (-1)' which conflicted with the later
'#define fork mock_fork' redefinition on Linux. The compiler is stricter
than macOS about redefining function-like macros as object-like macros.

Moved POSIX system headers (unistd.h, fcntl.h, sys/types.h, sys/wait.h)
to the top of the file so that pid_t and other types are available for
mock function signatures before any macros are defined.
…sts by conditionally defining platform-specific mocks and pre-including standard headers
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sudip-mondal-2002 sudip-mondal-2002 added the gssoc:approved GSSoC 2026 contribution label Jun 10, 2026
@sudip-mondal-2002 sudip-mondal-2002 merged commit 262b9aa into sudip-mondal-2002:main Jun 10, 2026
11 checks passed
github-actions Bot added a commit that referenced this pull request Jun 10, 2026
Nicks-19 pushed a commit to Nicks-19/Amplitron that referenced this pull request Jun 10, 2026
* test: add GUI manager coverage tests

* test: achieve near-100% code coverage on GUI files

* fix: resolve fork macro redefinition causing Linux CI compile failure

Removed the early '#define fork() (-1)' which conflicted with the later
'#define fork mock_fork' redefinition on Linux. The compiler is stricter
than macOS about redefining function-like macros as object-like macros.

Moved POSIX system headers (unistd.h, fcntl.h, sys/types.h, sys/wait.h)
to the top of the file so that pid_t and other types are available for
mock function signatures before any macros are defined.

* test: add conditional compilation guards for POSIX headers to support Windows builds

* test: wrap setenv and unsetenv in platform-conditional checks for Windows/MSYS2

* refactor: wrap long debug output lines in gui_manager tests for better readability

* fix: prevent macro poisoning and compilation errors in gui manager tests by conditionally defining platform-specific mocks and pre-including standard headers

* refactor: reorder includes in test_gui_manager to improve header organization

* test: add GuiManager unit tests and implement dependency setup script

* test: add unit tests for WindowContext to improve test coverage

* refactor: reorder includes and add namespace closing comment in window context tests

---------

Co-authored-by: SUDIP MONDAL <sudmondal2002@gmail.com>
Co-authored-by: Sudip Mondal <sudip.mondal@mando.work>
Co-authored-by: SUDIP MONDAL <sudipmondal.2002@rediffmail.com>
sudip-mondal-2002 added a commit that referenced this pull request Jun 11, 2026
* test: add integration test coverage for PedalWidget (#294)

Add tests for: - Color mapping across all 17 effect types. - Parameter change commands committing to undo/redo history. - Footswitch click simulation verifying bypass state toggling.

* test(ui): increase test coverage for pedalboard GUI files

* test: fix compilation, warnings, and formatting in integration tests

* chore: clean up include ordering and whitespace in pedal widget tests

* test: add GUI manager coverage tests (#305)

* test: add GUI manager coverage tests

* test: achieve near-100% code coverage on GUI files

* fix: resolve fork macro redefinition causing Linux CI compile failure

Removed the early '#define fork() (-1)' which conflicted with the later
'#define fork mock_fork' redefinition on Linux. The compiler is stricter
than macOS about redefining function-like macros as object-like macros.

Moved POSIX system headers (unistd.h, fcntl.h, sys/types.h, sys/wait.h)
to the top of the file so that pid_t and other types are available for
mock function signatures before any macros are defined.

* test: add conditional compilation guards for POSIX headers to support Windows builds

* test: wrap setenv and unsetenv in platform-conditional checks for Windows/MSYS2

* refactor: wrap long debug output lines in gui_manager tests for better readability

* fix: prevent macro poisoning and compilation errors in gui manager tests by conditionally defining platform-specific mocks and pre-including standard headers

* refactor: reorder includes in test_gui_manager to improve header organization

* test: add GuiManager unit tests and implement dependency setup script

* test: add unit tests for WindowContext to improve test coverage

* refactor: reorder includes and add namespace closing comment in window context tests

---------

Co-authored-by: SUDIP MONDAL <sudmondal2002@gmail.com>
Co-authored-by: Sudip Mondal <sudip.mondal@mando.work>
Co-authored-by: SUDIP MONDAL <sudipmondal.2002@rediffmail.com>

* refactor: abstract UI interaction logic into click_item helper to simplify pedal board tests

* test(ui): fix hardcoded coordinates to achieve 90%%+ line coverage on pedalboard chain

---------

Co-authored-by: SUDIP MONDAL <sudmondal2002@gmail.com>
Co-authored-by: Sudip Mondal <sudip.mondal@mando.work>
Co-authored-by: Yashraj siwal <yashrajsiwal@gmail.com>
Co-authored-by: SUDIP MONDAL <sudipmondal.2002@rediffmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC 2026 contribution level:intermediate Intermediate task · 25 GSSoC points Medium type:testing Unit tests, integration tests, or test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need test coverage for Gui modules

2 participants