diff options
Diffstat (limited to 'app-misc')
6 files changed, 348 insertions, 0 deletions
diff --git a/app-misc/trash-cli/Manifest b/app-misc/trash-cli/Manifest index 8fe593248b55..1206c4667649 100644 --- a/app-misc/trash-cli/Manifest +++ b/app-misc/trash-cli/Manifest @@ -1,2 +1,3 @@ DIST trash-cli-0.20.12.26.tar.gz 74542 BLAKE2B 558e3cc043cdaef44bf68317e666c6f757daf9feeb6b731a57aba91ec983e1adb1e404f7e8428a7bd1225d83df6e94e8b9b793942bbb233f09a44127af0a42fa SHA512 d0b0a97014c888ddda95759dc82837385a2809cae04bdf6a84dcf0233dc2cf9370253110bc5fdbc5c4452ebb65c5e7836fe1cfaa9aaabe38d34269724456cd1c +DIST trash-cli-0.21.10.24.tar.gz 78085 BLAKE2B 6d8f82695a94e45efd4316eb9f1a8c8f5d348774fc10cd4e5323d8dad15897f827acf343e2c1a15e1cef4eecb2ed76ab456345e359319c82bfde9b95f68f7b77 SHA512 1bf258cea7658a3968beec939d09ae088eac8898a9812e8a3aca587df7f2ad20c66f766995f8c893e4d84d0ea7db94ebb4ca7eb24982af81fa4179cc9e239fd1 DIST trash-cli-0.21.5.25.tar.gz 77067 BLAKE2B 5db46b21ba33b9076ea7f024b93e62f30b3671f44a024b30013369607bd580f0ef9831debd9fdc6c64575ab6edde14aa921229bbd16a6a77657b7ed20b58c318 SHA512 75ef338b356048768febc4afd42933d8aa44cde5156e386968dad7b33033b84becaef3d39ccf15c02216394735f37d1c7c8cd499000068d51247710e87590507 diff --git a/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-lint-in-tests.patch b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-lint-in-tests.patch new file mode 100644 index 000000000000..8f7cfe3babf1 --- /dev/null +++ b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-lint-in-tests.patch @@ -0,0 +1,99 @@ +From e467ae01869e853f83ebad4ef5514c5831283866 Mon Sep 17 00:00:00 2001 +From: Zoltan Puskas <zoltan@sinustrom.info> +Date: Sat, 4 Dec 2021 13:16:48 -0800 +Subject: [PATCH 1/2] Fix lint in tests + +Running pyflakes on the code has shown several lint errors. This diff +fixes them for the unit test files. + +Additionally myStringIO.py has been removed in favour of using six's +StringIO for consistency with other tests. +--- + tests/empty/test_empty_end_to_end_interactive.py | 2 +- + tests/myStringIO.py | 4 ---- + tests/put/test_file_trasher.py | 2 +- + tests/put/test_home_fallback.py | 2 +- + tests/test_restore_cmd.py | 2 +- + tests/test_trash_rm.py | 4 +--- + 6 files changed, 5 insertions(+), 11 deletions(-) + delete mode 100644 tests/myStringIO.py + +diff --git a/tests/empty/test_empty_end_to_end_interactive.py b/tests/empty/test_empty_end_to_end_interactive.py +index 80b8f81..64f20d6 100644 +--- a/tests/empty/test_empty_end_to_end_interactive.py ++++ b/tests/empty/test_empty_end_to_end_interactive.py +@@ -4,7 +4,7 @@ import unittest + import pytest + + from ..fake_trash_dir import FakeTrashDir +-from ..support import MyPath, list_trash_dir ++from ..support import MyPath + from .. import run_command + + +diff --git a/tests/myStringIO.py b/tests/myStringIO.py +deleted file mode 100644 +index 40a6c72..0000000 +--- a/tests/myStringIO.py ++++ /dev/null +@@ -1,4 +0,0 @@ +-try: +- from StringIO import StringIO +-except ImportError: +- from io import StringIO +diff --git a/tests/put/test_file_trasher.py b/tests/put/test_file_trasher.py +index 32e8019..37fb9db 100644 +--- a/tests/put/test_file_trasher.py ++++ b/tests/put/test_file_trasher.py +@@ -3,7 +3,7 @@ import unittest + from mock import Mock + from datetime import datetime + +-from trashcli.put import TrashResult, Trasher, FileTrasher ++from trashcli.put import TrashResult, FileTrasher + import os + + +diff --git a/tests/put/test_home_fallback.py b/tests/put/test_home_fallback.py +index 07d40a2..38b7fb4 100644 +--- a/tests/put/test_home_fallback.py ++++ b/tests/put/test_home_fallback.py +@@ -3,7 +3,7 @@ import unittest + from mock import Mock, call, ANY + + from trashcli.fstab import create_fake_volume_of +-from trashcli.put import TrashResult, Trasher, TrashDirectoriesFinder, FileTrasher ++from trashcli.put import TrashResult, TrashDirectoriesFinder, FileTrasher + from datetime import datetime + import os + +diff --git a/tests/test_restore_cmd.py b/tests/test_restore_cmd.py +index b1cda13..63c017d 100644 +--- a/tests/test_restore_cmd.py ++++ b/tests/test_restore_cmd.py +@@ -3,7 +3,7 @@ import unittest + from trashcli.list_mount_points import os_mount_points + from trashcli.restore import RestoreCmd, make_trash_directories, \ + TrashDirectory, TrashedFiles, Command +-from .myStringIO import StringIO ++from six import StringIO + from mock import call + from trashcli import restore + import datetime +diff --git a/tests/test_trash_rm.py b/tests/test_trash_rm.py +index e11935e..ec7e7e6 100644 +--- a/tests/test_trash_rm.py ++++ b/tests/test_trash_rm.py +@@ -1,8 +1,6 @@ + import unittest + +-import six +- +-from mock import Mock, call ++from mock import Mock + + from trashcli.rm import Filter + from six import StringIO +-- +2.33.1 + diff --git a/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-lint-in-trash-cli.patch b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-lint-in-trash-cli.patch new file mode 100644 index 000000000000..b69e6deb84c1 --- /dev/null +++ b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-lint-in-trash-cli.patch @@ -0,0 +1,26 @@ +From 00d10cff555c79a0ac11f7a298a892176830c353 Mon Sep 17 00:00:00 2001 +From: Zoltan Puskas <zoltan@sinustrom.info> +Date: Sat, 4 Dec 2021 13:27:23 -0800 +Subject: [PATCH 2/2] Fix lint in trash-cli + +Fix the import redefinition issue in list.py detected by pyflakes +--- + trashcli/list.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/trashcli/list.py b/trashcli/list.py +index 09f30de..725b5ce 100644 +--- a/trashcli/list.py ++++ b/trashcli/list.py +@@ -4,7 +4,7 @@ import os + + from . import fstab + from .fs import FileSystemReader, file_size +-from .fstab import volume_of, VolumesListing ++from .fstab import VolumesListing + from .trash import (version, TrashDirReader, path_of_backup_copy, print_version, + maybe_parse_deletion_date, trash_dir_found, + trash_dir_skipped_because_parent_is_symlink, +-- +2.33.1 + diff --git a/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-unit-test-test_trash_empty_will_skip_unreadable.patch b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-unit-test-test_trash_empty_will_skip_unreadable.patch new file mode 100644 index 000000000000..75bd478f670d --- /dev/null +++ b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-unit-test-test_trash_empty_will_skip_unreadable.patch @@ -0,0 +1,66 @@ +From 566dbd8bdde01514c5cf0802d03a9dca918b6e82 Mon Sep 17 00:00:00 2001 +From: Zoltan Puskas <zoltan@sinustrom.info> +Date: Sat, 4 Dec 2021 12:59:37 -0800 +Subject: [PATCH] Fix unit test test_trash_empty_will_skip_unreadable_dir + +This patch fixes two issues with the current test: +- it prevents the test from breaking out of the test environment and + does not try to clean trash directories for all mount points +- it does actually test the "unreadable" directory + +Bug: GH-217 +--- + tests/test_trash_empty.py | 25 +++++++++++++++++-------- + 1 file changed, 17 insertions(+), 8 deletions(-) + +diff --git a/tests/test_trash_empty.py b/tests/test_trash_empty.py +index c7a987d..a2f87e6 100644 +--- a/tests/test_trash_empty.py ++++ b/tests/test_trash_empty.py +@@ -15,26 +15,35 @@ from .support import MyPath + from trashcli.fs import FileSystemReader + from trashcli.fs import FileRemover + +-from trashcli.empty import main as empty +- + + @pytest.mark.slow + class TestTrashEmptyCmd(unittest.TestCase): + def setUp(self): + self.tmp_dir = MyPath.make_temp_dir() + self.unreadable_dir = self.tmp_dir / 'data/Trash/files/unreadable' ++ self.volumes_listing = Mock(spec=VolumesListing) ++ self.volumes_listing.list_volumes.return_value = [self.unreadable_dir] ++ self.err=StringIO() ++ self.empty = EmptyCmd( ++ out=StringIO(), ++ err=self.err, ++ environ={'XDG_DATA_HOME':self.tmp_dir / 'data'}, ++ volumes_listing=self.volumes_listing, ++ now=None, ++ file_reader=FileSystemReader(), ++ getuid=lambda: 123, ++ file_remover=FileRemover(), ++ version=None, ++ volume_of=lambda x: "volume_of %s" % x ++ ) + + def test_trash_empty_will_skip_unreadable_dir(self): +- out = StringIO() +- err = StringIO() +- + make_unreadable_dir(self.unreadable_dir) + +- empty(['trash-empty'], stdout = out, stderr = err, +- environ={'XDG_DATA_HOME':self.tmp_dir / 'data'}) ++ self.empty.run('trash-empty') + + assert ("trash-empty: cannot remove %s\n" % self.unreadable_dir == +- err.getvalue()) ++ self.err.getvalue()) + + def tearDown(self): + make_readable(self.unreadable_dir) +-- +2.33.1 + diff --git a/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-unit-tests-not-deleting-temp-directories.patch b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-unit-tests-not-deleting-temp-directories.patch new file mode 100644 index 000000000000..917f34d50e60 --- /dev/null +++ b/app-misc/trash-cli/files/trash-cli-0.21.10.24-fix-unit-tests-not-deleting-temp-directories.patch @@ -0,0 +1,117 @@ +From 196144f90aaeb9d062019db4937dc4a1ec5991aa Mon Sep 17 00:00:00 2001 +From: Zoltan Puskas <zoltan@sinustrom.info> +Date: Sat, 4 Dec 2021 11:12:16 -0800 +Subject: [PATCH] Fix unit tests not deleting temp directories + +Some tests were not deleting temporary directories polluting /tmp. This +patch fixes all locations in the code where this was forgotten. + +Additionally we apply a suffix on top of the randomly generated name for +the temp directories (new name example: tmpwl2fvrn9_trash_cli_test) +becasue: +- it has no cost to us or the users +- helps identify temporary directories as belonging to trash-cli tests +- will make similar issues obvious in the future + +Bug: GH-218 +--- + tests/empty/test_empty_end_to_end_interactive.py | 3 +++ + tests/empty/test_empty_end_to_end_with_argument.py | 3 +++ + tests/put/test_end_to_end_put.py | 3 +++ + tests/restore/test_trash_directory.py | 3 ++- + tests/support.py | 2 +- + tests/test_files.py | 1 + + tests/test_filesystem.py | 2 ++ + tests/test_trash_put_slow.py | 3 +++ + 8 files changed, 18 insertions(+), 2 deletions(-) + +diff --git a/tests/empty/test_empty_end_to_end_interactive.py b/tests/empty/test_empty_end_to_end_interactive.py +index 80b8f81..14b2867 100644 +--- a/tests/empty/test_empty_end_to_end_interactive.py ++++ b/tests/empty/test_empty_end_to_end_interactive.py +@@ -40,3 +40,6 @@ class TestEmptyEndToEndInteractive(unittest.TestCase): + 'Would empty the following trash directories:\n' + ' - %s\n' + 'Proceed? (y/n) ' % self.trash_dir, '', 0] ++ ++ def tearDown(self): ++ self.tmp_dir.clean_up() +diff --git a/tests/empty/test_empty_end_to_end_with_argument.py b/tests/empty/test_empty_end_to_end_with_argument.py +index bfa660b..aad10de 100644 +--- a/tests/empty/test_empty_end_to_end_with_argument.py ++++ b/tests/empty/test_empty_end_to_end_with_argument.py +@@ -54,3 +54,6 @@ class TestEmptyEndToEndWithArgument(unittest.TestCase): + self.user_run_trash_empty(['2']) + + assert list_trash_dir(self.trash_dir) == ['info/foo.trashinfo'] ++ ++ def tearDown(self): ++ self.tmp_dir.clean_up() +diff --git a/tests/put/test_end_to_end_put.py b/tests/put/test_end_to_end_put.py +index 5b95b57..8af89b8 100644 +--- a/tests/put/test_end_to_end_put.py ++++ b/tests/put/test_end_to_end_put.py +@@ -89,3 +89,6 @@ class TestEndToEndPut(unittest.TestCase): + ['-f', 'this_file_does_not_exist', 'nor_does_this_file']) + + assert [result.stdout, result.stderr, result.exit_code] == ['', '', 0] ++ ++ def tearDown(self): ++ self.tmp_dir.clean_up() +diff --git a/tests/restore/test_trash_directory.py b/tests/restore/test_trash_directory.py +index d961f45..5328f98 100644 +--- a/tests/restore/test_trash_directory.py ++++ b/tests/restore/test_trash_directory.py +@@ -53,4 +53,5 @@ class TestTrashDirectory(unittest.TestCase): + def list_trashinfos(self): + return list(self.trash_dir.all_info_files(self.temp_dir / 'trash-dir')) + +- ++ def tearDown(self): ++ self.temp_dir.clean_up() +diff --git a/tests/support.py b/tests/support.py +index afbb402..d5966d3 100644 +--- a/tests/support.py ++++ b/tests/support.py +@@ -34,4 +34,4 @@ class MyPath(str): + + @classmethod + def make_temp_dir(cls): +- return cls(os.path.realpath(tempfile.mkdtemp())) ++ return cls(os.path.realpath(tempfile.mkdtemp(suffix="_trash_cli_test"))) +diff --git a/tests/test_files.py b/tests/test_files.py +index abe4ae0..487ffd3 100644 +--- a/tests/test_files.py ++++ b/tests/test_files.py +@@ -45,3 +45,4 @@ class Test_make_unreadable_dir(unittest.TestCase): + def tearDown(self): + make_readable(self.unreadable_dir) + shutil.rmtree(self.unreadable_dir) ++ self.tmp_dir.clean_up() +diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py +index 2df08b1..b1e9aa6 100644 +--- a/tests/test_filesystem.py ++++ b/tests/test_filesystem.py +@@ -64,3 +64,5 @@ class Test_is_sticky_dir(unittest.TestCase): + + assert not is_sticky_dir(self.temp_dir / 'dir') + ++ def tearDown(self): ++ self.temp_dir.clean_up() +diff --git a/tests/test_trash_put_slow.py b/tests/test_trash_put_slow.py +index e85f699..078c371 100644 +--- a/tests/test_trash_put_slow.py ++++ b/tests/test_trash_put_slow.py +@@ -29,6 +29,9 @@ class TrashPutFixture: + self.stderr = result.stderr + self.exit_code = result.exit_code + ++ def __del__(self): ++ self.temp_dir.clean_up() ++ + + @pytest.mark.slow + class TestDeletingExistingFile(unittest.TestCase): +-- +2.33.1 + diff --git a/app-misc/trash-cli/trash-cli-0.21.10.24.ebuild b/app-misc/trash-cli/trash-cli-0.21.10.24.ebuild new file mode 100644 index 000000000000..138286991d1c --- /dev/null +++ b/app-misc/trash-cli/trash-cli-0.21.10.24.ebuild @@ -0,0 +1,39 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7,8,9,10} ) + +inherit distutils-r1 + +DESCRIPTION="Python scripts to manipulate trash cans via the command line" +HOMEPAGE="https://github.com/andreafrancia/trash-cli" +SRC_URI="https://github.com/andreafrancia/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +BDEPEND=" + test? ( + dev-python/mock[${PYTHON_USEDEP}] + )" + +RDEPEND=" + dev-python/psutil[${PYTHON_USEDEP}] +" + +PATCHES=( + "${FILESDIR}/${P}-fix-lint-in-tests.patch" + "${FILESDIR}/${P}-fix-lint-in-trash-cli.patch" + "${FILESDIR}/${P}-fix-unit-tests-not-deleting-temp-directories.patch" + "${FILESDIR}/${P}-fix-unit-test-test_trash_empty_will_skip_unreadable.patch" +) + +distutils_enable_tests pytest + +src_test() { + local -x COLUMNS=80 + distutils-r1_src_test +} |