| 228 | } |
| 229 | |
| 230 | void tst_executor::resolveGpgconfCommand() { |
| 231 | // Empty input |
| 232 | { |
| 233 | auto result = Pass::resolveGpgconfCommand(""); |
| 234 | QVERIFY2(result.program == "gpgconf", |
| 235 | "Empty input should fallback to gpgconf"); |
| 236 | } |
| 237 | |
| 238 | // WSL simple |
| 239 | { |
| 240 | auto result = Pass::resolveGpgconfCommand("wsl gpg2"); |
| 241 | QStringList expectedArgs = {"gpgconf"}; |
| 242 | QVERIFY2(result.program == "wsl" && result.arguments == expectedArgs, |
| 243 | "WSL simple should replace gpg with gpgconf"); |
| 244 | } |
| 245 | |
| 246 | // WSL with distro |
| 247 | { |
| 248 | auto result = Pass::resolveGpgconfCommand("wsl --distro Debian gpg2"); |
| 249 | QVERIFY2(result.program == "wsl", "WSL distro preserves wsl"); |
| 250 | QVERIFY2(result.arguments.contains("--distro") && |
| 251 | result.arguments.contains("Debian"), |
| 252 | "WSL distro arguments should be preserved"); |
| 253 | } |
| 254 | |
| 255 | // WSL with full path |
| 256 | { |
| 257 | auto result = Pass::resolveGpgconfCommand("wsl /usr/bin/gpg2"); |
| 258 | QStringList expectedArgs = {"/usr/bin/gpgconf"}; |
| 259 | QVERIFY2(result.program == "wsl" && result.arguments == expectedArgs, |
| 260 | "WSL with full path should preserve directory"); |
| 261 | } |
| 262 | |
| 263 | // WSL complex (should fallback) |
| 264 | { |
| 265 | auto result = Pass::resolveGpgconfCommand("wsl sh -c \"gpg2 --version\""); |
| 266 | QVERIFY2(result.program == "gpgconf", "Complex WSL shell should fallback"); |
| 267 | } |
| 268 | |
| 269 | // WSL malformed (only "wsl") |
| 270 | { |
| 271 | auto result = Pass::resolveGpgconfCommand("wsl"); |
| 272 | QVERIFY2(result.program == "gpgconf", "Malformed WSL should fallback"); |
| 273 | } |
| 274 | |
| 275 | // PATH-only |
| 276 | { |
| 277 | auto result = Pass::resolveGpgconfCommand("gpg2"); |
| 278 | QVERIFY2(result.program == "gpgconf" && result.arguments.isEmpty(), |
| 279 | "PATH-only should fallback with no extra arguments"); |
| 280 | } |
| 281 | |
| 282 | // Unix absolute - use temp directory for filesystem-independent test |
| 283 | { |
| 284 | QTemporaryDir tempDir; |
| 285 | QVERIFY2(tempDir.isValid(), "Temp directory should be valid"); |
| 286 | QString absPath = tempDir.path() + "/gpg2"; |
| 287 | QFile gpg2File(absPath); |