diff --git a/src/pydiode/tar.py b/src/pydiode/tar.py index 7d96eaf..e96b5ba 100644 --- a/src/pydiode/tar.py +++ b/src/pydiode/tar.py @@ -37,6 +37,8 @@ def main(): try: with tarfile.open(fileobj=sys.stdin.buffer, mode="r|") as tar: tar.extractall(args.path) + # Print the name of each file extracted + tar.list(verbose=False) # Don't print the full stack trace for known error types except tarfile.ReadError as e: if str(e) == "empty file": diff --git a/tests/test_tar.py b/tests/test_tar.py index d5baa63..449da40 100644 --- a/tests/test_tar.py +++ b/tests/test_tar.py @@ -28,12 +28,17 @@ def test_tar_untar(self): tar_receiver = subprocess.Popen( [sys.executable, "-m", "pydiode.tar", "extract", dest], stdin=tar_sender.stdout, + stdout=subprocess.PIPE, ) # Wait for the subprocesses to finish - tar_receiver.wait(timeout=1) - tar_sender.wait(timeout=1) - tar_sender.stdout.close() + receiver_stdout, _ = tar_receiver.communicate(timeout=1) + _, _ = tar_sender.communicate(timeout=1) + + # Ensure the printed filenames match the sent files + self.assertEqual( + list(files.keys()), receiver_stdout.decode("utf-8").split() + ) # Ensure the extracted files match the sent files for file, data in files.items():