andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.58k stars 179 forks source link

shtab does not generating working completions #264

Closed jmcantrell closed 1 year ago

jmcantrell commented 1 year ago

Describe the bug When trying to complete file paths for trash to operate on, nothing is completed. In zsh, the description of the thing that is trying to complete is "trash commands". In bash, nothing is completed, and no messages are displayed. Options seem to work in both bash and zsh.

trash-cli version Output of: trash-put --version 0.22.10.20

Are you using the latest version of trash-cli? Yes

Have you tried if the bug is present in the latest version of trash-cli? Yes (arch's system version and git version in a python venv)

Operating system:

To Reproduce Copy and paste the commands (and their output) to execute in order to reproduce the behavior:

  1. trash-put <tab>

Expected behavior The completion for the shell should include paths visible to the user.

andreafrancia commented 1 year ago

Please the following command:

pip install 'trash-cli[completion]'  && eval $(trash-put --print-completion zsh)
abdoulayeYATERA commented 1 year ago

Same issue here:

OS : arch shell: zsh trash-cli: 0.22.10.20

jmcantrell commented 1 year ago

@andreafrancia

_arguments:comparguments:327: can only be called from completion function

Which makes sense considering it's not being run in a completion context.

Should it even be trying to complete sub-commands, given there aren't any?

_shtab_trash_put_commands() {
  local _commands=(

  )
  _describe 'trash-put commands' _commands
}

The following indicates that the completion system will expect the next argument after any options to be a sub-command for trash-put, but the completion function above does not define any (nor does trash-put actually handle any sub-commands). The ->trash-put action does not appear to be used for anything either:

  _arguments -C $_shtab_trash_put_options \
    ': :_shtab_trash_put_commands' \  # <-- here
    '*::: :->trash-put'

I would expect it to look something like the following (which works for me). I'm not sure why shtab is not generating something similar:

  _arguments -C $_shtab_trash_put_options \
    '*:: :_files'
bound-variable commented 1 year ago

Completions were working for me until I updated my system yesterday.

alpheratz0 commented 1 year ago

I'm using zsh and trash-put completions are broken

trash-put version 0.22.10.20

Marcool04 commented 1 year ago

Same here:

$ uname -s -r -m -o
Linux 5.15.78-1-rpi-ARCH armv7l GNU/Linux

$ pacman -Qi trash-cli
Name            : trash-cli
Version         : 0.22.10.20-3

$ pacman -Qi bash
Name            : bash
Version         : 5.1.016-1

$ pacman -Qi bash-completion 
Name            : bash-completion
Version         : 2.11-3

This might provide some more insight:

$ set -x                                                                                                                                                          
$ trash [TAB]+ local completing_word=                                                                                                                                  
+ COMPREPLY=()                                                                                                                                                                               
+ prefix=_shtab_trash                                                                                                                                                                        
+ word_index=0                                                                                                                                                                               
+ _set_parser_defaults                                                                                                                                                                       
+ local 'subparsers_var=_shtab_trash_subparsers[@]'                                                                                                                                          
+ sub_parsers=                                                                                                                                                                               
+ local 'current_option_strings_var=_shtab_trash_option_strings[@]'                                                                                                                          
+ current_option_strings='-h --help --print-completion -d --directory -f --force -i --interactive -r -R --recursive --trash-dir -v --verbose --version'                                      
+ completed_positional_actions=0                                                                                                                                                             
+ _set_new_action pos_0 true                                                                                                                                                                 
++ _shtab_replace_nonword pos_0                                                                                                                                                              
++ echo pos_0                                                                                                                                                                                
+ current_action=_shtab_trash_pos_0                                                                                                                                                          
+ local current_action_compgen_var=_shtab_trash_pos_0_COMPGEN                                                                                                                                
+ current_action_compgen=                                                                                                                                                                    
+ local 'current_action_choices_var=_shtab_trash_pos_0_choices[@]'                                                                                                                           
+ current_action_choices=                                                                                                                                                                    
+ local current_action_nargs_var=_shtab_trash_pos_0_nargs                                                                                                                                    
+ '[' -n '*' ']'                                                                                                                                                                             
+ current_action_nargs='*'                                                                                                                                                                   
+ current_action_args_start_index=1                                                                                                                                                          
+ current_action_is_positional=true                                                                                                                                                          
+ word_index=1                                                                                                                                                                               
+ '[' 1 -ne 1 ']'                                                                                                                                                                            
+ [[ '' == -* ]]                                                                                                                                                                             
+ local 'IFS=                                                                                                                                                                                
'                                                                                                                                                                                            
+ COMPREPLY=($([ -n "${current_action_compgen}" ]                   && "${current_action_compgen}" "${completing_word}"))                                                                    
++ '[' -n '' ']'                                                                                                                                                                             
+ unset IFS                                                                                                                                                                                  
+ COMPREPLY+=($(compgen -W "${current_action_choices[*]}" -- "${completing_word}"))
++ compgen -W '' -- ''
+ return 0
$ set +x
eriteric commented 1 year ago

same here after system update. tried reinstalling completions, not working.

bound-variable commented 1 year ago

It's been fixed. Install via pip install git+https://github.com/andreafrancia/trash-cli or wait for next version.

jmcantrell commented 1 year ago

@Pound-Hash I get the same completion code using the git version as of today.

protist commented 1 year ago

@Pound-Hash and @jmcantrell The latest version fixes this for me. For Arch users you can test the new -git AUR package.

jmcantrell commented 1 year ago

It's sort of working now, but I can only complete a single file. After the first file, it will only complete options, and if I try to complete a file by starting to type the first few characters, it says "no more arguments". And this only works for zsh. I get no file completion for bash.

andreafrancia commented 1 year ago

I summon @Freed-Wu the expert of shtab, maybe he knows something more.

protist commented 1 year ago

@jmcantrell Ah, I didn't test fully. I can confirm I see the same as you with zsh.

Freed-Wu commented 1 year ago

For arch user: Please install the latest version of shtab. Then regenerate shell completion scripts.

$ pacman -Qi python-shtab | rg Version
2:Version         : 1.5.8-1
$ trash-put --print-completion zsh | sudo tee /usr/share/zsh/site-functions/_trash-put
$ trash-put --print-completion bash | sudo tee /usr/share/bash-completion/completions/trash-put

This bug is because the trash-cli's packager use the old shtab to generate shell completion scripts. Just install the latest, then regenerate shell completion scripts.

Freed-Wu commented 1 year ago

After the first file, it will only complete options

It still be some bug of shtab. I'll take a look.

Freed-Wu commented 1 year ago

Try this:

diff --git a/_trash-put b/_trash-put
index 74de767..a9d8518 100644
--- a/_trash-put
+++ b/_trash-put
@@ -20,7 +20,7 @@ _shtab_trash_put_options=(
   "--trash-dir[use TRASHDIR as trash folder]:trashdir:(${$(trash-list --trash-dirs)#parent_*:})"
   "*"{-v,--verbose}"[explain what is being done]"
   "(- : *)--version[show program\'s version number and exit]"
-  "(*)::files:_trash_files"
-  "(*)*::files:_trash_files"
 )

Because

    parser.add_argument('files',
                        nargs='*'
                        ).complete = TRASH_FILES

shtab handle nargs='*' as (*)::. It stops trigger _trash_files again after trigger _trash_files once. (*)*:: can work.

protist commented 1 year ago

@Freed-Wu I tested using the AUR package mentioned above. This already builds using the latest python-shtab, i.e. 1.5.8-1. Hence, trash-put --print-completion zsh is already the same as /usr/share/zsh/site-functions/_trash-put.

I also tested your patch, and that works perfectly! I can now use file completion on a second (and subsequent) filename.

Freed-Wu commented 1 year ago

It is just a dirty patch. Now we have two method to solve this problem:

Change https://github.com/iterative/shtab/blob/main/shtab/__init__.py#L497's ONE_OR_MORE to (*)* from (*).

Or Change https://github.com/andreafrancia/trash-cli/blob/master/trashcli/put/parser.py#L108 to

    parser.add_argument('files',
                        nargs='...'
                        ).complete = TRASH_FILES

... is REMAINER, will generate (-)* which can work. original * is ONE_OR_MORE, will generate (*) which stop striggering any non-prefix-with-minus's argument (include itself) again, That is why after you press trash-put an_argument_don't_start_with_minus <TAB> will trigger -option-start-with-minus.

protist commented 1 year ago

@Freed-Wu FWIW I tested the latter patch and that works for me (again I only tested in zsh).

Freed-Wu commented 1 year ago

Thanks for your test :+1:

andreafrancia commented 1 year ago

@Freed-Wu thank for your intervention. Should I change the parser.py as you explained?i If you want to send a pull request it would be very welcome?

protist commented 1 year ago

Thanks for the quick fix, but the tests now fail as per below. Reverting this commit allows the tests to pass again.

================================================================ FAILURES =================================================================
______________________________________________ TestPutScripts.test_trashes_connected_symlink ______________________________________________

self = <tests.test_put.test_trash_put_script.TestPutScripts testMethod=test_trashes_connected_symlink>

    def test_trashes_connected_symlink(self):
        self.make_connected_link(self.tmp_dir / 'link')

        result = run_command(self.tmp_dir, 'trash-put', [
            'link',
            '--trash-dir', self.tmp_dir / 'trash-dir',
        ])

        assert (result.stdout, result.stderr == "", "")
        assert not os.path.lexists(self.tmp_dir / 'link')
>       assert os.path.lexists(self.tmp_dir / 'trash-dir' / 'files' / 'link')
E       AssertionError: assert False
E        +  where False = <function lexists at 0x7fa83f0929e0>(((('/tmp/tmpe3hn4anw_trash_cli_test' / 'trash-dir') / 'files') / 'link'))
E        +    where <function lexists at 0x7fa83f0929e0> = <module 'posixpath' from '/usr/lib/python3.10/posixpath.py'>.lexists
E        +      where <module 'posixpath' from '/usr/lib/python3.10/posixpath.py'> = os.path
E        +    and   '/tmp/tmpe3hn4anw_trash_cli_test' = <tests.test_put.test_trash_put_script.TestPutScripts testMethod=test_trashes_connected_symlink>.tmp_dir

tests/test_put/test_trash_put_script.py:48: AssertionError
______________________________________________ TestPutScripts.test_trashes_dangling_symlink _______________________________________________

self = <tests.test_put.test_trash_put_script.TestPutScripts testMethod=test_trashes_dangling_symlink>

    def test_trashes_dangling_symlink(self):
        self.make_dangling_link(self.tmp_dir / 'link')

        result = run_command(self.tmp_dir, 'trash-put', [
            'link',
            '--trash-dir', self.tmp_dir / 'trash-dir',
        ])

        assert (result.stdout, result.stderr == "", "")
        assert not os.path.lexists(self.tmp_dir / 'link')
>       assert os.path.lexists(self.tmp_dir / 'trash-dir' / 'files' / 'link')
E       AssertionError: assert False
E        +  where False = <function lexists at 0x7fa83f0929e0>(((('/tmp/tmpl5mshxnm_trash_cli_test' / 'trash-dir') / 'files') / 'link'))
E        +    where <function lexists at 0x7fa83f0929e0> = <module 'posixpath' from '/usr/lib/python3.10/posixpath.py'>.lexists
E        +      where <module 'posixpath' from '/usr/lib/python3.10/posixpath.py'> = os.path
E        +    and   '/tmp/tmpl5mshxnm_trash_cli_test' = <tests.test_put.test_trash_put_script.TestPutScripts testMethod=test_trashes_dangling_symlink>.tmp_dir

tests/test_put/test_trash_put_script.py:36: AssertionError
============================================================ warnings summary =============================================================
tests/test_put/test_trash_put_script.py:46
  /tmp/trash-cli-git/src/trash-cli/tests/test_put/test_trash_put_script.py:46: PytestAssertRewriteWarning: assertion is always true, perhaps remove parentheses?
    assert (result.stdout, result.stderr == "", "")

tests/test_put/test_trash_put_script.py:34
  /tmp/trash-cli-git/src/trash-cli/tests/test_put/test_trash_put_script.py:34: PytestAssertRewriteWarning: assertion is always true, perhaps remove parentheses?
    assert (result.stdout, result.stderr == "", "")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================= short test summary info =========================================================
FAILED tests/test_put/test_trash_put_script.py::TestPutScripts::test_trashes_connected_symlink - AssertionError: assert False
FAILED tests/test_put/test_trash_put_script.py::TestPutScripts::test_trashes_dangling_symlink - AssertionError: assert False
================================================ 2 failed, 388 passed, 2 warnings in 3.26s ================================================
Marcool04 commented 1 year ago

and even forcing installation, on arch, results in a non functional tab completion with bash at any rate...

andreafrancia commented 1 year ago

Thanks for the quick fix, but the tests now fail as per below. Reverting this commit allows the tests to pass again.

I think the failure is related to another commit I've done today. It also failed on GitHub Actions here. I've changed something, now it works on my machine and on GitHub Actions. I'm not sure why it didn't worked before.

Please try again now let me know.

andreafrancia commented 1 year ago

Many thanks to @Freed-Wu who fixed the Zsh issue.

I'm reopening this ticket because the the completion in bash does not work yet. I don't know if @Freed-Wu can help us to fix also the bash issue.

Marcool04 commented 1 year ago

Sure enough, the new commit passes the test, but we still have:

$ set -x 
$ trash-put [TAB]+ local completing_word=
+ COMPREPLY=()
+ prefix=_shtab_trash_put
+ word_index=0
+ _set_parser_defaults
+ local 'subparsers_var=_shtab_trash_put_subparsers[@]'
+ sub_parsers=
+ local 'current_option_strings_var=_shtab_trash_put_option_strings[@]'
+ current_option_strings='-h --help --print-completion -d --directory -f --force -i --interactive -r -R --recursive --trash-dir -v --verbose --version'
+ completed_positional_actions=0
+ _set_new_action pos_0 true
++ _shtab_replace_nonword pos_0
++ echo pos_0
+ current_action=_shtab_trash_put_pos_0
+ local current_action_compgen_var=_shtab_trash_put_pos_0_COMPGEN
+ current_action_compgen=
+ local 'current_action_choices_var=_shtab_trash_put_pos_0_choices[@]'
+ current_action_choices=
+ local current_action_nargs_var=_shtab_trash_put_pos_0_nargs
+ '[' -n ... ']'
+ current_action_nargs=...
+ current_action_args_start_index=1
+ current_action_is_positional=true
+ word_index=1
+ '[' 1 -ne 1 ']'
+ [[ '' == -* ]]
+ local 'IFS=
'
+ COMPREPLY=($([ -n "${current_action_compgen}" ]                   && "${current_action_compgen}" "${completing_word}"))
++ '[' -n '' ']'
+ unset IFS
+ COMPREPLY+=($(compgen -W "${current_action_choices[*]}" -- "${completing_word}"))
++ compgen -W '' -- ''
+ return 0
Freed-Wu commented 1 year ago

Can you test #270?

Marcool04 commented 1 year ago

Edit: this does indeed fix tab completion for bash. Thanks a lot to @Freed-Wu and @andreafrancia for fast merge! 👍

~Sorry @andreafrancia but as far as I can tell https://github.com/andreafrancia/trash-cli/commit/8cdb571504a8c5f0bafc4f1c9463ac7f0233ccba does not complete fixing this for bash, see above comment.~

protist commented 1 year ago

Thanks @Freed-Wu and @andreafrancia! All good now with the tests and for zsh completion.

jmcantrell commented 1 year ago

I'm unable to install the aur version of trash-cli-git due to check() errors.

Reading repository package databases...
Reading local package database...
Resolving AUR dependencies...

:: AUR package will be installed:
 trash-cli-git                                              -> 1:0.22.10.20.r52.g0b476b1-1

:: Proceed with installation? [Y/n] 
:: [v]iew package details   [m]anually select packages
>> 
looking for conflicting AUR packages...
:: warning: Not showing diff for trash-cli-git package (installing for the first time)
:: Skipping review of PKGBUILD for trash-cli-git package (--noedit)

:: Downloading the latest sources for a devel package trash-cli-git...

:: Starting the build:
==> Making package: trash-cli-git 1:0.22.10.20.r63.g8cdb571-1 (Thu 24 Nov 2022 09:10:21 PM CST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating trash-cli git repo...
warning: redirecting to https://github.com/andreafrancia/trash-cli.git/
==> Validating source files with sha256sums...
    trash-cli ... Skipped
==> Extracting sources...
  -> Creating working copy of trash-cli git repo...
Reset branch 'makepkg'
==> Starting prepare()...
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
running build
running build_py
running build_scripts
copying and adjusting trash -> build/scripts-3.10
copying and adjusting trash-put -> build/scripts-3.10
copying and adjusting trash-list -> build/scripts-3.10
copying and adjusting trash-restore -> build/scripts-3.10
copying and adjusting trash-empty -> build/scripts-3.10
copying and adjusting trash-rm -> build/scripts-3.10
==> Starting check()...
========================================================= test session starts ==========================================================
platform linux -- Python 3.10.8, pytest-7.2.0, pluggy-1.0.0
rootdir: /home/jeremy/.cache/pikaur/build/trash-cli-git/src/trash-cli
plugins: cov-3.0.0, typeguard-2.13.3
collected 390 items                                                                                                                    

tests/test_bump.py ...                                                                                                           [  0%]
tests/test_candidate_shrink_user.py ......                                                                                       [  2%]
tests/test_fake_file_system.py ......                                                                                            [  3%]
tests/test_fake_fstab.py ...                                                                                                     [  4%]
tests/test_fake_ismount.py .......                                                                                               [  6%]
tests/test_file_remover.py .                                                                                                     [  6%]
tests/test_files.py ...                                                                                                          [  7%]
tests/test_filesystem.py ......                                                                                                  [  8%]
tests/test_generate_scripts.py .                                                                                                 [  9%]
tests/test_joining_paths.py .                                                                                                    [  9%]
tests/test_list_all_trashinfo_contents.py ..                                                                                     [ 10%]
tests/test_list_slow.py ..                                                                                                       [ 10%]
tests/test_make_script.py .....                                                                                                  [ 11%]
tests/test_mock_dir_reader.py ....                                                                                               [ 12%]
tests/test_my_mock.py ..                                                                                                         [ 13%]
tests/test_parsing_trashinfo_contents.py ............                                                                            [ 16%]
tests/test_partitions.py ...                                                                                                     [ 17%]
tests/test_top_trash_dir_rules.py ....                                                                                           [ 18%]
tests/test_trash_dir_reader.py ..                                                                                                [ 18%]
tests/test_trash_list.py ................                                                                                        [ 22%]
tests/test_trash_put_reporter.py .                                                                                               [ 23%]
tests/test_trash_rm.py .......                                                                                                   [ 24%]
tests/test_trash_rm_slow.py ....                                                                                                 [ 25%]
tests/test_volume_of.py ...                                                                                                      [ 26%]
tests/test_empty/test_clock.py ...                                                                                               [ 27%]
tests/test_empty/test_empty_end_to_end.py ......                                                                                 [ 28%]
tests/test_empty/test_empty_end_to_end_interactive.py .                                                                          [ 29%]
tests/test_empty/test_empty_end_to_end_with_argument.py ....                                                                     [ 30%]
tests/test_empty/test_empty_end_to_end_with_trash_dir.py .....                                                                   [ 31%]
tests/test_empty/test_existing_file_remover.py .                                                                                 [ 31%]
tests/test_empty/test_guard.py ...                                                                                               [ 32%]
tests/test_empty/test_make_parser.py ......                                                                                      [ 34%]
tests/test_empty/test_parse_reply.py .....                                                                                       [ 35%]
tests/test_empty/test_prepare_output_message.py ...                                                                              [ 36%]
tests/test_empty/test_user.py .                                                                                                  [ 36%]
tests/test_empty/empty_cmd/test_empty_cmd.py ..                                                                                  [ 36%]
tests/test_empty/empty_cmd/test_empty_cmd_fs.py .                                                                                [ 37%]
tests/test_empty/empty_cmd/test_empty_cmd_with_multiple_volumes_fs.py ...                                                        [ 37%]
tests/test_fs/test_move.py ..                                                                                                    [ 38%]
tests/test_fstab/test_volumes_listing.py .....                                                                                   [ 39%]
tests/test_list/test_deletion_date_extractor.py ..                                                                               [ 40%]
tests/test_list/test_end_to_end_list.py ....                                                                                     [ 41%]
tests/test_list/test_file_size.py .                                                                                              [ 41%]
tests/test_list/test_trash_dirs_selector.py ...                                                                                  [ 42%]
tests/test_list/test_trash_list_parser.py ........                                                                               [ 44%]
tests/test_put/test_atomic_write.py ....                                                                                         [ 45%]
tests/test_put/test_create_trashinfo_basename.py ...                                                                             [ 46%]
tests/test_put/test_describer.py .......                                                                                         [ 47%]
tests/test_put/test_describer_integration.py .......                                                                             [ 49%]
tests/test_put/test_end_to_end_put.py ........                                                                                   [ 51%]
tests/test_put/test_ensure_dir.py ...                                                                                            [ 52%]
tests/test_put/test_fake_fs.py ...................................                                                               [ 61%]
tests/test_put/test_gate.py .                                                                                                    [ 61%]
tests/test_put/test_gentle_stat_read.py ..                                                                                       [ 62%]
tests/test_put/test_make_parser.py ...........                                                                                   [ 65%]
tests/test_put/test_original_location.py ............                                                                            [ 68%]
tests/test_put/test_parent_path.py ....                                                                                          [ 69%]
tests/test_put/test_persist_trash_info.py ..                                                                                     [ 69%]
tests/test_put/test_put.py .........                                                                                             [ 72%]
tests/test_put/test_suffix.py ...                                                                                                [ 72%]
tests/test_put/test_trash_dir_volume.py .                                                                                        [ 73%]
tests/test_put/test_trash_directories_finder.py ..                                                                               [ 73%]
tests/test_put/test_trash_put_script.py ..FF                                                                                     [ 74%]
tests/test_put/test_trash_put_slow.py .............                                                                              [ 77%]
tests/test_put/test_trasher.py ....                                                                                              [ 78%]
tests/test_put/test_trashing_checker.py ...                                                                                      [ 79%]
tests/test_put/test_user.py ......                                                                                               [ 81%]
tests/test_put/test_volume_of_parent.py .                                                                                        [ 81%]
tests/test_put/real_fs/test_fake_fs_list_dir.py .                                                                                [ 81%]
tests/test_put/real_fs/test_real_fs_is_accessible.py ....                                                                        [ 82%]
tests/test_put/real_fs/test_real_fs_list_dir.py .                                                                                [ 83%]
tests/test_put/real_fs/test_real_fs_permissions.py ..                                                                            [ 83%]
tests/test_put/real_fs/test_size_counter_on_fake_fs.py ...                                                                       [ 84%]
tests/test_put/real_fs/test_size_counter_on_real_fs.py ...                                                                       [ 85%]
tests/test_restore/test_all_trash_directories.py .                                                                               [ 85%]
tests/test_restore/test_end_to_end_restore.py ....                                                                               [ 86%]
tests/test_restore/test_is_trashed_from_path.py ....                                                                             [ 87%]
tests/test_restore/test_parse_indexes.py ..........                                                                              [ 90%]
tests/test_restore/test_restore_asking_the_user.py ..                                                                            [ 90%]
tests/test_restore/test_restore_trash.py .......                                                                                 [ 92%]
tests/test_restore/test_trash_directories2.py ..                                                                                 [ 92%]
tests/test_restore/test_trash_directory.py ...                                                                                   [ 93%]
tests/test_restore/restore_cmd/test_listing_in_restore_cmd.py ...                                                                [ 94%]
tests/test_restore/restore_cmd/test_restore_arg_parser.py ....                                                                   [ 95%]
tests/test_restore/restore_cmd/test_trash_restore_cmd.py .....                                                                   [ 96%]
tests/test_restore/restore_cmd/test_trashed_file_restore_integration.py ..                                                       [ 97%]
tests/test_restore/restore_cmd/test_trashed_files.py .                                                                           [ 97%]
tests/test_restore/restore_cmd/test_trashed_files_integration.py .                                                               [ 97%]
tests/test_rm/test_rm_script.py ..                                                                                               [ 98%]
tests/trash_dir_scanner/test_top_trash_dir_rules.py ....                                                                         [ 99%]
tests/trash_dir_scanner/test_trash_dir_scanner.py .                                                                              [ 99%]
tests/trash_dir_scanner/test_user_info_provider.py ..                                                                            [100%]

=============================================================== FAILURES ===============================================================
____________________________________________ TestPutScripts.test_trashes_connected_symlink _____________________________________________

self = <tests.test_put.test_trash_put_script.TestPutScripts testMethod=test_trashes_connected_symlink>

    def test_trashes_connected_symlink(self):
        self.make_connected_link(self.tmp_dir / 'link')

        result = run_command(self.tmp_dir, 'trash-put', [
            '-v',
            '--trash-dir', self.tmp_dir / 'trash-dir',
            'link',
        ])

>       self.assertEqual([
            "trash-put: 'link' trashed in %s" % (self.tmp_dir / 'trash-dir'),
        ], self.read_trashed_in_message(result), result.stderr)
E       AssertionError: Lists differ: ["tra[21 chars]d in /home/jeremy/.local/tmp/tmp9pjzgmfx_trash[16 chars]dir"] != ["tra[21 chars]d in ~/.local/tmp/tmp9pjzgmfx_trash_cli_test/trash-dir"]
E       
E       First differing element 0:
E       "tras[20 chars]d in /home/jeremy/.local/tmp/tmp9pjzgmfx_trash[15 chars]-dir"
E       "tras[20 chars]d in ~/.local/tmp/tmp9pjzgmfx_trash_cli_test/trash-dir"
E       
E         ["trash-put: 'link' trashed in "
E       -  '/home/jeremy/.local/tmp/tmp9pjzgmfx_trash_cli_test/trash-dir']
E       ?   ^^^^^^^^^^^^
E       
E       +  '~/.local/tmp/tmp9pjzgmfx_trash_cli_test/trash-dir']
E       ?   ^
E        : trash-put: volume of file: /home
E       trash-put: trying trash dir: /home/jeremy/.local/tmp/tmp9pjzgmfx_trash_cli_test/trash-dir from volume: /home
E       trash-put: 'link' trashed in ~/.local/tmp/tmp9pjzgmfx_trash_cli_test/trash-dir

tests/test_put/test_trash_put_script.py:50: AssertionError
_____________________________________________ TestPutScripts.test_trashes_dangling_symlink _____________________________________________

self = <tests.test_put.test_trash_put_script.TestPutScripts testMethod=test_trashes_dangling_symlink>

    def test_trashes_dangling_symlink(self):
        self.make_dangling_link(self.tmp_dir / 'link')

        result = run_command(self.tmp_dir, 'trash-put', [
            '-v',
            '--trash-dir', self.tmp_dir / 'trash-dir',
            'link',
        ])

>       self.assertEqual([
            "trash-put: 'link' trashed in %s" % (self.tmp_dir / 'trash-dir'),
        ], self.read_trashed_in_message(result), result.stderr)
E       AssertionError: Lists differ: ["tra[21 chars]d in /home/jeremy/.local/tmp/tmpybe4xxrz_trash[16 chars]dir"] != ["tra[21 chars]d in ~/.local/tmp/tmpybe4xxrz_trash_cli_test/trash-dir"]
E       
E       First differing element 0:
E       "tras[20 chars]d in /home/jeremy/.local/tmp/tmpybe4xxrz_trash[15 chars]-dir"
E       "tras[20 chars]d in ~/.local/tmp/tmpybe4xxrz_trash_cli_test/trash-dir"
E       
E         ["trash-put: 'link' trashed in "
E       -  '/home/jeremy/.local/tmp/tmpybe4xxrz_trash_cli_test/trash-dir']
E       ?   ^^^^^^^^^^^^
E       
E       +  '~/.local/tmp/tmpybe4xxrz_trash_cli_test/trash-dir']
E       ?   ^
E        : trash-put: volume of file: /home
E       trash-put: trying trash dir: /home/jeremy/.local/tmp/tmpybe4xxrz_trash_cli_test/trash-dir from volume: /home
E       trash-put: 'link' trashed in ~/.local/tmp/tmpybe4xxrz_trash_cli_test/trash-dir

tests/test_put/test_trash_put_script.py:35: AssertionError
======================================================= short test summary info ========================================================
FAILED tests/test_put/test_trash_put_script.py::TestPutScripts::test_trashes_connected_symlink - AssertionError: Lists differ: ["tra[21 chars]d in /home/jeremy/.local/tmp/tmp9pjzgmfx_trash[16 chars]dir"] != ["tra[21 chars]d in ~...
FAILED tests/test_put/test_trash_put_script.py::TestPutScripts::test_trashes_dangling_symlink - AssertionError: Lists differ: ["tra[21 chars]d in /home/jeremy/.local/tmp/tmpybe4xxrz_trash[16 chars]dir"] != ["tra[21 chars]d in ~...
==================================================== 2 failed, 388 passed in 5.53s =====================================================
==> ERROR: A failure occurred in check().
    Aborting...

Command 'makepkg --force' failed to execute.
protist commented 1 year ago

@jmcantrell are you using a AUR helper? Are you installing in a clean (updated) directory? makepkg works fine for me, and builds the latest version 1:0.22.10.20.r63.g8cdb571-1

jmcantrell commented 1 year ago

@protist I am using pikaur, but I just built it with makepkg and got the same output. The version from aur appears to be 1:0.22.10.20.r52.g0b476b1-1 though. Are you getting your PKGBUILD from elsewhere?

protist commented 1 year ago

@jmcantrell No, just from AUR. IDK why it's an earlier version though. Just to make sure we're using exactly the same PKGBUILD version, can you try:

$ curl 'https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=trash-cli-git' > PKGBUILD
$ makepkg -s
jmcantrell commented 1 year ago

@protist I also get the same output when running pytest in the source repo.

jmcantrell commented 1 year ago

@protist Same version and same output when curling the PKGBUILD.

Correction: I see the version you do now, but I'm getting the same test output.

protist commented 1 year ago

@jmcantrell Glad you are getting the correct version, but I can't comment on the test output unfortunately.

jmcantrell commented 1 year ago

I'll open an issue for the test failures.