Commit Graph

53 Commits

Author SHA1 Message Date
Nirbheek Chauhan 217eae4011 run_unittests: Move sleep() ninja bug hack to setconf 2017-02-18 02:37:32 +05:30
Nirbheek Chauhan dd47bcd210 run_unittests: Support returning the output of a subprocess 2017-02-18 02:37:32 +05:30
Nirbheek Chauhan 82057ccd55 Add unit tests related to absolute prefixes
Also split the unit tests into those that are actually Linux-specific
and those that are not and can (and should) run on all platforms. This
will give us much better coverage since a lot of these test
platform-specific code in Meson that wraps features that we expose in
a platform-agnostic way.

Tests are for:
https://github.com/mesonbuild/meson/issues/1341
https://github.com/mesonbuild/meson/issues/1345
https://github.com/mesonbuild/meson/issues/1349
2017-02-18 02:37:32 +05:30
Nirbheek Chauhan 97911c4384 Fix absolute prefix/xxxdir subdir check on Windows
os.path.commonpath (and our implementation of it) both always return the
path using the native operating system path separator, so we can't just
directly compare it since the prefix could be specified in '/', and
commonpath would use '\' on Windows.

Also add a unit test for this.
2017-02-06 19:10:03 +01:00
Nirbheek Chauhan bb491735a9 coredata: Use our own implementation of commonpath
os.path.commonpath was added in Python 3.5, so just write our own for
now. pathlib was added in Python 3.4, so this should be ok. We need to
use that instead of doing str.split() etc because Windows path handling
has a lot of exceptions and pathlib handles all that for us.

Also adds a unit test for this.
2017-01-30 03:19:31 +05:30
Jussi Pakkanen 66fbcde96e Cope with files created with a different umask. 2017-01-29 19:05:59 +02:00
Jussi Pakkanen 4a08841331 Merge pull request #1335 from tp-m/test-custom-target-used-in-test-cmd
tests: check custom target output is created before being used in a t…
2017-01-28 19:05:54 +02:00
Nirbheek Chauhan 2bb58c909f Use CompilerArgs for generation of compile commands
At the same time, also fix the order in which compile arguments are
added. Detailed comments have been added concerning the priority and
order of the arguments.

Also adds a unit test and an integration test for the same.
2017-01-28 05:09:51 +05:30
Nirbheek Chauhan 4677f37366 tests: Move build-by-default unit test to common tests
Also add a test() that can be run on all platforms.

Currently unit tests are only run on Linux, so this was only testing the
Ninja backend. This change reveals that build-by-default was broken with
the Visual Studio backend.
2017-01-28 01:05:19 +05:30
Nirbheek Chauhan dbcbf19ece compilers: New class CompilerArgs derived from list()
The purpose of this class is to make it possible to sanely generate
compiler command-lines by ensuring that new arguments appended or added
to a list of arguments properly override previous arguments.
For instance:

>>> a = CompilerArgs(['-Lfoo', '-DBAR'])
>>> a += ['-Lgah', '-DTAZ']
>>> print(a)
['-Lgah', '-Lfoo', '-DBAR', '-DTAZ']

Arguments will be de-duped if it is safe to do so. Currently, this is
only done for -I and -L arguments (previous occurances are removed when
a new one is added) and arguments that once added cannot be overriden
such as -pipe are removed completely.
2017-01-27 23:42:22 +05:30
Nirbheek Chauhan 7d6f628ed4 Support file perms for install_data and install_subdir
With the 'install_mode' kwarg, you can now specify the file and
directory permissions and the owner and the group to be used while
installing. You can pass either:

* A single string specifying just the permissions
* A list of strings with:
  - The first argument a string of permissions
  - The second argument a string specifying the owner or
    an int specifying the uid
  - The third argument a string specifying the group or
    an int specifying the gid

Specifying `false` as any of the arguments skips setting that one.

The format of the permissions kwarg is the same as the symbolic
notation used by ls -l with the first character that specifies 'd',
'-', 'c', etc for the file type omitted since that is always obvious
from the context.

Includes unit tests for the same. Sadly these only run on Linux right
now, but we want them to run on all platforms. We do set the mode in the
integration tests for all platforms but we don't check if they were
actually set correctly.
2017-01-24 00:20:51 +05:30
Nirbheek Chauhan 23f3cec9d0 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
2017-01-23 20:34:45 +02:00
Jussi Pakkanen 21d8505825 build_by_default it is. 2017-01-15 20:14:46 +02:00
Jussi Pakkanen db8ad2a4bd Add test for build_on_all. 2017-01-15 19:45:23 +02:00
Hemmo Nieminen 5833bd6735 tests: Add a test for new test suite selection. 2017-01-13 00:09:52 +02:00
Nirbheek Chauhan 7f3aeb27e7 unit tests: Use assertIn() instead of assertTrue()
assertIn() will print both the arguments on assertion fail, but
assertTrue() will not, so that makes it easier to debug.
2017-01-04 00:40:54 +05:30
Nirbheek Chauhan 731aca216e icc: Fix C/C++ std options and add a unit test for them
Compiler versions 15.0 and later actually ignore invalid values for the
-std= option unless `-diag-error 10159` is passed, so we need to put
that in the unit test.

I have tested this with versions 14.0.3, 15.0.6, 16.0.4, and 17.0.1.
Would be great if someone could test with 13.x.y
2017-01-04 00:40:54 +05:30
Nirbheek Chauhan c8bb7f2217 unit tests: Be more specific in checking for commands
'-w' in c_command will check for it as a substring, which will also
match '-wd', etc. So match it with quotes. This won't give us false
positives, but might give us false negatives in case the argument is not
quoted, but that's better behaviour for a test.

The alternative is to split the string command, but the command does not
necessarily obey shell quoting rules, so we cannot reliably use
shlex.split().
2017-01-04 00:40:54 +05:30
Jussi Pakkanen 74f15263b6 Can set envvars in test setups. 2017-01-02 23:52:50 +02:00
Jussi Pakkanen ee8a6e6fc5 Can specify test setups and run them with mesontest. 2017-01-02 23:52:50 +02:00
Nirbheek Chauhan 3445beb00b Add a test for deterministic exe-wrapper data file
https://github.com/mesonbuild/meson/issues/1062
2016-12-31 21:59:02 +05:30
Jussi Pakkanen 0a14ad63de Add simple uninstall target. Closes #753. 2016-12-31 13:55:55 +02:00
Nirbheek Chauhan d5952531c7 Share code between installed and non-installed soname tests 2016-12-22 02:27:16 +05:30
Nirbheek Chauhan 18f581f2c4 Add an installed soname unit test
We also need to test that the sonames are correct after installation.
2016-12-22 01:32:02 +05:30
Igor Gnatenko 8268eb4959 tree-wide: remove unused imports
./setup.py:17:1: F401 'os' imported but unused
import os
^
./setup.py:37:1: F401 'stat.ST_MODE' imported but unused
from stat import ST_MODE
^
./run_tests.py:17:1: F401 'os' imported but unused
import subprocess, sys, os
^
./run_tests.py:18:1: F401 'shutil' imported but unused
import shutil
^
./run_unittests.py:23:1: F401 'mesonbuild.dependencies.Qt5Dependency' imported but unused
from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency
^
./mesonbuild/build.py:15:1: F401 '.coredata' imported but unused
from . import coredata
^
./mesonbuild/interpreter.py:32:1: F401 'subprocess' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/interpreter.py:32:1: F401 're' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/dependencies.py:23:1: F401 'subprocess' imported but unused
import os, stat, glob, subprocess, shutil
^
./mesonbuild/mesonlib.py:17:1: F401 'sys' imported but unused
import platform, subprocess, operator, os, shutil, re, sys
^
./mesonbuild/modules/qt5.py:15:1: F401 'subprocess' imported but unused
import os, subprocess
^
./mesonbuild/modules/pkgconfig.py:15:1: F401 '..coredata' imported but unused
from .. import coredata, build
^
./mesonbuild/scripts/scanbuild.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/meson_exe.py:20:1: F401 'subprocess' imported but unused
import subprocess
^
./mesonbuild/scripts/meson_exe.py:22:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/symbolextractor.py:23:1: F401 'subprocess' imported but unused
import os, sys, subprocess
^
./mesonbuild/scripts/symbolextractor.py:25:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/meson_install.py:19:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/yelphelper.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/yelphelper.py:20:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException
^
./mesonbuild/backend/vs2010backend.py:17:1: F401 're' imported but unused
import re
^
./test cases/vala/8 generated sources/src/copy_file.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/107 postconf/postconf.py:3:1: F401 'sys' imported but unused
import sys, os
^
./test cases/common/129 object only target/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^
./test cases/common/57 custom target chain/usetarget/subcomp.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/95 dep fallback/subprojects/boblib/genbob.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/98 gen extra/srcgen.py:4:1: F401 'os' imported but unused
import os
^
./test cases/common/113 generatorcustom/gen.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/113 generatorcustom/catter.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/59 object generator/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:19:35 +01:00
Jussi Pakkanen eba3a7ed60 Fix compiler arg checking if ccache is used. 2016-12-06 23:45:17 +02:00
Jussi Pakkanen 228a9035af Merge pull request #1103 from mesonbuild/rewriter
Beginnings of a rewriter
2016-12-06 20:22:04 +02:00
Jussi Pakkanen 14ca7d602c Store subdir information for each node so we can remove files set in other subdirectories. 2016-12-04 18:28:25 +02:00
Jussi Pakkanen 6aa24362cd Use copytree to prepare for further tests. 2016-12-04 17:38:03 +02:00
Jussi Pakkanen 90b038383d Renamed rewriter. 2016-12-04 01:08:13 +02:00
Jussi Pakkanen 2168860a1e Added unit test for rewriter. 2016-12-04 01:06:39 +02:00
Jussi Pakkanen ecb882cd4f Print readelf output if soversion can not be determined to help debugging. 2016-12-03 23:10:50 +02:00
Nirbheek Chauhan ae8c4f5a30 run_unittests: Document the purpose of each test 2016-12-04 00:34:53 +05:30
Nirbheek Chauhan 025d699c00 unit tests: Use universal_newlines everywhere
This approach is locale-independent and more correct. For instance, this
will work with UTF-16 while the previous approach with binary comparison
would not.

This also removes the need for doing an explicit decode to utf-8 which
is lossy and can fail by yielding no output at all.
2016-12-04 00:33:48 +05:30
Nirbheek Chauhan cee9638cc4 Compiler check and extra args should always override
We want compiler check arguments (-O0, -fpermissive, etc) to override
all other arguments, and we want extra_args passed in by the build file
to always override everything.

To do this properly, we must split include arguments out, append them
first, append all other arguments as usual, and then append the rest.

As part of this, we also add the compiler check flags to the
cc.compiles() and cc.links() helper functions since they also most
likely need them.

Also includes a unit test for all this.
2016-12-04 00:32:24 +05:30
Jussi Pakkanen 3276bdd23d Merge pull request #1102 from mesonbuild/soname
Fix soname symlink generation
2016-12-02 23:57:19 +02:00
Jussi Pakkanen 07d7e87411 Allow soname to be an arbitrary string and fix symlink generation. 2016-11-26 22:16:05 +02:00
Jussi Pakkanen bfd190279c Detect Qt5 properly on more platforms. 2016-11-23 05:11:02 -05:00
Jussi Pakkanen d651727208 Bootstrap test code with CMake. 2016-11-21 01:04:10 +02:00
Elliott Sales de Andrade 330aebc186 Fix message to be checked in Qt5 unit test. 2016-11-14 11:45:23 -05:00
Nirbheek Chauhan cedfa575f6 Add a unit test for Qt5 detection with qmake
This can only be done as a unit test because it requires changes to the
environment. This also means we need to pass the current environment to
subprocess.check_output, which we should always do anyway since the
environment is torn down and restored between each test.
2016-11-11 01:51:30 +05:30
Nirbheek Chauhan 66ec8c4258 tests: Check that run_target can find a files() argument
Tests https://github.com/mesonbuild/meson/issues/957
2016-11-09 03:03:33 +05:30
Jussi Pakkanen 69aa0091b1 The regex to detect version numbers needs to be a bit more complex. Closes #967. 2016-11-02 13:47:38 -07:00
Jussi Pakkanen 6762d30c6a Exposes the install names of targets in introspection. Closes #829. 2016-10-30 06:46:08 -07:00
Nirbheek Chauhan f3bb6bb227 Add a unit test to ensure object file order
Part of the changes to make input and output filenames in targets be
deterministic.
2016-10-25 14:36:47 +05:30
Nirbheek Chauhan 9ac98040ae Add a unittest using the Vala and C warnings test
This actually tests that -Wall, -Werror, and -w are set in the right
targets.
2016-10-14 19:13:38 +05:30
Nirbheek Chauhan 6ffae922cc Add a unittest for pkg-config file generation
This also tests that -lfoo is correctly added to libfoo.pc when the
library name is 'libfoo' and name_prefix is ''
2016-10-13 02:19:02 +05:30
Nirbheek Chauhan 7307f6a5c8 unittests/pic: Actually test that setting b_staticpic works
The previous test was tautological for the second half because:

a) b_staticpic=true is the default
b) We weren't refetching the compdb
2016-10-12 20:49:19 +05:30
Jussi Pakkanen 28df8b800e Add an option to select if static libraries are built with -fPIC. 2016-10-10 21:28:28 +03:00
Jussi Pakkanen f90bfa5245 Review fixes. 2016-10-09 14:41:47 -04:00