Closed peterjc closed 5 months ago
Use case: Test script(s) under tests/ and source code under scr/, running from the tests folder try using --source ../src/ and it fails.
tests/
scr/
--source ../src/
Work around: Use the absolute path
I believe the .. need expanding here:
..
def addSource(self, source : Path): if isinstance(source, str): source = Path(source) if not source.is_absolute(): source = self.cwd / source self.sources.append(source)
i.e. https://github.com/plasma-umass/slipcover/blob/v0.3.1/src/slipcover/importer.py#L61
It should probably call https://docs.python.org/3/library/pathlib.html#pathlib.Path.resolve but there could be side effects that I've not considered. However, this seems to work for me:
def addSource(self, source : Path): if isinstance(source, str): source = Path(source) if not source.is_absolute(): source = (self.cwd / source).resolve() self.sources.append(source)
Thinking about this there could be undesired behaviour with resolving symlinks, but I don't use them much in my source code myself.
Use case: Test script(s) under
tests/
and source code underscr/
, running from the tests folder try using--source ../src/
and it fails.Work around: Use the absolute path
I believe the
..
need expanding here:i.e. https://github.com/plasma-umass/slipcover/blob/v0.3.1/src/slipcover/importer.py#L61
It should probably call https://docs.python.org/3/library/pathlib.html#pathlib.Path.resolve but there could be side effects that I've not considered. However, this seems to work for me: