Skip to content

Commit 77e4d3e

Browse files
Ben HillisCopilot
andcommitted
Fix review feedback: use exec, WSLC_TEST_METHOD, and full path in test
Address review feedback: - Use 'exec' to replace the shell process instead of spawning a child process (OneBlue, Copilot) - Use WSLC_TEST_METHOD macro so the test only runs in the WSLC test suite, not WSL1/WSL2 suites where wslc.exe is unavailable - Use GetMsiPackagePath() + wslpath to resolve the full path to wslc.exe and wslc script, since the install directory may not be on PATH in CI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 05b2c77 commit 77e4d3e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/windows/wslc/wslc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
WSL_PATH="$(dirname "$(realpath "$0")")"
99
WSLC_EXE="$WSL_PATH/wslc.exe"
1010

11-
"$WSLC_EXE" "$@"
12-
exit $?
11+
exec "$WSLC_EXE" "$@"

test/windows/SimpleTests.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,16 @@ class SimpleTests
295295
VERIFY_IS_TRUE(output.find(L"/mnt/c/Users/Test User/AppData/Local/Programs/Microsoft VS Code/bin") != std::wstring::npos);
296296
}
297297

298-
TEST_METHOD(WslcShellScript)
298+
WSLC_TEST_METHOD(WslcShellScript)
299299
{
300300
// Verify that the 'wslc' shell script (no .exe extension) invokes wslc.exe
301301
// and produces the same output as calling wslc.exe directly.
302-
auto [exeOutput, exeErr] = LxsstuLaunchWslAndCaptureOutput(L"wslc.exe version");
303-
auto [scriptOutput, scriptErr] = LxsstuLaunchWslAndCaptureOutput(L"wslc version");
302+
// Use the full install path since the MSI directory may not be on %PATH% in CI.
303+
auto installPath = wsl::windows::common::wslutil::GetMsiPackagePath().value();
304+
auto exeCmd = std::format(L"$(wslpath '{}wslc.exe') version", installPath);
305+
auto scriptCmd = std::format(L"$(wslpath '{}wslc') version", installPath);
306+
auto [exeOutput, exeErr] = LxsstuLaunchWslAndCaptureOutput(exeCmd);
307+
auto [scriptOutput, scriptErr] = LxsstuLaunchWslAndCaptureOutput(scriptCmd);
304308
VERIFY_ARE_EQUAL(exeOutput, scriptOutput);
305309
VERIFY_ARE_EQUAL(exeErr, scriptErr);
306310
}

0 commit comments

Comments
 (0)