]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
mkosi: add new switch --without-tests/-T for running the build script without running... 122/head
authorLennart Poettering <lennart@poettering.net>
Mon, 17 Jul 2017 17:10:29 +0000 (19:10 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 6 Oct 2017 17:35:57 +0000 (19:35 +0200)
This new option simply controls the $WITH_TESTS environment variable
(which defaults to 1), that is supposed to be honoured by the build
script the same way as $WITH_DOCS is honoured. If set to 0 the build script
should avoid unit running tests during the build process.

This is useful for speeding up the build process, in particular when
combining this with incremental mode, as it brings build-times for mkosi
much closer to build-times on the host, when developing software.

Note that this new switch changes exactly nothing in the way mkosi puts
together image, it only controls the value of $WITH_TESTS, and it is
exclusively up to the build script to honour this or not.

My new favourite command is now:

        # mkosi -ifT shell

This command will build a new image, avoid running tests and quickly
give me a shell in it.

mkosi

diff --git a/mkosi b/mkosi
index 5b953b0e9829e3d973b1162aaaf73777dc56136c..8d03e4e4d2ca2f81d9adbc6fb87f105dbf0eee8e 100755 (executable)
--- a/mkosi
+++ b/mkosi
@@ -1994,6 +1994,7 @@ def parse_args():
     group = parser.add_argument_group("Packages")
     group.add_argument('-p', "--package", action=PackageAction, dest='packages', help='Add an additional package to the OS image', metavar='PACKAGE')
     group.add_argument("--with-docs", action='store_true', help='Install documentation (only Fedora, CentOS and Mageia)')
+    group.add_argument('-T', "--without-tests", action='store_false', dest='with_tests', default=True, help='Do not run tests as part of build script, if supported')
     group.add_argument("--cache", dest='cache_path', help='Package cache path', metavar='PATH')
     group.add_argument("--extra-tree", action='append', dest='extra_trees', help='Copy an extra tree on top of image', metavar='PATH')
     group.add_argument("--build-script", help='Build script to run inside image', metavar='PATH')
@@ -2249,6 +2250,9 @@ def process_setting(args, section, key, value):
         elif key == "WithDocs":
             if not args.with_docs:
                 args.with_docs = parse_boolean(value)
+        elif key == "WithTests":
+            if not args.with_tests:
+                args.with_tests = parse_boolean(value)
         elif key == "Cache":
             if args.cache_path is None:
                 args.cache_path = value
@@ -2766,6 +2770,10 @@ def print_summary(args):
     sys.stderr.write("         Package Cache: " + none_to_none(args.cache_path) + "\n")
     sys.stderr.write("           Extra Trees: " + line_join_list(args.extra_trees) + "\n")
     sys.stderr.write("          Build Script: " + none_to_none(args.build_script) + "\n")
+
+    if args.build_script:
+        sys.stderr.write("             Run tests: " + yes_no(args.with_tests) + "\n")
+
     sys.stderr.write("         Build Sources: " + none_to_none(args.build_sources) + "\n")
     sys.stderr.write("       Build Directory: " + none_to_none(args.build_dir) + "\n")
     sys.stderr.write("        Build Packages: " + line_join_list(args.build_packages) + "\n")
@@ -2906,6 +2914,7 @@ def run_build_script(args, workspace, raw):
                    "--bind", dest + ":/root/dest",
                    "--bind=" + var_tmp(workspace) + ":/var/tmp",
                    "--setenv=WITH_DOCS=" + ("1" if args.with_docs else "0"),
+                   "--setenv=WITH_TESTS=" + ("1" if args.with_tests else "0"),
                    "--setenv=DESTDIR=/root/dest"]
 
         if args.build_sources is not None: