Skip to content

test(win32): check paths in git bash on Windows#1212

Merged
antongolub merged 1 commit into
google:mainfrom
antongolub:check-win32-paths
Jun 3, 2025
Merged

test(win32): check paths in git bash on Windows#1212
antongolub merged 1 commit into
google:mainfrom
antongolub:check-win32-paths

Conversation

@antongolub

Copy link
Copy Markdown
Collaborator

relates #1211

  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub antongolub force-pushed the check-win32-paths branch 2 times, most recently from 044e2ce to 1abefd2 Compare May 11, 2025 07:33
@antongolub antongolub force-pushed the check-win32-paths branch from 1abefd2 to 15a1519 Compare May 11, 2025 07:38
@antongolub

Copy link
Copy Markdown
Collaborator Author

Hey @Schweinepriester,

I need your assistance to reproduce the case.
https://github.com/antongolub/zx/actions/runs/14953634588/job/42006319291

  test('should create a dir via mkdir', async () => {
    const temp = tmpdir()
    const _$ = $({ verbose: true, cwd: temp })

    console.log('shell:', $.shell)
    await _$`which bash`
    await _$`bash --version`

    await _$`mkdir -p ${path.join(temp, 'AA-zx-test')}`
    await _$`mkdir -p BB-zx-test`
    const { stdout } = await _$`ls -l | grep zx-test`

    assert.match(stdout, /AA-zx-test/)
    assert.match(stdout, /BB-zx-test/)
  })

returns

shell: C:\Program Files\Git\bin\bash.EXE
$ which bash
/usr/bin/bash
$ bash --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-msys)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ mkdir -p $'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\zx-6hgab0hzhsg\\AA-zx-test'
$ mkdir -p BB-zx-test
$ ls -l | grep zx-test
drwxr-xr-x 1 runneradmin 197121 0 May 11 07:39 AA-zx-test
drwxr-xr-x 1 runneradmin 197121 0 May 11 07:39 BB-zx-test

@Schweinepriester

Copy link
Copy Markdown
Contributor

thank you for looking into it!

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 ~/Desktop/zx-check-win32-paths
$ npm run test:smoke:win32

> zx@8.5.4 test:smoke:win32
> node ./test/smoke/win32.test.js

▶ win32
  ✔ should work with windows-specific commands (495.5184ms)
  ✔ quotePowerShell works (195.3788ms)
Set-PSReadLineOption: C:\Users\KaiHollberg\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:2
Line |
   2 |  Set-PSReadLineOption -PredictionSource History
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The predictive suggestion feature cannot be enabled because the console output doesn't support virtual terminal
     | processing or it's redirected.
shell: C:\Program Files\Git\usr\bin\bash.EXE
$ which bash
  ✔ should work with pwsh when it is available (650.1617ms)
/usr/bin/bash
$ bash --version
GNU bash, version 5.2.12(1)-release (x86_64-pc-msys)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ mkdir -p $'C:\\Users\\KAIHOL~1\\AppData\\Local\\Temp\\zx-tiyz0vvwyar\\AA-zx-test'
$ mkdir -p BB-zx-test
$ ls -l | grep zx-test
drwxr-xr-x 1 AzureAD+KaiHollberg 4096 0 Mai 11 10:03 AA-zx-test
drwxr-xr-x 1 AzureAD+KaiHollberg 4096 0 Mai 11 10:03 BB-zx-test
  ✔ should create a dir via mkdir (216.7672ms)
✔ win32 (1559.4072ms)
ℹ tests 4
ℹ suites 1
ℹ pass 4
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 1562.9248

image

so it would appear to work oO


thinking I'm going insane I doubled checked though:

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 ~/Desktop/zx-check-win32-paths
$ ls -l | grep zx-test

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 ~/Desktop/zx-check-win32-paths
$ cat windows-test.mjs
import { $ } from 'zx'
import path from 'node:path'
import { fileURLToPath } from 'url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

$.verbose = true
await $`zx --version`
await $`mkdir -p ${path.join(__dirname, 'AA-zx-test')}`
await $`mkdir -p BB-zx-test`
await $`ls -l | grep zx-test`

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 ~/Desktop/zx-check-win32-paths
$ zx windows-test.mjs
$ zx --version
8.5.3
$ mkdir -p $'C:\\Users\\KaiHollberg\\Desktop\\zx-check-win32-paths\\AA-zx-test'
$ mkdir -p BB-zx-test
$ ls -l | grep zx-test
drwxr-xr-x 1 AzureAD+KaiHollberg 4096      0 Mai 11 10:14 AA-zx-test
drwxr-xr-x 1 AzureAD+KaiHollberg 4096      0 Mai 11 10:14 BB-zx-test

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 ~/Desktop/zx-check-win32-paths
$ cd /c/git/frontend_main/apps/acheron/

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 /c/git/frontend_main/apps/acheron (nt-next-windows)
$ cat windows-test.mjs
import { $ } from 'zx'
import path from 'node:path'
import { fileURLToPath } from 'url'

const __dirname = path.dirname(fileURLToPath(import.meta.url))

$.verbose = true
await $`zx --version`
await $`mkdir -p ${path.join(__dirname, 'AA-zx-test')}`
await $`mkdir -p BB-zx-test`
await $`ls -l | grep zx-test`

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 /c/git/frontend_main/apps/acheron (nt-next-windows)
$ ls -l | grep zx-test

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 /c/git/frontend_main/apps/acheron (nt-next-windows)
$ zx windows-test.mjs
$ zx --version
8.5.3
$ mkdir -p $'C:\\git\\frontend_main\\apps\\acheron\\AA-zx-test'
$ mkdir -p BB-zx-test
$ ls -l | grep zx-test
drwxr-xr-x 1 AzureAD+KaiHollberg 4096    0 Mai 11 10:15 BB-zx-test

image

oO

@Schweinepriester

Schweinepriester commented May 11, 2025

Copy link
Copy Markdown
Contributor

tried checking permissions now:

AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 /c/git/frontend_main/apps (nt-next-windows)
$ ll
total 12
drwxr-xr-x 1 AzureAD+KaiHollberg 4096 0 Mai 11 10:15 acheron/
[…]
AzureAD+KaiHollberg@DESKTOP-42OUI8T MINGW64 ~/Desktop
$ ll
[…]
drwxr-xr-x 1 AzureAD+KaiHollberg 4096         0 Mai 11 10:14  zx-check-win32-paths/
[…]

they are the same…

@antongolub

Copy link
Copy Markdown
Collaborator Author

Ok, I'll merge this as a test suite improvement for now. We'll try to dig up the rest later.

@antongolub antongolub merged commit bd0ce19 into google:main Jun 3, 2025
28 checks passed
nizar0x1f added a commit to nizar0x1f/zx that referenced this pull request Jul 17, 2025
Converts Windows paths to POSIX format when running in Git Bash on Windows.
Fixes silent failures of commands like `mkdir -p ${path.join(__dirname, 'dir')}`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants