Context directories may contain double slashes
Summary
Directories stored by buildstream's context may currently contain double slashes (e.g. /temp/bst_cache//buildstream/build). These are not harmful, and in fact quite common (since we cannot predict whether a user ends their path with a / or not).
The tests in tests/context/context.py however read literal strings for paths, and in some environments will fail because a path contains double slashes.
Steps to reproduce
- Run
XDG_CACHE_HOME=/tmp/buildstream/ ./setup.py test --addopts 'tests/context/context.py'or similar (note that the cache directory ends in a slash). - Observe the tests failing.
What is the current bug behavior?
The test fails.
What is the expected correct behavior?
The test should succeed.
Relevant logs and/or screenshots
Output of XDG_CACHE_HOME="/temp/bst_cache/" ./setup.py test --addopts 'tests/context/context.py' on latest master in a fresh fedora testsuite docker container:
tests/context/context.py::test_context_load FAILED [100%]
=================================== FAILURES ===================================
______________________________ test_context_load _______________________________
context_fixture = {'context': <buildstream._context.Context object at 0x7ff3cc42d518>, 'xdg-cache': '/temp/bst_cache/'}
def test_context_load(context_fixture):
context = context_fixture['context']
cache_home = context_fixture['xdg-cache']
assert(isinstance(context, Context))
context.load(config=os.devnull)
> assert(context.sourcedir == os.path.join(cache_home, 'buildstream', 'sources'))
E AssertionError: assert '/temp/bst_ca...tream/sources' == '/temp/bst_cac...tream/sources'
E - /temp/bst_cache//buildstream/sources
E ? -
E + /temp/bst_cache/buildstream/sources
tests/context/context.py:44: AssertionError
Possible fixes
We could either set the assertions here To use os.path.normpath on the parsed directories, or we could change buildstream to use that while parsing internally.
I have added an MR to do the former for now, feel free to discuss whether that's just taping over the issue or whether we don't care about double slashes.
Other relevant information
- BuildStream version affected: /milestone %"BuildStream_v1.1"