Skip to content

Commit bbd236b

Browse files
committed
bugfix: Lute tests on windows machines
1 parent 25c1022 commit bbd236b

File tree

5 files changed

+65
-7
lines changed

5 files changed

+65
-7
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: ["primary"]
66
pull_request:
77
branches: ["primary"]
8+
workflow_dispatch:
89

910
concurrency:
1011
group: ${{ github.workflow }}-${{ github.ref }}
@@ -43,7 +44,8 @@ jobs:
4344
run: rm .luaurc
4445

4546
- name: Run Luau Tests
46-
run: find tests -name "*.test.luau" | xargs -I {} ${{ steps.build_lute.outputs.exe_path }} run {}
47+
shell: bash
48+
run: find tests -name "*.test.luau" | xargs -I {} $(echo '${{ steps.build_lute.outputs.exe_path }}' | tr '\\' '/') run {}
4749

4850
run-lute-cxx-unittests:
4951
runs-on: ${{ matrix.os }}

lute/std/libs/path/win32/init.luau

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ function win32.resolve(...: pathlike): path
273273
end
274274

275275
if not win32.isabsolute(path) then
276-
local cwd = win32.parse(process.cwd())
276+
local cwd = win32.parse(process.cwd())
277+
print("-Nil?:", cwd, "-Nil?:", path, "-Nil?", joinHelper)
277278
joinHelper(cwd, path)
278279
path = cwd
279280
end

tests/cli/compile.test.luau

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ local COMPILEE_CONTENTS = [[return "Hello world"]]
2323
local lutePath = process.execpath()
2424
local tmpDir = system.tmpdir()
2525

26-
test.suite("Lute CLI Compile", function(suite)
27-
suite:case("Run compile", function(check)
26+
test.suite("stdlib_compile", function(suite)
27+
suite:case("run_in_script_bytecode_compilation", function(check)
2828
-- Setup
2929
-- Create files
3030
local compilerPath = path.join(tmpDir, "compiler.luau")
@@ -39,8 +39,9 @@ test.suite("Lute CLI Compile", function(suite)
3939

4040
local result = process.run({ path.format(lutePath), path.format(compilerPath), path.format(compileePath) })
4141
-- Compilation should work with no memory leaks
42+
local expectedNewline = system.os == "Windows_NT" and "\r\n" or "\n"
4243
check.eq(result.stderr, "")
43-
check.eq(result.stdout, "SUCCESS\n")
44+
check.eq(result.stdout, "SUCCESS" .. expectedNewline)
4445
check.eq(result.exitcode, 0)
4546

4647
-- -- Cleanup

tests/cli/loadbypath.test.luau

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ test.suite("Lute CLI Run", function(suite)
4343

4444
local result = process.run({ tostring(lutePath), requirerPath, requireePath })
4545
check.eq(result.exitcode, 0)
46-
check.eq(result.stdout, "Success\n")
46+
local expectedNewline = system.os == "Windows_NT" and "\r\n" or "\n"
47+
check.eq(result.stdout, "Success" .. expectedNewline)
4748

4849
-- Cleanup
4950
fs.remove(requirerPath)

tests/std/process.test.luau

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local pathlib = require("@std/path")
22
local process = require("@std/process")
33
local test = require("@std/test")
4+
local system = require("@std/system")
45

56
test.suite("ProcessSuite", function(suite)
67
suite:case("homedir_and_cwd_and_execpath", function(assert)
@@ -19,7 +20,10 @@ test.suite("ProcessSuite", function(suite)
1920
assert.eq(r.stdout, "hello-from-lute\n")
2021
end)
2122

22-
suite:case("run_shell_and_cwd", function(assert)
23+
suite:case("run_shell_and_cwd_posix", function(assert)
24+
if system.win32 then
25+
return
26+
end
2327
local r = process.run({ "pwd" }, { cwd = "/" })
2428
assert.tableeq(r, {
2529
exitcode = 0,
@@ -37,6 +41,55 @@ test.suite("ProcessSuite", function(suite)
3741
})
3842
end)
3943

44+
suite:case("run_shell_and_cwd_windows", function(assert)
45+
if system.unix or system.macos or system.linux then
46+
return
47+
end
48+
-- Get the current drive letter and construct root path
49+
local cwd = process.cwd()
50+
local cwdPath = pathlib.parse(cwd)
51+
local driveLetter = cwdPath.driveLetter
52+
local rootPath = driveLetter .. ":\\"
53+
54+
-- Git Bash on Windows converts C:\ to /c, D:\ to /d, etc.
55+
local expectedOutput = "/" .. string.lower(driveLetter) .. "\n"
56+
57+
local r = process.run({ "pwd" }, { cwd = rootPath })
58+
assert.tableeq(r, {
59+
exitcode = 0,
60+
stdout = expectedOutput,
61+
stderr = "",
62+
ok = true,
63+
})
64+
65+
local r2 = process.run({ "echo hello!" }, { shell = true })
66+
assert.tableeq(r2, {
67+
exitcode = 0,
68+
stdout = "hello!\r\n",
69+
stderr = "",
70+
ok = true,
71+
})
72+
end)
73+
74+
suite:case("run_with_cwd_tmpdir", function(assert)
75+
-- Platform-independent test using tmpdir
76+
local tmpdir = system.tmpdir()
77+
local tmpdirStr = pathlib.format(tmpdir)
78+
79+
-- Use pwd/cd to verify cwd was changed correctly
80+
local cmd = if system.win32 then { "cd" } else { "pwd" }
81+
local opts = if system.win32 then { cwd = tmpdirStr, shell = true } else { cwd = tmpdirStr }
82+
local lf = if system.win32 then "\r\n" else "\n"
83+
84+
local r = process.run(cmd, opts)
85+
assert.eq(r.exitcode, 0)
86+
assert.eq(r.ok, true)
87+
assert.eq(r.stderr, "")
88+
-- Normalize path separators and compare (remove trailing newline)
89+
local actualPath = string.gsub(r.stdout, lf .. "$", "")
90+
assert.eq(actualPath, tmpdirStr)
91+
end)
92+
4093
suite:case("run_nonzero_exitcode", function(assert)
4194
local r = process.run({ "sh", "-c", "exit 41" })
4295
assert.tableeq(r, {

0 commit comments

Comments
 (0)