fd icon indicating copy to clipboard operation
fd copied to clipboard

Unit test failed on Windows

Open vidhyasasi opened this issue 1 year ago • 6 comments

Checks

  • [X] I have read the troubleshooting section and still think this is a bug.

Describe the bug you encountered:

Ran cargo test for testing unit test and two tests failed on a Windows machine.

The error of a cargo test looks like:

failures:

''' ---- test_exec_with_separator stdout ---- thread 'test_exec_with_separator' panicked at 'fd --path-separator=# --absolute-path foo --exec echo did not exit successfully. stdout:


stderr:

[fd error]: Command not found: echo [fd error]: Command not found: echo [fd error]: Command not found: echo [fd error]: Command not found: echo [fd error]: Command not found: echo [fd error]: Command not found: echo ---', tests\testenv\mod.rs:238:13 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

---- test_list_details stdout ---- thread 'test_list_details' panicked at 'fd --list-details did not exit successfully. stdout:


stderr:

[fd error]: 'fd --list-details' is not supported on Windows unless GNU 'ls' is installed. ---', tests\testenv\mod.rs:238:13

failures: test_exec_with_separator test_list_details

test result: FAILED. 82 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.79s

error: test failed, to rerun pass --test tests '''

Describe what you expected to happen:

No response

What version of fd are you using?

fd 8.7.0

Which operating system / distribution are you on?

Windows version 10.0.20348 Build 20348

vidhyasasi avatar Jun 06 '23 13:06 vidhyasasi

Apparently, you don't have an echo command. Is that normal on windows?

tmccombs avatar Jun 06 '23 20:06 tmccombs

I am running rust using PowerShell in Windows. That is why it says "Command not found: echo". Because it is not available in PowerShell but in CommandLine. The equivalent of echo in powershell is "Write-Output".

vidhyasasi avatar Jun 07 '23 06:06 vidhyasasi

@tmccombs I think echo is just a shell builtin on Windows, there's no standalone echo.exe. But probably the GitHub actions runners have one from MSYS or something which is why it works in CI. I think fd -x cmd /C echo should work.

tavianator avatar Jun 07 '23 20:06 tavianator

hmm, it looks like some other tests that use echo are configured not to run on windows.

I think the ways we could address this are:

  1. Don't run these tests on windows
  2. Don't run these test unless there is an echo executable
  3. On windows somehow create an echo executable (shell script?) as part of the test harness
  4. Use a macro or function that takes a command array, and replaces "echo" with "cmd", "/C", "echo", on windows.

tmccombs avatar Jun 08 '23 05:06 tmccombs

Nope, it looks like fd is broken, at least on powershell on Windows 10 (both within and without neovim):

PS C:\Users\user\app> echo "123"
123
PS C:\Users\user\app> fd -e exe --exec echo {}
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo
[fd error]: Command not found: echo

matu3ba avatar Nov 07 '23 15:11 matu3ba

echo is a builtin command in powershell. when you run echo "123" powershell prints "123" directly, it doesn't invoke a separate program named "echo".

tmccombs avatar Nov 08 '23 07:11 tmccombs