Skip to content

Commit

Permalink
Fix real path vs symlink inconsistence
Browse files Browse the repository at this point in the history
When calling abspath on a filename, the function returns its canonical
(real) path. In our tests, this value is compared against a symlink,
which causes errors.
  • Loading branch information
ivanvig authored and olofk committed Feb 17, 2025
1 parent 4a799ad commit ea493f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fusesoc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _resolve_path_from_cfg(self, path):
if os.path.isabs(expanded):
return expanded
else:
cfg_file_dir = os.path.dirname(os.path.abspath(self._path))
cfg_file_dir = os.path.dirname(os.path.realpath(self._path))
return os.path.normpath(os.path.join(cfg_file_dir, expanded))

def _path_from_cfg(self, name):
Expand Down
2 changes: 1 addition & 1 deletion fusesoc/coremanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def find_cores(self, library, ignored_dirs):
visited = set()
for root, dirs, files in os.walk(path, followlinks=True):
ignore_tree = ("FUSESOC_IGNORE" in files) or (
os.path.abspath(root) in ignored_dirs
os.path.realpath(root) in ignored_dirs
)
if ignore_tree:
del dirs[:]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def test_config_relative_path():

conf = Config(tcf.name)
for name in ["build_root", "cache_root", "library_root"]:
abs_td = os.path.abspath(td)
abs_td = os.path.realpath(td)
assert getattr(conf, name) == os.path.join(abs_td, name)


Expand All @@ -107,7 +107,7 @@ def test_config_relative_path_starts_with_dot():

conf = Config(tcf.name)
for name in ["build_root", "cache_root", "library_root"]:
abs_td = os.path.abspath(td)
abs_td = os.path.realpath(td)
assert getattr(conf, name) == os.path.join(abs_td, name)


Expand All @@ -128,7 +128,7 @@ def test_config_relative_path_with_local_config():

conf = Config(tcf.name)
for name in ["build_root", "cache_root", "library_root"]:
abs_td = os.path.abspath(td)
abs_td = os.path.realpath(td)
assert getattr(conf, name) == os.path.join(abs_td, name)
os.chdir(prev_dir)

Expand Down

0 comments on commit ea493f5

Please sign in to comment.