Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve interactiveness checks #3449

Merged
merged 2 commits into from
Oct 8, 2023

Conversation

calestyo
Copy link
Contributor

This should fix #3445 and bring some further minor cleanups.

As for the last commit of this series, which removes the interactiveness checks from the completion scripts and your comment:

Fair enough. Please note that fzf can be installed by manually cloning the repo, so the files can be placed anywhere the user wants and they can make any mistake they want :)

over in #3445:

I'd guess most people will install software via some form of packaging, which takes care of that - after all that's what the whole distros-system in *nix/BSD/Linux is there for.

If someone installs manually from the sources, well than I think one can reasonably expect him to know what he's doing - or at least to live with it, when doing stupid things.

After all, we can only do so much to prevent people from shooting themselves.

Checking for interactiveness in the key-binding scripts is IMO still some reasonable effort, because users are expected to actually source them manually in their .bashrc or similar.

But for the completion scripts its IMO overkill. We also don't check there whether the shell is really bash or perhaps just POSIX sh.

That being said, if you still insist on keeping the key in the completion scripts, too, just don't pick 1ee68e1.

Cheers,
Chris.

@calestyo
Copy link
Contributor Author

@junegunn Any idea why the test suite fails here?

I've tried[0] to run the tests manually on some host of mine (on the branch that I want to get merged):

The ones that failed here on GH seemed to work when running the suite locally, but others failed (though they seem unrelated to my commits?):

$ FZF_VERSION=0.42.3 FZF_REVISION=tarball make install && ./install --all && LC_ALL=C tmux new-session -d && ruby test/test_go.rb --verbose
rm -f bin/fzf
cp -f target/fzf-linux_amd64 bin/fzf
Downloading bin/fzf ...
  - Already exists
  - Checking fzf executable ... 0.42.3 != 0.42.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 1347k  100 1347k    0     0  2692k      0 --:--:-- --:--:-- --:--:-- 7879k
  - Checking fzf executable ... 0.42.0

Generate /home/calestyo/.fzf.bash ... OK
Generate /home/calestyo/.fzf.zsh ... OK
Update fish_user_paths ... Failed
Symlink /home/calestyo/.config/fish/functions/fzf_key_bindings.fish ... OK

Update /home/calestyo/.bashrc:
  - [ -f ~/.fzf.bash ] && source ~/.fzf.bash
    + Added

Update /home/calestyo/.zshrc:
  - [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
    + Added

Create /home/calestyo/.config/fish/functions/fish_user_key_bindings.fish:
    function fish_user_key_bindings
      fzf_key_bindings
    end

Finished. Restart your shell or reload config file.
   source ~/.bashrc  # bash
   source ~/.zshrc   # zsh
   fzf_key_bindings  # fish

Use uninstall script to remove fzf.

For more information, see: https://github.com/junegunn/fzf
Run options: --verbose --seed 51537

# Running:

TestFish#test_alt_c = 0.62 s = .
TestFish#test_ctrl_r_multiline = 0.37 s = .
TestFish#test_ctrl_t_unicode = 0.75 s = .
TestFish#test_alt_c_command = 0.73 s = .
TestFish#test_ctrl_t = 0.56 s = .
TestFish#test_ctrl_r = 1.06 s = .
TestFish#test_ctrl_r_abort = 0.74 s = .
TestZsh#test_custom_completion_api = 0.58 s = .
TestZsh#test_file_completion = 0.72 s = .
TestZsh#test_unset_completion = 0.53 s = .
TestZsh#test_ctrl_r = 0.98 s = .
TestZsh#test_ctrl_t_unicode = 0.56 s = .
TestZsh#test_custom_completion = 0.30 s = .
TestZsh#test_complete_quoted_command = 0.71 s = .
TestZsh#test_ctrl_r_multiline = 0.32 s = .
TestZsh#test_file_completion_unicode = 0.40 s = .
TestZsh#test_dir_completion = 0.35 s = .
TestZsh#test_ctrl_r_abort = 0.64 s = .
TestZsh#test_ssh_completion = 0.41 s = .
TestZsh#test_ctrl_t = 0.49 s = .
TestZsh#test_process_completion = 0.37 s = .
TestZsh#test_alt_c_command = 0.66 s = .
TestZsh#test_alt_c = 0.39 s = .
TestZsh#test_file_completion_root = 0.18 s = .
TestGoFZF#test_preview_clear_screen = 0.85 s = .
TestGoFZF#test_header = 0.15 s = .
TestGoFZF#test_bind = 0.30 s = .
TestGoFZF#test_change_header = 0.18 s = .
TestGoFZF#test_expect_print_query = 0.30 s = .
TestGoFZF#test_height_range_fit_preview_above = 0.21 s = .
TestGoFZF#test_expect = 4.08 s = .
TestGoFZF#test_reload_and_change_preview_should_update_preview = 0.23 s = .
TestGoFZF#test_clear_list_when_header_lines_changed_due_to_reload = 0.23 s = .
TestGoFZF#test_ellipsis = 0.22 s = .
TestGoFZF#test_tac_sort = 0.32 s = .
TestGoFZF#test_transform_query = 0.36 s = .
TestGoFZF#test_header_lines_with_nth = 0.31 s = .
TestGoFZF#test_or_operator = 0.04 s = .
TestGoFZF#test_invalid_cache_query_type = 0.53 s = .
TestGoFZF#test_preview_update_on_select = 0.18 s = .
TestGoFZF#test_read0 = 0.03 s = .
TestGoFZF#test_height_range_fit = 0.14 s = .
TestGoFZF#test_no_clear = 0.17 s = .
TestGoFZF#test_exit_0 = 0.27 s = .
TestGoFZF#test_execute_plus_flag = 0.28 s = .
TestGoFZF#test_preview_bindings_with_default_preview = 0.26 s = .
TestGoFZF#test_bind_print_query = 0.29 s = .
TestGoFZF#test_kill_default_command_on_abort = 0.27 s = .
TestGoFZF#test_smart_case_for_each_term = 0.03 s = .
TestGoFZF#test_change_preview_window = 0.24 s = .
TestGoFZF#test_toggle_sort = 0.64 s = .
TestGoFZF#test_change_first_last = 0.22 s = .
TestGoFZF#test_put = 0.29 s = .
TestGoFZF#test_sync = 0.40 s = .
TestGoFZF#test_change_and_transform_header = 0.39 s = .
TestGoFZF#test_become_tty = 0.73 s = .
TestGoFZF#test_labels_bottom = 0.15 s = .
TestGoFZF#test_preview_size_0 = 0.24 s = .
TestGoFZF#test_keep_right = 0.20 s = .
TestGoFZF#test_select_deselect = 0.30 s = .
TestGoFZF#test_tiebreak_begin_algo_v2 = 0.02 s = .
TestGoFZF#test_info_separator_unicode = 0.14 s = .
TestGoFZF#test_preview_header = 0.27 s = .
TestGoFZF#test_start_event = 0.16 s = .
TestGoFZF#test_backward_delete_char_eof = 0.27 s = .
TestGoFZF#test_expect_printable_character_print_query = 0.32 s = .
TestGoFZF#test_item_index_reset_on_reload = 0.33 s = .
TestGoFZF#test_partial_caching = 0.23 s = .
TestGoFZF#test_expect_print_query_select_1 = 0.27 s = .
TestGoFZF#test_change_preview_window_rotate_hidden_down = 0.19 s = .
TestGoFZF#test_preview_hidden = 0.23 s = .
TestGoFZF#test_reload_and_change_cache = 0.22 s = .
TestGoFZF#test_toggle_preview_wrap = 0.25 s = .
TestGoFZF#test_header_first_reverse = 0.21 s = .
TestGoFZF#test_normalized_match = 0.03 s = .
TestGoFZF#test_change_preview_window_rotate = 0.32 s = .
TestGoFZF#test_change_prompt = 0.17 s = .
TestGoFZF#test_transform_prompt = 0.29 s = .
TestGoFZF#test_accept_non_empty_with_empty_list = 0.30 s = .
TestGoFZF#test_change_query = 0.16 s = .
TestGoFZF#test_one_and_zero = 0.17 s = .
TestGoFZF#test_reload_and_change = 0.14 s = .
TestGoFZF#test_disabled_preview_update = 0.29 s = .
TestGoFZF#test_scroll_off = 0.21 s = .
TestGoFZF#test_height_range_with_exit_0 = 0.16 s = .
TestGoFZF#test_reload_even_when_theres_no_match = 0.21 s = .
TestGoFZF#test_delete_with_modifiers = 0.23 s = .
TestGoFZF#test_change_preview_window_rotate_hidden = 0.26 s = .
TestGoFZF#test_header_and_header_lines = 0.14 s = .
TestGoFZF#test_preview_correct_tab_width_after_ansi_reset_code = 0.20 s = .
TestGoFZF#test_select_all_deselect_all_toggle_all = 0.39 s = .
TestGoFZF#test_tac = 0.37 s = .
TestGoFZF#test_close = 0.19 s = .
TestGoFZF#test_disabled = 0.21 s = .
TestGoFZF#test_invalid_option = 0.02 s = .
TestGoFZF#test_kill_reload_command_on_accept = 0.43 s = .
TestGoFZF#test_preview_flags = 0.27 s = .
TestGoFZF#test_preview_size_0_hidden = 0.31 s = .
TestGoFZF#test_toggle_header = /usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/assertions.rb:183:in `assert'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/assertions.rb:218:in `assert_equal'
test/test_go.rb:2573:in `assert_block'
test/test_go.rb:1231:in `block in test_toggle_header'
test/test_go.rb:137:in `block in until'
test/test_go.rb:33:in `wait'
test/test_go.rb:110:in `until'
test/test_go.rb:1231:in `test_toggle_header'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:98:in `block (3 levels) in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:195:in `capture_exceptions'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:95:in `block (2 levels) in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:281:in `time_it'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:94:in `block in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:376:in `on_signal'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:221:in `with_info_handler'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:93:in `run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:1042:in `run_one_method'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:350:in `run_one_method'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:337:in `block (2 levels) in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:336:in `each'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:336:in `block in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:376:in `on_signal'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:363:in `with_info_handler'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:335:in `run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:169:in `block in __run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:169:in `map'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:169:in `__run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:146:in `run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:73:in `block in autorun'
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
seq 4 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --header-lines 2 --header foo --bind space:toggle-header --header-first --height 10 --border
seq 4 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --header-lines 2 --header foo --bind space:toggle-header --header-first --height 10 --border
unknown action: toggle-header
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
10.04 s = F
TestGoFZF#test_execute_shell = 0.16 s = .
TestGoFZF#test_fzf_default_command_failure = 0.21 s = .
TestGoFZF#test_multi_max = 0.42 s = .
TestGoFZF#test_listen_with_api_key = 0.15 s = F
TestGoFZF#test_unbind_rebind = 0.20 s = .
TestGoFZF#test_height_range_fit_preview_left = 0.14 s = .
TestGoFZF#test_with_nth = 0.55 s = .
TestGoFZF#test_exact = 0.04 s = .
TestGoFZF#test_header_lines_reverse = 0.29 s = .
TestGoFZF#test_history = /usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/assertions.rb:183:in `assert'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/assertions.rb:218:in `assert_equal'
test/test_go.rb:202:in `assert_equal'
test/test_go.rb:928:in `block in test_history'
test/test_go.rb:137:in `block in until'
test/test_go.rb:33:in `wait'
test/test_go.rb:110:in `until'
test/test_go.rb:928:in `test_history'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:98:in `block (3 levels) in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:195:in `capture_exceptions'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:95:in `block (2 levels) in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:281:in `time_it'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:94:in `block in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:376:in `on_signal'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:221:in `with_info_handler'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest/test.rb:93:in `run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:1042:in `run_one_method'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:350:in `run_one_method'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:337:in `block (2 levels) in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:336:in `each'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:336:in `block in run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:376:in `on_signal'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:363:in `with_info_handler'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:335:in `run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:169:in `block in __run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:169:in `map'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:169:in `__run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:146:in `run'
/usr/lib/ruby/gems/3.1.0/gems/minitest-5.15.0/lib/minitest.rb:73:in `block in autorun'
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
seq 100 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --history=/tmp/fzf-test-history --history-size=4 > /tmp/output-test_history-0.tmp; mv /tmp/output-test_history-0.tmp /tmp/output-test_history-0
seq 100 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --history=/tmp/fzf-test-history --history-size=4 > /tmp/output-test_history-0.tmp; mv /tmp/output-test_history-0.tmp /tmp/output-test_history-0
mv: overwrite '/tmp/output-test_history-0'?
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
11.06 s = F
TestGoFZF#test_header_lines_reverse_list = 0.39 s = .
TestGoFZF#test_margin = 0.22 s = .
TestGoFZF#test_info_inline_right = 0.27 s = .
TestGoFZF#test_query_unicode = 0.29 s = .
TestGoFZF#test_reload = 0.62 s = .
TestGoFZF#test_inverse_only_search_should_not_sort_the_result = 0.17 s = .
TestGoFZF#test_preview_scroll_begin_constant = 0.20 s = .
TestGoFZF#test_labels_center = 0.16 s = .
TestGoFZF#test_focus_event = 0.19 s = .
TestGoFZF#test_tiebreak_index_begin = 0.05 s = .
TestGoFZF#test_with_nth_basic = 0.02 s = .
TestGoFZF#test_fzf_default_command = 0.29 s = .
TestGoFZF#test_margin_reverse_list = 0.15 s = .
TestGoFZF#test_header_and_header_lines_reverse = 0.15 s = .
TestGoFZF#test_vanilla = 0.43 s = .
TestGoFZF#test_kill_reload_command_on_abort = 0.30 s = .
TestGoFZF#test_scroll = 0.60 s = .
TestGoFZF#test_scroll_off_large = 0.17 s = .
TestGoFZF#test_exitstatus_empty = 0.24 s = .
TestGoFZF#test_header_and_header_lines_reverse_list = 0.15 s = .
TestGoFZF#test_hscroll_off = 0.63 s = .
TestGoFZF#test_filter_exitstatus = 0.04 s = .
TestGoFZF#test_info_right = 0.19 s = .
TestGoFZF#test_with_nth_ansi = 0.03 s = .
TestGoFZF#test_clear_query = 0.17 s = .
TestGoFZF#test_jump = 0.36 s = .
TestGoFZF#test_info_separator_ansi_colors_and_tabs = 0.13 s = .
TestGoFZF#test_pointer_with_jump = 0.17 s = .
TestGoFZF#test_pos = 0.27 s = .
TestGoFZF#test_info_hidden = 0.20 s = .
TestGoFZF#test_file_word = 0.25 s = .
TestGoFZF#test_preview = 2.58 s = .
TestGoFZF#test_bind_replace_query = 0.18 s = .
TestGoFZF#test_header_first = 0.21 s = .
TestGoFZF#test_tiebreak_length_with_nth = 0.03 s = .
TestGoFZF#test_prev_next_selected = 0.20 s = .
TestGoFZF#test_multi_order = 0.29 s = .
TestGoFZF#test_execute_multi = 0.30 s = .
TestGoFZF#test_header_reverse = 0.21 s = .
TestGoFZF#test_kill_default_command_on_accept = 0.38 s = .
TestGoFZF#test_pointer = 0.15 s = .
TestGoFZF#test_preview_file = 0.18 s = .
TestGoFZF#test_marker = 0.14 s = .
TestGoFZF#test_preview_scroll_begin_and_offset = 0.23 s = .
TestGoFZF#test_select_1_exit_0_fail = 0.71 s = .
TestGoFZF#test_tiebreak_end = 0.04 s = .
TestGoFZF#test_toggle_preview_without_default_preview_command = 0.19 s = .
TestGoFZF#test_track_action = 0.23 s = .
TestGoFZF#test_labels_right = 0.14 s = .
TestGoFZF#test_info_separator_repeat = 0.20 s = .
TestGoFZF#test_tac_nosort = 0.33 s = .
TestGoFZF#test_tiebreak = 0.05 s = .
TestGoFZF#test_execute = 0.19 s = .
TestGoFZF#test_header_lines = 0.36 s = .
TestGoFZF#test_height_range_overflow = 0.21 s = .
TestGoFZF#test_accept_non_empty = 0.34 s = .
TestGoFZF#test_cancel = 0.26 s = .
TestGoFZF#test_exit_0_exit_code = 0.03 s = .
TestGoFZF#test_track = 0.23 s = .
TestGoFZF#test_header_lines_overflow = 0.28 s = .
TestGoFZF#test_info_no_separator = 0.15 s = .
TestGoFZF#test_listen = 0.15 s = E
TestGoFZF#test_tiebreak_chunk = 0.03 s = .
TestGoFZF#test_clear_selection = 0.16 s = .
TestGoFZF#test_preview_window_follow = 0.54 s = .
TestGoFZF#test_with_nth_no_ansi = 0.03 s = .
TestGoFZF#test_height_range_fit_preview_above_alternative = 0.14 s = .
TestGoFZF#test_preview_q_no_match = 0.23 s = .
TestGoFZF#test_invalid_cache = 0.25 s = .
TestGoFZF#test_toggle_alternative_preview_window = 0.16 s = .
TestGoFZF#test_escaped_meta_characters = 0.05 s = .
TestGoFZF#test_become = 0.25 s = .
TestGoFZF#test_reload_should_update_preview = 0.21 s = .
TestGoFZF#test_interrupt_execute = 0.17 s = .
TestGoFZF#test_strip_xterm_osc_sequence = 0.41 s = .
TestGoFZF#test_default_extended = 0.04 s = .
TestGoFZF#test_cycle = 0.20 s = .
TestGoFZF#test_preview_q_no_match_with_initial_query = 0.14 s = .
TestGoFZF#test_key_bindings = 0.28 s = .
TestGoFZF#test_info_separator_no_unicode = 0.14 s = .
TestGoFZF#test_long_line = 0.03 s = .
TestGoFZF#test_unicode_case = 0.03 s = .
TestGoFZF#test_accept_non_empty_with_multi_selection = 0.32 s = .
TestGoFZF#test_backward_eof = 0.37 s = .
TestGoFZF#test_jump_accept = 0.38 s = .
TestGoFZF#test_no_extra_newline_issue_3209 = 0.15 s = .
TestGoFZF#test_show_and_hide_preview = 0.23 s = .
TestGoFZF#test_header_reverse_list = 0.14 s = .
TestGoFZF#test_preview_bindings_without_default_preview = 0.20 s = .
TestGoFZF#test_labels_left = 0.15 s = .
TestGoFZF#test_margin_reverse = 0.15 s = .
TestGoFZF#test_preview_scroll_begin_expr = 0.15 s = .
TestGoFZF#test_tabstop = 1.52 s = .
TestGoFZF#test_select_1 = 0.28 s = .
TestGoFZF#test_info_inline_separator = 0.16 s = .
TestGoFZF#test_reload_sync = 1.16 s = .
TestBash#test_ctrl_t = 0.54 s = .
TestBash#test_dynamic_completion_loader = 0.55 s = .
TestBash#test_file_completion = 0.80 s = .
TestBash#test_file_completion_unicode = 0.41 s = .
TestBash#test_ctrl_r_multiline = 0.37 s = .
TestBash#test_dir_completion = 0.47 s = .
TestBash#test_ctrl_r_abort = 0.72 s = .
TestBash#test_unset_completion = 0.72 s = .
TestBash#test_alt_c_command = 0.70 s = .
TestBash#test_ctrl_t_unicode = 0.61 s = .
TestBash#test_file_completion_root = 0.25 s = .
TestBash#test_process_completion = 0.39 s = .
TestBash#test_ssh_completion = 0.42 s = .
TestBash#test_ctrl_r = 1.05 s = .
TestBash#test_alt_c = 0.44 s = .
TestBash#test_custom_completion = 0.38 s = .
TestBash#test_custom_completion_api = 0.64 s = .

Finished in 94.310801s, 2.3539 runs/s, 25.4478 assertions/s.

  1) Failure:
TestGoFZF#test_toggle_header [test/test_go.rb:1231]:
--- expected
+++ actual
@@ -1,11 +1,4 @@
-"╭───────
-│
-│   4
-│ > 3
-│   2/2
-│ >
-│   2
-│   1
-│   foo
-╰───────
+"seq 4 |
+seq 4 |
+unknown
 "


  2) Failure:
TestGoFZF#test_listen_with_api_key [test/test_go.rb:2807]:
--- expected
+++ actual
@@ -1 +1,3 @@
-"401"
+# encoding: ASCII-8BIT
+#    valid: true
+"200"


  3) Failure:
TestGoFZF#test_history [test/test_go.rb:928]:
--- expected
+++ actual
@@ -1 +1 @@
-"  100/100"
+"seq 100 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --history=/tmp/fzf-test-history --history-size=4 > /tmp/output-test_history-0.tmp; mv /tmp/output-test_history-0.tmp /tmp/output-test_history-0"


  4) Error:
TestGoFZF#test_listen:
JSON::ParserError: 859: unexpected token at 'invalid request method
'
    /usr/lib/ruby/3.1.0/json/common.rb:216:in `parse'
    /usr/lib/ruby/3.1.0/json/common.rb:216:in `parse'
    test/test_go.rb:2780:in `block in test_listen'
    test/test_go.rb:2777:in `each'
    test/test_go.rb:2777:in `test_listen'

222 runs, 2400 assertions, 3 failures, 1 errors, 0 skips

Thanks,
Chris.

[0] btw: would be nice if e.g. BUILD.md could document how to run the tests and what dependencies they have.

@calestyo
Copy link
Contributor Author

Did some more checks, i.e. ran the test suite on master (which results in at least 3 failed tests for me)... and then again on my branch, where tests seem to be flaky: sometimes I also get just the 3, sometimes more.

So maybe the test failures have nothing to do with my commits.

@calestyo calestyo force-pushed the improve-interactiveness-checks branch 2 times, most recently from 1364ace to c3826bf Compare October 2, 2023 22:40
@junegunn
Copy link
Owner

junegunn commented Oct 4, 2023

All fish tests are failing even after a retry. You might want to check if the fish version on GitHub actions is compatible with your change.

  1) Failure:
TestFish#test_alt_c_command [test/test_go.rb:3108]:
Expected: 1
  Actual: 0

  2) Failure:
TestFish#test_ctrl_r [test/test_go.rb:3131]:
Expected 0 to be > 0.

  3) Failure:
TestFish#test_ctrl_r_multiline [test/test_go.rb:3149]:
Expected: ">"
  Actual: nil

  4) Failure:
TestFish#test_ctrl_t [test/test_go.rb:3052]:
Expected: 100
  Actual: 0

  5) Failure:
TestFish#test_ctrl_t_unicode [test/test_go.rb:3066]:
Expected: 2
  Actual: 0

  6) Failure:
TestFish#test_ctrl_r_abort [test/test_go.rb:3165]:
Expected: "> foo"
  Actual: "foo"

  7) Failure:
TestFish#test_alt_c [test/test_go.rb:3092]:
Expected 0 to be > 0.

@calestyo
Copy link
Contributor Author

calestyo commented Oct 4, 2023

All fish tests are failing even after a retry. You might want to check if the fish version on GitHub actions is compatible with your change.

Uhm... I've never used github actions... running the tests locally now gives me just:

Finished in 104.848981s, 2.1173 runs/s, 28.7747 assertions/s.

  1) Failure:
TestGoFZF#test_history [test/test_go.rb:928]:
--- expected
+++ actual
@@ -1 +1 @@
-"  100/100"
+"seq 100 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --history=/tmp/fzf-test-history --history-size=4 > /tmp/output-test_history-0.tmp; mv /tmp/output-test_history-0.tmp /tmp/output-test_history-0"


  2) Failure:
TestGoFZF#test_kill_default_command_on_abort [test/test_go.rb:2253]:
Expected "FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND=/tmp/output-test_kill_default_command_on_abort-0.sh /home/calestyo/fzf/bin/fzf  > /tmp/output-test_kill_default_command_on_abort-0.tmp; mv /tmp/output-test_kill_default_command_on_abort-0.tmp /tmp/output-test_kill_default_command_on_abort-0" to include "closed".

  3) Failure:
TestGoFZF#test_kill_reload_command_on_abort [test/test_go.rb:2292]:
Expected "seq 1 3 | FZF_DEFAULT_OPTS=--no-scrollbar FZF_DEFAULT_COMMAND= /home/calestyo/fzf/bin/fzf --bind 'ctrl-r:reload(/tmp/output-test_kill_reload_command_on_abort-0.sh)' > /tmp/output-test_kill_reload_command_on_abort-0.tmp; mv /tmp/output-test_kill_reload_command_on_abort-0.tmp /tmp/output-test_kill_reload_command_on_abort-0" to include "closed".

222 runs, 3017 assertions, 3 failures, 0 errors, 0 skips

But these seem to happen also on master.

It's really weird.

This should keep the code more readable, be less error prone (accidentally doing
something outside the if-block and aligns the code with what’s already done for
zsh.

`0` is returned, because it shall not be considered an error when the script is
(accidentally) sourced from a non-interactive shell.

If executed as a script (rather than sourced), the results are not specified by
POSIX but depend on the shell, with bash giving an error in that case.

Signed-off-by: Christoph Anton Mitterer <[email protected]>
The shell execution environment shouldn’t be modified at all, when called from a
non-interactive shell.

It shall be noted that the current check may become error prone for bash, namely
in case there should ever be a differentiation between `i` and `I` in the
special variable `-` and bash’s `nocasematch`-shell-option be used.

Signed-off-by: Christoph Anton Mitterer <[email protected]>
@calestyo calestyo force-pushed the improve-interactiveness-checks branch from c3826bf to fdd22da Compare October 8, 2023 09:58
@junegunn
Copy link
Owner

junegunn commented Oct 8, 2023

But for the completion scripts its IMO overkill.

I want to keep it because I think the potential benefit outweighs the cost.

@calestyo calestyo force-pushed the improve-interactiveness-checks branch 2 times, most recently from 0d3a89d to c448711 Compare October 8, 2023 14:45
@calestyo
Copy link
Contributor Author

calestyo commented Oct 8, 2023

@junegunn Well no idea what's going on with the test system ^^

Since you've anyway rejected the idea of dropping the useless checks in the completion files I've dropped 1364ace. And since something is fishy with fish (pun intended), I've now dropped 0d3a89d.

No idea why it makes the tests fail, it works locally. Maybe the fish version on github supports only --is-interactive but that is documented to be deprecated and get dropped.

@calestyo
Copy link
Contributor Author

calestyo commented Oct 8, 2023

Anyway... please review and merge :-)

@junegunn junegunn merged commit f103aa4 into junegunn:master Oct 8, 2023
5 checks passed
@junegunn
Copy link
Owner

junegunn commented Oct 8, 2023

Since you've anyway rejected the idea of dropping the useless checks in the completion files

I don't understand why you keep saying it's useless. Not every package manager treats the file differently so that it's automatically loaded. There are many package managers that provide fzf, and how many have you tested? For example, Homebrew, the most popular plugin manager on macOS doesn't install the file in a different location. Users are expected to source the file from their shell configuration files.

You could have at least git blame the line and see why we added the check in the first place. People were having problems and we addressed them by adding the check. You're dismissing the effort based on your limited experience.

@calestyo
Copy link
Contributor Author

calestyo commented Oct 8, 2023

I don't understand why you keep saying it's useless. Not every package manager treats the file differently so that it's automatically loaded. There are many package managers that provide fzf, and how many have you tested? For example, Homebrew, the most popular plugin manager on macOS doesn't install the file in a different location. Users are expected to source the file from their shell configuration files.

Well it's what I tried to argue in the original message of this PR.

AFAICS, there are two ways people will install fzf and the shell integration:

  1. manually
  2. via some packaging system

If (1) then one can a) reasonable expect that people read the README and/or know what they're doing - and even if not, doesn’t make install anyway do the right thing? At least on my test VM I got a .fzf.bash, for which automatic loading was added to .bashrc (which is already only executed from an interactive shell), which itself already checks for interactiveness.

So we have now 3 times the interactiveness check for completion.bash.

If (2) then by all means, if the file's placed in a directory where it would be sourced for non-interactive shells: fix the package. And if it doesn't install it, well it probably kinda should (at least if there's a way for users to disable it for them).

Anyway... I don't want that to become a useless argument... it's mostly a matter of personal taste, which safeguard is still justified and which is too much. I guess you'd also say that checking for bash is overkill (the user could source all these files from dash)... it just happens that I personally feel, that it's also too much for the completion files.

Though as I've indicated in the PR, I can also live with it. :-D

@calestyo
Copy link
Contributor Author

calestyo commented Oct 8, 2023

Oh, and thanks again for merging :-)

@calestyo calestyo deleted the improve-interactiveness-checks branch October 8, 2023 22:56
@junegunn
Copy link
Owner

junegunn commented Oct 9, 2023

So we have now 3 times the interactiveness check for completion.bash.

Why three? There are two. If you're counting the one from a package manager, that's the code we don't maintain and can't control. If we are going to remove a redundant check, we will remove the one that install script injects and make the completion file self-contained, easier to bring around and use.

Anyway... I don't want that to become a useless argument... it's mostly a matter of personal taste, which safeguard is still justified and which is too much. I guess you'd also say that checking for bash is overkill (the user could source all these files from dash)... it just happens that I personally feel, that it's also too much for the completion files.

You're making up an imaginary scenario and comparing it with a real problem people had. Please git blame the lines before making suggestions.

fix the package

Easier said than done.

@calestyo
Copy link
Contributor Author

calestyo commented Oct 9, 2023

Why three?

I was referring to the loading when fzf was installed via make install:

  1. bash loads .bashrc only when interactive (and many standard .bashrc have even their own check for it, counting that it would be 4)
  2. (1) sources ~/.fzf.bash, has a check
  3. completion.bash another one

You're making up an imaginary scenario and comparing it with a real problem people had. Please git blame the lines before making suggestions.

I believe you that people had problems. :-) It's like every now and then someone posts at the cryptsetup mailing list that he's lost his password has no backups and what he can do to get his data back (nothing). I mean you cannot protect people from everything.

Anyway... makes no sense to discuss this further, so lets focus on the other open PRs or new features (actually I'm thinking of a few) 😍

junegunn added a commit that referenced this pull request Oct 9, 2023
@junegunn
Copy link
Owner

junegunn commented Oct 9, 2023

I mean you cannot protect people from everything.

No, we can't.

what he can do to get his data back (nothing)

But in this case, we can help them with a small safety device with virtually zero overhead, so why not?

@calestyo
Copy link
Contributor Author

calestyo commented Oct 9, 2023

But in this case, we can help them with a small safety device with virtually zero overhead, so why not?

As said... it's really just a matter of taste, and not that big issue.

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.

shell script interactiveness checks
2 participants