mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
version: don't skip link info and skip if there is no psutil
Fixes #2336 Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
+12
-12
@@ -42,22 +42,22 @@ class CmdVersion(CmdBaseNoRepo):
|
||||
binary=binary,
|
||||
)
|
||||
|
||||
if psutil:
|
||||
try:
|
||||
repo = Repo()
|
||||
root_directory = repo.root_dir
|
||||
try:
|
||||
repo = Repo()
|
||||
root_directory = repo.root_dir
|
||||
|
||||
info += "Cache: {cache}\n".format(
|
||||
cache=self.get_linktype_support_info(repo)
|
||||
)
|
||||
|
||||
if psutil:
|
||||
info += (
|
||||
"Cache: {cache}\n"
|
||||
"Filesystem type (cache directory): {fs_cache}\n"
|
||||
).format(
|
||||
cache=self.get_linktype_support_info(repo),
|
||||
fs_cache=self.get_fs_type(repo.cache.local.cache_dir),
|
||||
)
|
||||
|
||||
except NotDvcRepoError:
|
||||
root_directory = os.getcwd()
|
||||
).format(fs_cache=self.get_fs_type(repo.cache.local.cache_dir))
|
||||
except NotDvcRepoError:
|
||||
root_directory = os.getcwd()
|
||||
|
||||
if psutil:
|
||||
info += ("Filesystem type (workspace): {fs_root}").format(
|
||||
fs_root=self.get_fs_type(os.path.abspath(root_directory))
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import re
|
||||
import pytest
|
||||
|
||||
from dvc.main import main
|
||||
from dvc.command.version import psutil
|
||||
|
||||
|
||||
def test_info_in_repo(dvc_repo, caplog):
|
||||
@@ -10,15 +12,21 @@ def test_info_in_repo(dvc_repo, caplog):
|
||||
assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
|
||||
assert re.search(re.compile(r"Platform: .*"), caplog.text)
|
||||
assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
|
||||
assert re.search(
|
||||
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(psutil is None, reason="No psutil.")
|
||||
def test_fs_info_in_repo(dvc_repo, caplog):
|
||||
assert main(["version"]) == 0
|
||||
|
||||
assert re.search(
|
||||
re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
|
||||
)
|
||||
assert re.search(
|
||||
re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
|
||||
)
|
||||
assert re.search(
|
||||
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
|
||||
)
|
||||
|
||||
|
||||
def test_info_outside_of_repo(repo_dir, caplog):
|
||||
@@ -28,12 +36,18 @@ def test_info_outside_of_repo(repo_dir, caplog):
|
||||
assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
|
||||
assert re.search(re.compile(r"Platform: .*"), caplog.text)
|
||||
assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
|
||||
assert not re.search(
|
||||
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.skipif(psutil is None, reason="No psutil.")
|
||||
def test_fs_info_outside_of_repo(repo_dir, caplog):
|
||||
assert main(["version"]) == 0
|
||||
|
||||
assert re.search(
|
||||
re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
|
||||
)
|
||||
assert not re.search(
|
||||
re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
|
||||
)
|
||||
assert not re.search(
|
||||
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user