diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2017-01-16 16:08:00 +0530 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-01-23 20:34:45 +0200 |
commit | 23f3cec9d029b5d44fa7f6a109ab9cda948b12ba (patch) | |
tree | 4334fc2fc36c12766ddc5c005bfe20f3ed119599 /run_unittests.py | |
parent | f762e896d2891edc53058ffeb57d38ee2c1fb8db (diff) | |
download | meson-23f3cec9d029b5d44fa7f6a109ab9cda948b12ba.zip meson-23f3cec9d029b5d44fa7f6a109ab9cda948b12ba.tar.gz meson-23f3cec9d029b5d44fa7f6a109ab9cda948b12ba.tar.bz2 |
Force installation dir options to be inside prefix
With the exception of things like sysconfdir (/etc), every other
installation directory option must be inside the prefix.
Also move the prefix checks to coredata.py since prefix can also be set
from inside project() with default_options and via mesonconf. Earlier
you could set prefix to a relative path that way.
This also allows us to return consistent values for get_option('xxxdir')
regardless of whether relative paths are passed or absolute paths are
passed while setting options on the command-line, via mesonconf, or via
default_options in project(). Now the returned path will *always* be
relative to the prefix.
Includes a unit test for this, and a failing test.
Closes #1299
Diffstat (limited to 'run_unittests.py')
-rwxr-xr-x | run_unittests.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/run_unittests.py b/run_unittests.py index 123bca8..6aa5b2b 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -33,10 +33,11 @@ def get_soname(fname): return m.group(1) raise RuntimeError('Could not determine soname:\n\n' + raw_out) -def get_fake_options(): +def get_fake_options(prefix): import argparse opts = argparse.Namespace() opts.cross_file = None + opts.prefix = prefix return opts class FakeEnvironment(object): @@ -85,7 +86,8 @@ class LinuxlikeTests(unittest.TestCase): super().tearDown() def _run(self, command): - self.output += subprocess.check_output(command, env=os.environ.copy()) + self.output += subprocess.check_output(command, stderr=subprocess.STDOUT, + env=os.environ.copy()) def init(self, srcdir, extra_args=None): if extra_args is None: @@ -510,7 +512,7 @@ class LinuxlikeTests(unittest.TestCase): ''' testdir = os.path.join(self.common_test_dir, '1 trivial') env = Environment(testdir, self.builddir, self.meson_command, - get_fake_options(), []) + get_fake_options(self.prefix), []) cc = env.detect_c_compiler(False) self._test_stds_impl(testdir, cc, 'c') @@ -521,11 +523,10 @@ class LinuxlikeTests(unittest.TestCase): ''' testdir = os.path.join(self.common_test_dir, '2 cpp') env = Environment(testdir, self.builddir, self.meson_command, - get_fake_options(), []) + get_fake_options(self.prefix), []) cpp = env.detect_cpp_compiler(False) self._test_stds_impl(testdir, cpp, 'cpp') - def test_build_by_default(self): testdir = os.path.join(self.unit_test_dir, '5 build by default') self.init(testdir) @@ -537,6 +538,21 @@ class LinuxlikeTests(unittest.TestCase): self._run(self.ninja_command + ['fooprog']) self.assertTrue(os.path.exists(exe)) + def test_libdir_must_be_inside_prefix(self): + testdir = os.path.join(self.common_test_dir, '1 trivial') + # libdir being inside prefix is ok + args = ['--prefix', '/opt', '--libdir', '/opt/lib32'] + self.init(testdir, args) + self.wipe() + # libdir not being inside prefix is not ok + args = ['--prefix', '/usr', '--libdir', '/opt/lib32'] + self.assertRaises(subprocess.CalledProcessError, self.init, testdir, args) + self.wipe() + # libdir must be inside prefix even when set via mesonconf + self.init(testdir) + self.assertRaises(subprocess.CalledProcessError, self.setconf, '-Dlibdir=/opt') + + class RewriterTests(unittest.TestCase): def setUp(self): |