diff --git a/src/test/java/com/github/copilot/sdk/TestUtil.java b/src/test/java/com/github/copilot/sdk/TestUtil.java
index d9462af87..af4474590 100644
--- a/src/test/java/com/github/copilot/sdk/TestUtil.java
+++ b/src/test/java/com/github/copilot/sdk/TestUtil.java
@@ -36,9 +36,9 @@ public static String tempPath(String filename) {
*
* Resolution order:
*
- * - Search the system PATH using {@code where.exe} (Windows) or {@code which}
- * (Linux/macOS).
- * - Fall back to the {@code COPILOT_CLI_PATH} environment variable.
+ * - Use the {@code COPILOT_CLI_PATH} environment variable when set.
+ * - Otherwise search the system PATH using {@code where.exe} (Windows) or
+ * {@code which} (Linux/macOS).
* - Walk parent directories looking for
* {@code nodejs/node_modules/@github/copilot/index.js}.
*
@@ -55,16 +55,16 @@ public static String tempPath(String filename) {
* {@code null} if none was found
*/
static String findCliPath() {
- String copilotInPath = findCopilotInPath();
- if (copilotInPath != null) {
- return copilotInPath;
- }
-
String envPath = System.getenv("COPILOT_CLI_PATH");
if (envPath != null && !envPath.isEmpty()) {
return envPath;
}
+ String copilotInPath = findCopilotInPath();
+ if (copilotInPath != null) {
+ return copilotInPath;
+ }
+
Path current = Paths.get(System.getProperty("user.dir"));
while (current != null) {
Path cliPath = current.resolve("nodejs/node_modules/@github/copilot/index.js");