diff --git a/swh/loader/svn/tests/test_utils.py b/swh/loader/svn/tests/test_utils.py --- a/swh/loader/svn/tests/test_utils.py +++ b/swh/loader/svn/tests/test_utils.py @@ -5,6 +5,7 @@ import logging import os +from pathlib import Path import pty import shutil from subprocess import Popen @@ -43,6 +44,18 @@ assert os.path.exists(repo_path), "Repository should exists" +def test_init_svn_repo_from_dump_svnadmin_error(tmp_path): + """svnadmin load error should be reported in exception text""" + dump_path = os.path.join(tmp_path, "foo") + Path(dump_path).touch() + + with pytest.raises( + ValueError, + match="svnadmin: E200003: Premature end of content data in dumpstream", + ): + utils.init_svn_repo_from_dump(dump_path, cleanup_dump=False, root_dir=tmp_path) + + def test_init_svn_repo_from_dump_and_cleanup(datadir, tmp_path): """Mounting svn repository with a dump cleanup after is ok""" dump_name = "penguinsdbtools2018.dump.gz" diff --git a/swh/loader/svn/utils.py b/swh/loader/svn/utils.py --- a/swh/loader/svn/utils.py +++ b/swh/loader/svn/utils.py @@ -8,7 +8,7 @@ import os import re import shutil -from subprocess import PIPE, Popen, call +from subprocess import PIPE, Popen, call, run import tempfile from typing import Optional, Tuple from urllib.parse import quote, urlparse, urlunparse @@ -111,10 +111,13 @@ # are already handled in loader implementation (see _ra_codecs_error_handler # in ra.py) cmd = ["svnadmin", "load", "-q", "--bypass-prop-validation", repo_path] - r = call(cmd, stdin=dump.stdout) - if r != 0: + completed_process = run( + cmd, stdin=dump.stdout, capture_output=True, text=True + ) + if completed_process.returncode != 0: raise ValueError( - "Failed to mount the svn dump for project %s" % project_name + f"Failed to mount the svn dump for project {project_name}\n" + + completed_process.stderr ) return temp_dir, repo_path except Exception as e: