Commit Graph

90 Commits

Author SHA1 Message Date
Nirbheek Chauhan 36e8291a6a unit tests: Run another linuxlike test on all platforms 2017-04-09 23:11:36 +05:30
Nirbheek Chauhan a51d582c72 unit tests: Skip tests that need Ninja
Such as tests that use the compiler db, or install things.
2017-04-09 23:11:36 +05:30
Nirbheek Chauhan f80d471345 unit tests: Fix running specific targets with MSBuild
/t:targetname syntax doesn't work, but running the vcxproj does work

Also use the Backend enum everywhere.
2017-04-09 23:11:36 +05:30
Nirbheek Chauhan a331bf1162 unit tests: Run on all backends, not just Ninja 2017-04-09 23:11:05 +05:30
Nirbheek Chauhan d755228afe tests: Factor out common code to run_tests
And use generic build/clean/test/install commands in the unit tests,
just like project tests. This sets the groundwork for running the unit
tests with all backends.
2017-04-09 23:08:42 +05:30
Jon Turney fd47ef3a27 Use '.exe' extension for executables for Cygwin
Use '.exe' extension for executables for Cygwin when building and installing
2017-04-06 22:47:15 +01:00
Jon Turney cbc5064a67 Don't use -fPIC on Cygwin, either
Identify Cygwin-targetted gcc as sui generis (don't use -fPIC, but don't
link with standard Windows libraries, either)

Update tests appropriately
2017-04-06 22:47:15 +01:00
Nirbheek Chauhan 6042e21e25 Use CPPFLAGS for pre-processor compiler checks
Also don't add CFLAGS twice for links() checks

Includes a test for this.
2017-04-04 23:38:36 +05:30
Jussi Pakkanen 8b73d80792 Merge pull request #1457 from mesonbuild/overrides
Add MVP implementation of overriding options.
2017-04-03 23:31:32 +03:00
Jussi Pakkanen c7f66c3a9e Merge pull request #1505 from centricular/dont-use-c++-for-assembly
Try harder to use the C compiler for compiling asm
2017-04-02 00:15:22 +03:00
Jussi Pakkanen 1b81b32afb Add test for werror which is a boolean type. 2017-04-02 00:07:23 +03:00
Jussi Pakkanen 319398f074 Proxy object for overriding options transparently. 2017-04-02 00:07:23 +03:00
Nirbheek Chauhan 9261243834 tests/common/141: Also test C + asm targets
Ensure that they are all built with and linked with the C compiler
2017-03-30 00:47:00 +05:30
Nirbheek Chauhan 31dc38826d unit tests: Skip static library overwrite on Windows
Test is broken due to https://github.com/mesonbuild/meson/issues/1526
2017-03-28 14:47:55 +05:30
Aaron Small b5e30fd8e0 Fix qt4 tool location detection, which may result in incorrectly picking
up qt5 tools when using the qt4 module.
2017-03-27 21:59:28 +03:00
Nirbheek Chauhan fa09b122b0 wrap: Also capture stderr while running quiet_git()
We want to return the stderr if the command failed.
2017-03-27 15:09:18 +05:30
Nirbheek Chauhan 001cf52c3a Try even harder to use the C compiler for assembly
Now as long as you have a C compiler available in the project, it will
be used to compile assembly even if the target contains a C++ compiler
and even if the target contains only assembly and C++ sources.

Earlier, the order in which sources appeared in a target would decide
which compiler would be used.

However, if the project only provides a C++ compiler, that will be
used for compiling assembly sources.

If this breaks your use-case, please tell us.

Includes a test that ensures that all of the above is adhered to.
2017-03-27 14:40:34 +05:30
Jussi Pakkanen d668bea11d Merge pull request #1496 from centricular/fix-internal-dep-order
Preserve internal-dep include order in build target dependencies
2017-03-25 18:55:47 +02:00
Nirbheek Chauhan d5975cc683 wrap: Implement special wrap modes for use by packagers
Special wrap modes:
  nofallback: Don't download wraps for dependency() fallbacks
  nodownload: Don't download wraps for all subproject() calls

Subprojects are used for two purposes:
1. To download and build dependencies by using .wrap files if they
   are not provided by the system. This is usually expressed via
   dependency(..., fallback: ...).
2. To download and build 'copylibs' which are meant to be used by
   copying into your project. This is always done with an explicit
   subproject() call.

--wrap-mode=nofallback will never do (1)
--wrap-mode=nodownload will do neither (1) nor (2)

If you are building from a release tarball, you should be able to
safely use 'nodownload' since upstream is expected to ship all
required sources with the tarball.

If you are building from a git repository, you will want to use
'nofallback' so that any 'copylib' wraps will be download as
subprojects.

Note that these options do not affect subprojects that are git
submodules since those are only usable in git repositories, and you
almost always want to download them.
2017-03-25 06:57:30 +05:30
Nirbheek Chauhan 7f80f81ac9 Preserve the order of internal deps in a target
We were adding them to the CompilerArgs instance in the order in which
they are specified, which is wrong because later dependencies would
override previous ones. Add them in the reverse order instead.

Closes https://github.com/mesonbuild/meson/issues/1495
2017-03-23 10:26:29 +05:30
Nirbheek Chauhan 50e0543cd7 unittests: Print output for failing commands
Because we are using check_output, if the command fails no output will
be printed at all. So, we use subprocess.run instead.

Also, on configure failures, print the meson-log.txt instead of stdout.
2017-03-13 03:25:57 +05:30
Jussi Pakkanen b3aaab3a03 Have all compiler invocations in compdb. Closes #1439. 2017-03-04 05:51:56 -05:00
Nirbheek Chauhan 01f207f347 unit tests: Don't try to test objc/c++ on Windows
MSVC compiler doesn't support it obviously.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 69e83d6aed Support passing of options to compilers and linkers
If you pass options, the last element in the array won't be the
compiler basename, so just check if the basename is in the exelist
somewhere.

Includes a test.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 56a8b2a181 Fix static linker exelist in cross-info and environment
https://github.com/mesonbuild/meson/pull/1406 had an incomplete fix
for this. The test case caught it.

Note: this still doesn't test that setting it in the cross-info works,
but it's the same codepath as via the environment so it should be ok.
2017-02-21 01:36:08 +05:30
Nirbheek Chauhan 798c349e35 Fix compiler exelist in cross-info and the environment
https://github.com/mesonbuild/meson/pull/1406 had an incomplete fix
for this. The test case caught it.

Note: this still doesn't test that setting it in the cross-info works,
but it's the same codepath as via the environment so it should be ok.
2017-02-21 01:36:08 +05:30
Jussi Pakkanen d6614ba811 Merge pull request #1402 from centricular/test-setup-fixes
Various fixes to how mesontest handles test setups.
2017-02-20 14:56:45 -05:00
Jussi Pakkanen 98af711ca6 Merge pull request #1403 from centricular/compile_resources
Make configure_file() great again
2017-02-20 14:27:06 -05:00
Nirbheek Chauhan 73b2ee08a8 Rewrite custom_target template string substitution
Factor it out into a function in mesonlib.py. This will allow us to
reuse it for generators and for configure_file(). The latter doesn't
implement this at all right now.

Also includes unit tests.
2017-02-20 23:32:03 +05:30
Nirbheek Chauhan f90f17b250 unit tests: Test some corner-cases in test setups
https://github.com/mesonbuild/meson/pull/1402
2017-02-19 23:13:32 +05:30
Nirbheek Chauhan 7e805a019a find_program: Fix implementation of .path()
And actually test that prog.path() works. The earlier test was just
running the command without checking if it succeeded.

Also make everything use prog.get_command() or get_path() instead of
accessing the internal member prog.fullpath directly.
2017-02-19 03:49:31 +05:30
Nirbheek Chauhan 18bce47691 find_program: Correctly use scripts found in PATH
We also need to check whether the program found in PATH can be executed
directly by Windows or if we need to figure out what the interpreter is
and add it to the list.

Also add `msc` to the list of extensions that can be executed natively

Includes a project test and a unit test for this and all expected
behaviours on Windows.
2017-02-18 02:38:54 +05:30
Nirbheek Chauhan d5b4944924 run_unittests: Move more tests to AllPlatformTests
Only tests that depend on Linux-specific behaviour are now in
LinuxlikeTests.
2017-02-18 02:38:54 +05:30
Nirbheek Chauhan 8e36697617 run_unittests: Resolve the real path of the tmpdir
On macOS, the temporary directory is inside /var/folders, but /var is
a symlink to /private/var, and for some reason that messes up path
traversal when you're inside the temporary directory and the source
directory is never found, and ninja runs in a loop trying to
regenerate files that can never be regenerated.
2017-02-18 02:38:54 +05:30
Nirbheek Chauhan 2eef18b163 run_unittests: Filter out non-object contents in static library test
On macOS, this contains an extra file called `__.SYMDEF SORTED`, so
filter it out.
2017-02-18 02:38:54 +05:30
Nirbheek Chauhan de1b10c32d run_unittests: Print output if a test failed
Earlier we would just swallow all output making it impossible to figure
out why something failed.
2017-02-18 02:38:54 +05:30
Nirbheek Chauhan a14eba27a9 ninja: Delete output static lib before calling `ar`
Otherwise if the list of sources changes on reconfigure after building,
the static library will contain both the old and new objects.

Closes https://github.com/mesonbuild/meson/issues/1355
2017-02-18 02:38:54 +05:30
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