diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-05-16 10:11:12 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-05-16 22:51:38 +0300 |
commit | 61750494f5ce7bd50d6856c36537cb7e8f5a7921 (patch) | |
tree | 5cd601b42a2c2e5d377d811089a3badfc5098710 | |
parent | 7f1cecf25b4e78df44dde1ed071088e50d7370a3 (diff) | |
download | meson-61750494f5ce7bd50d6856c36537cb7e8f5a7921.zip meson-61750494f5ce7bd50d6856c36537cb7e8f5a7921.tar.gz meson-61750494f5ce7bd50d6856c36537cb7e8f5a7921.tar.bz2 |
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.
-rwxr-xr-x | run_unittests.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/run_unittests.py b/run_unittests.py index 7242a5f..6efd3c3 100755 --- a/run_unittests.py +++ b/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): ''' |