[Linux] Add AutoStart implementation and tests#40
Conversation
Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
…gnore Co-authored-by: lijy91 <3889523+lijy91@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds Linux-specific test coverage and build integration for the new cross-platform AutoStart API work by introducing a dedicated autostart_test binary on Linux and ignoring CodeQL-generated build artifacts.
Changes:
- Added
tests/autostart_test.cppcovering theAutoStartAPI lifecycle and.desktopcontent expectations under an isolated$XDG_CONFIG_HOME. - Registered the new
autostart_testexecutable with CTest for Linux builds. - Updated
.gitignoreto exclude CodeQL build/output artifacts.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/autostart_test.cpp | Adds Linux-only tests for enable/disable/is-enabled behavior and basic .desktop content validation. |
| tests/CMakeLists.txt | Adds a Linux-only autostart_test target and CTest registration. |
| .gitignore | Ignores CodeQL-generated build directories/files. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| std::cerr << "Desktop file Exec line missing executable path." << std::endl; | ||
| RemoveDesktopFile(tmpDir, testId); | ||
| return 1; | ||
| } |
There was a problem hiding this comment.
The .desktop content test exercises an argument containing spaces ("value with space"), but it doesn't assert that the generated Exec= line actually preserves it as a single argument (i.e., is quoted/escaped correctly). Adding a check that the Exec line contains the properly quoted/escaped argument would better validate the intended XDG quoting behavior.
| } | |
| } | |
| // Verify that the Exec line preserves the spaced argument as a single argument | |
| std::size_t execPos = content.find("Exec="); | |
| if (execPos != std::string::npos) { | |
| std::size_t endOfLine = content.find('\n', execPos); | |
| std::string execLine = | |
| content.substr(execPos, endOfLine == std::string::npos ? std::string::npos | |
| : endOfLine - execPos); | |
| if (execLine.find("\"value with space\"") == std::string::npos && | |
| execLine.find("value\\ with\\ space") == std::string::npos) { | |
| std::cerr << "Exec line does not preserve spaced argument correctly: " | |
| << execLine << std::endl; | |
| RemoveDesktopFile(tmpDir, testId); | |
| return 1; | |
| } | |
| } |
| @@ -0,0 +1,350 @@ | |||
| #include <sys/stat.h> | |||
There was a problem hiding this comment.
<sys/stat.h> is included but not used anywhere in this test file. Removing unused headers keeps build times and dependencies minimal.
| #include <sys/stat.h> |
Implements Linux XDG autostart support via
.desktopfiles in~/.config/autostart/, completing the cross-platformAutoStartAPI for Linux.Changes
src/platform/linux/autostart_linux.cpp— Full XDG autostart implementation:Enable()writes a.desktopfile with[Desktop Entry],Type=Application,Exec=,Hidden=false,X-GNOME-Autostart-enabled=true,X-KDE-autostart-after=panelDisable()removes the file (idempotent)IsEnabled()checks file existence$XDG_CONFIG_HOME; falls back to$HOME/.config; detects executable via/proc/self/exetests/autostart_test.cpp— New tests using isolatedmkdtemp-based config dirs with scopedXDG_CONFIG_HOMEoverride, covering: constructors, getters/setters, enable/disable lifecycle, idempotent disable,.desktopcontent validation, and re-enable updatestests/CMakeLists.txt— Registersautostart_testfor Linux buildsUsage
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.