fzf.fish: Missing argument 'exit code' argument in mock function invocation

https://github.com/PatrickF1/fzf.fish/blob/8a299b47d89fef49d5d548ae1bb8ba53452da201/tests/preview_file/custom_dir_preview.fish#L2

The test is failing. The reason seems to be that the mock function requires a [exit code] argument before the [executed code] argument provided.

https://github.com/matchai/fish-mock#usage

This issue appears in many places throughout the test code base. e.g. in all the files in the tests/search_current_dir/ directory for example.

return: Argument 'echo file.txt' is not a valid integer

~/hacking/fzf.fish/tests/preview_file/custom_dir_preview.fish (line 57): 
    return $exit_code
    ^
in function 'mocked_exa_fn_.' with arguments '.'
	called on line 1 of file ~/hacking/fzf.fish/tests/preview_file/custom_dir_preview.fish
in function 'exa' with arguments '.'
	called on line 1 of file ~/hacking/fzf.fish/functions/__fzf_preview_file.fish
in function '__fzf_preview_file' with arguments '.'
	called on line 1 of file ~/hacking/fzf.fish/tests/preview_file/custom_dir_preview.fish
in command substitution
	called on line 3 of file ~/hacking/fzf.fish/tests/preview_file/custom_dir_preview.fish

(Type 'help return' for related documentation)
test: Missing argument at index 2

Standard input (line 9): 
                if test $argv
                   ^
in function '@test' with arguments 'correctly\ uses\ custom\ command\ to\ preview\ directories = file.txt'
	called on line 4 of file ~/hacking/fzf.fish/tests/preview_file/custom_dir_preview.fish

(Type 'help test' for related documentation)
not ok 1 correctly uses custom command to preview directories
  ---
    operator: =
    expected: 
    actual: file.txt
    at: ~/hacking/fzf.fish/tests/preview_file/custom_dir_preview.fish:4
  ...

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 26 (11 by maintainers)

Commits related to this issue

Most upvoted comments

So the only remaining issue would be to make sure that $actual is enclosed in double quotes:

https://github.com/PatrickF1/fzf.fish/blob/5ce8a51b78abf40468c96c06fd7c896bea7d05c0/tests/search_shell_variables/%24_in_curr_token.fish#L7

@test "doesn't overwrite \$ when replacing current token with selected variable" "$actual" = "\$selection"

and

https://github.com/PatrickF1/fzf.fish/blob/5ce8a51b78abf40468c96c06fd7c896bea7d05c0/tests/search_shell_variables/local_var.fish#L6

@test "can find a local variable" "$actual" = a_local_variable

Thanks a lot for your support @PatrickF1 and @jorgebucaran, I really appreciate it. Learned quite a bit about fish in the process.

And again, my apologies for the confusion.

Oops, looks like I hadn’t updated my git repo…

After updating the repo, and with fzf.fish installed w/ Fisher, all tests pass

Very sorry about the confusion

echo "\$fd_captured_opts='$fd_captured_opts'"

$fd_captured_opts='--color=always --hidden --exclude=.git'
ok 8 correctly passes fzf_fd_opts when executing fd

As you can see, echoing $fd_captured_opts makes the test pass…

Oops, I missed that 5.6 was released.

I tested w/ that version but both tests are still failing… Also had to apply @jorgebucaran recommendation above because the tests are still broken 😉

@jorgebucaran I followed your suggestions and now the tests fails “correctly”, thank you.

@PatrickF1 now back to you re: the failing tests 😃

not ok 11 doesn't overwrite $ when replacing current token with selected variable
  ---
    operator: =
    expected: '$selection'
    actual: ''
    at: ~/hacking/fzf.fish/tests/search_shell_variables/$_in_curr_token.fish:7
  ...
not ok 12 can find a local variable
  ---
    operator: =
    expected: a_local_variable
    actual: ''
    at: ~/hacking/fzf.fish/tests/search_shell_variables/local_var.fish:6
  ...