[libvirt PATCH 016/351] meson: add test_suite build option

Pavel Hrdina posted 351 patches 5 years, 6 months ago
There is a newer version of this series
[libvirt PATCH 016/351] meson: add test_suite build option
Posted by Pavel Hrdina 5 years, 6 months ago
With autoconf this option controlled if the test suite is compiled by
default or not with the fact that it will be compiled later when
running `make check`.

With meson it is not possible to compile it later when running
`ninja test` as it will be always compiled if referenced by `test()`
function in meson.build files. Because of that enable the test suite
be default.

Enabling it only when compiling from git makes the test suite disabled
for `ninja dist` command which builds the code from non-git location.
Since that command is closest equivalent of `make distcheck` which runs
the test suite.

The only drawback from the autoconf state is that users compiling
libvirt from tarball will compile the test suite as well even though
they will not run it in most cases.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 configure.ac      | 17 -----------------
 meson.build       |  5 +++++
 meson_options.txt |  1 +
 3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/configure.ac b/configure.ac
index 66fc88bd014..71766f2fe61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -616,23 +616,6 @@ if test -z "$PERL"; then
          AC_MSG_ERROR(['perl' binary is required to build libvirt])
 fi
 
-LIBVIRT_ARG_WITH([TEST_SUITE], [build test suite by default], [check])
-case "$with_test_suite" in
-    yes|no|check) ;;
-    *) AC_MSG_ERROR([bad value ${withval} for tests option]) ;;
-esac
-
-AC_MSG_CHECKING([Whether to build test suite by default])
-if test "$with_test_suite" = "check" ; then
-  if test -d $srcdir/.git ; then
-    with_test_suite=yes
-  else
-    with_test_suite=no
-  fi
-fi
-AC_MSG_RESULT([$with_test_suite])
-AM_CONDITIONAL([WITH_TESTS], [test "$with_test_suite" = "yes"])
-
 LIBVIRT_ARG_ENABLE([EXPENSIVE_TESTS],
                    [set the default for enabling expensive tests ]
                      [(long timeouts), use VIR_TEST_EXPENSIVE to ]
diff --git a/meson.build b/meson.build
index 633db2df51a..fee75204d27 100644
--- a/meson.build
+++ b/meson.build
@@ -124,6 +124,11 @@ if packager_version != ''
 endif
 
 
+# test options
+
+use_test_suite = get_option('test_suite')
+
+
 # figure out libvirt version strings
 
 arr_version = meson.project_version().split('.')
diff --git a/meson_options.txt b/meson_options.txt
index 2281faec429..6973b9f6587 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -3,3 +3,4 @@ option('packager', type: 'string', value: '', description: 'Extra packager name'
 option('packager_version', type: 'string', value: '', description: 'Extra packager version')
 option('system', type: 'boolean', value: false, description: 'Set install paths to system ones')
 option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')
+option('test_suite', type: 'boolean', value: true, description: 'Whether to enable and build test suite by default')
-- 
2.26.2

Re: [libvirt PATCH 016/351] meson: add test_suite build option
Posted by Peter Krempa 5 years, 6 months ago
On Thu, Jul 16, 2020 at 11:54:12 +0200, Pavel Hrdina wrote:
> With autoconf this option controlled if the test suite is compiled by
> default or not with the fact that it will be compiled later when
> running `make check`.
> 
> With meson it is not possible to compile it later when running
> `ninja test` as it will be always compiled if referenced by `test()`
> function in meson.build files. Because of that enable the test suite
> be default.
> 
> Enabling it only when compiling from git makes the test suite disabled
> for `ninja dist` command which builds the code from non-git location.
> Since that command is closest equivalent of `make distcheck` which runs
> the test suite.
> 
> The only drawback from the autoconf state is that users compiling
> libvirt from tarball will compile the test suite as well even though
> they will not run it in most cases.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  configure.ac      | 17 -----------------
>  meson.build       |  5 +++++
>  meson_options.txt |  1 +
>  3 files changed, 6 insertions(+), 17 deletions(-)

[...]

> diff --git a/meson_options.txt b/meson_options.txt
> index 2281faec429..6973b9f6587 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -3,3 +3,4 @@ option('packager', type: 'string', value: '', description: 'Extra packager name'
>  option('packager_version', type: 'string', value: '', description: 'Extra packager version')
>  option('system', type: 'boolean', value: false, description: 'Set install paths to system ones')
>  option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')
> +option('test_suite', type: 'boolean', value: true, description: 'Whether to enable and build test suite by default')

Given that you've said that the testsuite is always build, the
description is misleadingly noting that it can be avoided.

Re: [libvirt PATCH 016/351] meson: add test_suite build option
Posted by Ján Tomko 5 years, 6 months ago
On a Wednesday in 2020, Peter Krempa wrote:
>On Thu, Jul 16, 2020 at 11:54:12 +0200, Pavel Hrdina wrote:
>> With autoconf this option controlled if the test suite is compiled by
>> default or not with the fact that it will be compiled later when
>> running `make check`.
>>
>> With meson it is not possible to compile it later when running
>> `ninja test` as it will be always compiled if referenced by `test()`
>> function in meson.build files. Because of that enable the test suite
>> be default.
>>
>> Enabling it only when compiling from git makes the test suite disabled
>> for `ninja dist` command which builds the code from non-git location.
>> Since that command is closest equivalent of `make distcheck` which runs
>> the test suite.
>>
>> The only drawback from the autoconf state is that users compiling
>> libvirt from tarball will compile the test suite as well even though
>> they will not run it in most cases.
>>
>> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
>> ---
>>  configure.ac      | 17 -----------------
>>  meson.build       |  5 +++++
>>  meson_options.txt |  1 +
>>  3 files changed, 6 insertions(+), 17 deletions(-)
>
>[...]
>
>> diff --git a/meson_options.txt b/meson_options.txt
>> index 2281faec429..6973b9f6587 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -3,3 +3,4 @@ option('packager', type: 'string', value: '', description: 'Extra packager name'
>>  option('packager_version', type: 'string', value: '', description: 'Extra packager version')
>>  option('system', type: 'boolean', value: false, description: 'Set install paths to system ones')
>>  option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')
>> +option('test_suite', type: 'boolean', value: true, description: 'Whether to enable and build test suite by default')
>
>Given that you've said that the testsuite is always build, the
>description is misleadingly noting that it can be avoided.
>

If the point of this is just to silently eat the command line option,
I'd say just drop it. Maintainers and users will have to adjust anyway.

Jano
Re: [libvirt PATCH 016/351] meson: add test_suite build option
Posted by Pavel Hrdina 5 years, 6 months ago
On Wed, Jul 22, 2020 at 11:25:07AM +0200, Ján Tomko wrote:
> On a Wednesday in 2020, Peter Krempa wrote:
> > On Thu, Jul 16, 2020 at 11:54:12 +0200, Pavel Hrdina wrote:
> > > With autoconf this option controlled if the test suite is compiled by
> > > default or not with the fact that it will be compiled later when
> > > running `make check`.
> > > 
> > > With meson it is not possible to compile it later when running
> > > `ninja test` as it will be always compiled if referenced by `test()`
> > > function in meson.build files. Because of that enable the test suite
> > > be default.
> > > 
> > > Enabling it only when compiling from git makes the test suite disabled
> > > for `ninja dist` command which builds the code from non-git location.
> > > Since that command is closest equivalent of `make distcheck` which runs
> > > the test suite.
> > > 
> > > The only drawback from the autoconf state is that users compiling
> > > libvirt from tarball will compile the test suite as well even though
> > > they will not run it in most cases.
> > > 
> > > Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> > > ---
> > >  configure.ac      | 17 -----------------
> > >  meson.build       |  5 +++++
> > >  meson_options.txt |  1 +
> > >  3 files changed, 6 insertions(+), 17 deletions(-)
> > 
> > [...]
> > 
> > > diff --git a/meson_options.txt b/meson_options.txt
> > > index 2281faec429..6973b9f6587 100644
> > > --- a/meson_options.txt
> > > +++ b/meson_options.txt
> > > @@ -3,3 +3,4 @@ option('packager', type: 'string', value: '', description: 'Extra packager name'
> > >  option('packager_version', type: 'string', value: '', description: 'Extra packager version')
> > >  option('system', type: 'boolean', value: false, description: 'Set install paths to system ones')
> > >  option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc')
> > > +option('test_suite', type: 'boolean', value: true, description: 'Whether to enable and build test suite by default')
> > 
> > Given that you've said that the testsuite is always build, the
> > description is misleadingly noting that it can be avoided.
> > 
> 
> If the point of this is just to silently eat the command line option,
> I'd say just drop it. Maintainers and users will have to adjust anyway.
> 
> Jano

That's true. At some point I was using the return value of this option.
I'll drop it completely.

Thanks

Pavel