[reprotest] 01/01: Documentation the new variations syntax and tweak some flags

Ximin Luo infinity0 at debian.org
Fri Sep 15 12:06:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository reprotest.

commit 50d99938ccfdeaeb1103b86789bcd42f59c890ab
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Sep 15 14:02:58 2017 +0200

    Documentation the new variations syntax and tweak some flags
    
    - revert --variations to non-append behaviour, for backwards compatibility
    - add a --vary flag for the append behaviour, for better composability
---
 README.rst              | 78 ++++++++++++++++++++++++++++++++++++++++++++-----
 debian/changelog        |  5 +---
 reprotest/__init__.py   | 30 ++++++++++++-------
 reprotest/build.py      |  5 ++++
 reprotest/mdiffconf.py  |  2 ++
 tests/test_reprotest.py |  2 +-
 6 files changed, 99 insertions(+), 23 deletions(-)

diff --git a/README.rst b/README.rst
index c541cc0..21308c0 100644
--- a/README.rst
+++ b/README.rst
@@ -188,11 +188,75 @@ This flag is already set in our presets, in the situations where it is
 appropriate to do so.
 
 
-Varying the user
-================
+Variations
+==========
 
-If you also vary fileordering at the same time, each user you use needs to be
-in the "fuse" group. Do that by running `usermod -aG fuse $OTHERUSER` as root.
+The --vary and --variations flags in their simple forms, are a comma-separated
+list of variation names that indicate which variations to apply. The full list
+of names is given in the --help text for --variations.
+
+| \
+| In full detail, the flags are a comma-separated list of actions, as follows:
+|
+| +$variation (or $variation with no explicit operator)
+| -$variation
+|    Enable or disable a variation
+|
+| @$variation
+|    Enable a variation, resetting its parameters (see below) to default values.
+|
+| $variation.$param=$value
+| $variation.$param+=$value
+| $variation.$param-=$value
+|    Set/add/remove $value as/to/from the current value of the $param parameter
+     of the $variation.
+|
+| $variation.$param++
+| $variation.$param--
+|    Increment/decrement the value of the $param parameter of the $variation.
+
+Most variations do not have parameters, and for them only the + and - operators
+are relevant. The variations that accept parameters are:
+
+user_group.available
+    A semicolon-separated ordered set, specifying the available user+group
+    combinations that reprotest can ``sudo(1)`` to. Default is empty, in which
+    case the variation is a no-op, and you'll see a warning about this. Each
+    user+group should be given in the form $user:$group where either component
+    can be omitted, or else if there is no colon then it is interpreted as only
+    a $user, with no $group variation.
+time.faketimes
+    A semicolon-separated ordered set, specifying possible ``faketime(1)`` time
+    descriptors to use. Default is empty.
+time.auto_faketimes
+    A semicolon-separated ordered set, specifying a list of "magic" values
+    which will be resolved into additional values for time.faketimes. Default
+    is "SOURCE_DATE_EPOCH", possible values are:
+
+    SOURCE_DATE_EPOCH
+        Use the latest file modification time found in the source_root.
+
+The difference between --vary and --variations is that the former appends onto
+previous values but the latter resets them. Furthermore, the last value set for
+--variations is treated as the zeroth --vary argument. For example::
+
+    reprotest --vary=-user_group
+
+means to vary +all (the default value for --variations) and -user_group (the
+given value for --vary), whereas::
+
+    reprotest --variations=-all --variations=home,time --vary=timezone --vary=-time
+
+means to vary home, time (the last given value for --variations), timezone, and
+-time (the given multiple values for --vary), i.e. home and timezone.
+
+
+Varying the user or group
+=========================
+
+If you also vary fileordering at the same time (this is the case by default),
+each user you use needs to be in the "fuse" group. Do that by running `usermod
+-aG fuse $OTHERUSER` as root.
 
 Avoid sudo(1) password prompts
 ------------------------------
@@ -223,10 +287,10 @@ know what the sudo authors were thinking.)
 No, this is really not nice at all - suggestions and patches welcome.
 
 
-Known bugs
-==========
+Varying the time
+================
 
-The "time" variation uses **faketime** which *sometimes* causes weird and
+The "time" variation uses ``faketime(1)`` which *sometimes* causes weird and
 hard-to-diagnose problems. In the past, this has included:
 
 - builds taking an infinite amount of time; though this should be fixed in
diff --git a/debian/changelog b/debian/changelog
index 84d5080..e01b721 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,5 @@
 reprotest (0.7) UNRELEASED; urgency=medium
 
-  FIXME do not release
-  - update the docs on --variations
-
   [ Ximin Luo ]
   * Document when one should use --diffoscope-args=--exclude-directory-metadata
     and do this in our Debian package presets.
@@ -13,7 +10,7 @@ reprotest (0.7) UNRELEASED; urgency=medium
   * Heavy refactoring to support > 2 builds.
   * Add a variation config language to be able to configure the specifics of
     different variations, and to make it easier to configure further builds.
-  * Deprecate the --dont-vary flag.
+  * Deprecate the --dont-vary flag, add a --vary flag for better composability.
 
   [ Mattia Rizzolo ]
   * Bump Standards-Version to 4.0.0.
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index a0c9035..76ab788 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -105,7 +105,7 @@ class BuildContext(collections.namedtuple('_BuildContext', 'testbed_root local_d
             tree = self.testbed_src
         )
 
-    def plan_variations(self, build, is_control, variations): # XXX
+    def plan_variations(self, build, is_control, variations):
         if is_control:
             variations = variations._replace(spec=VariationSpec.empty())
         actions = variations.spec.actions()
@@ -309,11 +309,12 @@ def cli_parser():
     parser.add_argument('source_root|build_command', default=None, nargs='?',
         help='The first argument is treated either as a source_root (see the '
         '-s option) or as a build-command (see the -c option) depending on '
-        'some heuristics. Specifically: if neither -c nor -s are given, then: '
-        'if this exists as a file or directory and is not "auto", then this is '
-        'treated as a source_root, else as a build_command. Otherwise, if one '
-        'of -c or -s is given, then this is treated as the other one. If both '
-        'are given, then this is a command-line syntax error and we exit code 2.'),
+        'what it looks like. Most of the time, this should "just work"; but '
+        'specifically: if neither -c nor -s are given, then: if this exists as '
+        'a file or directory and is not "auto", then this is treated as a '
+        'source_root, else as a build_command. Otherwise, if one of -c or -s '
+        'is given, then this is treated as the other one. If both are given, '
+        'then this is a syntax error and we exit code 2.'),
     parser.add_argument('artifact_pattern', default=None, nargs='?',
         help='Build artifact to test for reproducibility. May be a shell '
              'pattern such as "*.deb *.changes".'),
@@ -353,9 +354,16 @@ def cli_parser():
         help='Save the artifacts in this directory, which must be empty or '
         'non-existent. Otherwise, the artifacts will be deleted and you only '
         'see their hashes (if reproducible) or the diff output (if not).')
-    group1.add_argument('--variations', default=["+all"], action='append',
-        help='Build variations to test as a whitespace-or-comma-separated '
-        'list.  Default is to test all available variations: %(default)s.')
+    group1.add_argument('--variations', default="+all",
+        help='Build variations to test as a comma-separated list of variation '
+        'names. Default is "+all", equivalent to "%s", testing all available '
+        'variations. See the man page section on VARIATIONS for more advanced '
+        'syntax options, including tweaking how certain variations work.' %
+        VariationSpec.default_long_string())
+    group1.add_argument('--vary', metavar='VARIATIONS', default=[], action='append',
+        help='Like --variations, but appends to previous --vary values '
+        'instead of overwriting them. Furthermore, the last value set for '
+        '--variations is treated implicitly as the zeroth --vary value.')
     # TODO: remove after reprotest 0.8
     group1.add_argument('--dont-vary', default=[], action='append', help=argparse.SUPPRESS)
 
@@ -498,9 +506,9 @@ def run(argv, check):
             diffoscope_args = values.diffoscope_args + diffoscope_args
 
     # Variations args
-    variations = parsed_args.variations
+    variations = [parsed_args.variations] + parsed_args.vary
     if parsed_args.dont_vary:
-        logging.warn("--dont-vary is deprecated; use --variations=-$variation instead")
+        logging.warn("--dont-vary is deprecated; use --vary=-$variation instead")
         variations += ["-%s" % a for x in parsed_args.dont_vary for a in x.split(",")]
     spec = VariationSpec().extend(variations)
     variations = Variations(verbosity, spec)
diff --git a/reprotest/build.py b/reprotest/build.py
index 072dad7..85c460e 100644
--- a/reprotest/build.py
+++ b/reprotest/build.py
@@ -394,6 +394,11 @@ class VariationSpec(mdiffconf.ImmutableNamespace):
         return cls(**{k: default_overrides.get(k, True) for k in variations})
 
     @classmethod
+    def default_long_string(cls):
+        actions = cls.default().actions()
+        return ", ".join("+" + a[0] for a in actions)
+
+    @classmethod
     def empty(cls):
         return cls()
 
diff --git a/reprotest/mdiffconf.py b/reprotest/mdiffconf.py
index 98775ae..a6d4709 100644
--- a/reprotest/mdiffconf.py
+++ b/reprotest/mdiffconf.py
@@ -140,8 +140,10 @@ def parse(d, action, one, zero=None, aliases={}):
             single $alias_operand to specify one-or-more $real_operands to
             actually apply the operator to.
     """
+    if not action: return d
     parts = re.split(r"(\+=|-=|\+\+|--|=|\+|-|@)", action, 1)
     attr, op, operand = ("", "+", parts[0]) if len(parts) == 1 else parts
+    attr = attr.strip()
     target, target_one = rgetattr2(d, attr, one)
 
     if op in ("++", "--"):
diff --git a/tests/test_reprotest.py b/tests/test_reprotest.py
index 03cf4a9..81f1baf 100644
--- a/tests/test_reprotest.py
+++ b/tests/test_reprotest.py
@@ -14,7 +14,7 @@ REPROTEST_TEST_SERVERS = os.getenv("REPROTEST_TEST_SERVERS", "null").split(",")
 REPROTEST_TEST_DONTVARY = os.getenv("REPROTEST_TEST_DONTVARY", "").split(",")
 
 if REPROTEST_TEST_DONTVARY:
-    REPROTEST += ["--variations=-" + ",-".join(REPROTEST_TEST_DONTVARY)]
+    REPROTEST += ["--vary=-" + ",-".join(REPROTEST_TEST_DONTVARY)]
 
 TEST_VARIATIONS = frozenset(reprotest.build.VARIATIONS.keys()) - frozenset(REPROTEST_TEST_DONTVARY)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git



More information about the Reproducible-commits mailing list