run_unittests: make cross file location test robust against environment

Currently this test assumes that the user doesn't have XDG_DATA_HOME
set in their path, but this isn't a good assumption, and can result in
the test not actually testing what it means to.
pull/5403/head
Dylan Baker 5 years ago committed by Jussi Pakkanen
parent 7f1cecf25b
commit 61750494f5
  1. 11
      run_unittests.py

@ -2743,9 +2743,14 @@ int main(int argc, char **argv) {
f.write(cross_content)
name = os.path.basename(f.name)
with mock.patch('mesonbuild.coredata.os.path.expanduser', lambda x: x.replace('~', d)):
self.init(testdir, ['--cross-file=' + name], inprocess=True)
self.wipe()
# If XDG_DATA_HOME is set in the environment running the
# tests this test will fail, os mock the environment, pop
# it, then test
with mock.patch.dict(os.environ):
os.environ.pop('XDG_DATA_HOME', None)
with mock.patch('mesonbuild.coredata.os.path.expanduser', lambda x: x.replace('~', d)):
self.init(testdir, ['--cross-file=' + name], inprocess=True)
self.wipe()
def test_compiler_run_command(self):
'''

Loading…
Cancel
Save