aboutsummaryrefslogtreecommitdiff
# SPDX-License-Identifier: CC0-1.0

# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
#
# Available under the terms of Creative Commons Zero v1.0 Universal.

import re

variable_word_re = re.compile(r'^<(.+)>$')

def process_command(command, expected_command):
    """Validate the command line and extract its variable parts (if any)."""
    assert len(command) == len(expected_command)

    extracted = {}
    for word, expected_word in zip(command, expected_command):
        match = variable_word_re.match(expected_word)
        if match:
            extracted[match.group(1)] = word
        else:
            assert word == expected_word

    return extracted

def run_missing_executable(command, **kwargs):
    """
    Instead of running a command, raise FileNotFoundError as if its executable
    was missing.
    """
    raise FileNotFoundError('dummy')

class MockedCompletedProcess:
    """
    Object with some fields similar to those of subprocess.CompletedProcess.
    """
    def __init__(self, args, returncode=0,
                 stdout='some output', stderr='some error output',
                 text_output=True):
        """
        Initialize MockedCompletedProcess. Convert strings to bytes if needed.
        """
        self.args       = args
        self.returncode = returncode

        if type(stdout) is str and not text_output:
            stdout = stdout.encode()
        if type(stderr) is str and not text_output:
            stderr = stderr.encode()

        self.stdout = stdout
        self.stderr = stderr
pan title='2019-09-12 23:07:43 +0200'>2019-09-12linux-container: "run-container" scripts shows the container's PID....Ludovic Courtès 2019-09-12file-systems: Add /var/run/nscd to '%network-file-mappings'....Ludovic Courtès 2019-08-29Merge branch 'master' into core-updatesMark H Weaver 2019-08-28gnu: mingw-w64: Update to 6.0.0....David Thompson 2019-08-28accounts: Delete duplicate entries....Ludovic Courtès 2019-08-22Merge branch 'master' into core-updatesMark H Weaver 2019-08-16linux-modules: Define and use a module name database....Ludovic Courtès 2019-08-16linux-modules: Add 'load-linux-modules-from-directory'....Ludovic Courtès 2019-08-16linux-modules: Add "modules.devname" writer....Ludovic Courtès 2019-08-16linux-modules: Add "modules.alias" writer....Danny Milosavljevic 2019-08-14gnu: mingw: Add x86_64 support....Carl Dong 2019-07-12Merge branch 'master' into core-updates...Marius Bakke 2019-07-06linux-container: Mount a new /dev/pts instance in the container....Ludovic Courtès 2019-06-27Merge branch 'master' into core-updatesLudovic Courtès 2019-06-27accounts: Use 'fsync' instead of 'fdatasync'....Ludovic Courtès 2019-06-23linux-container: Remove dependency on (guix utils)....Ludovic Courtès 2019-06-17utils: Add 'invoke/quiet'....Ludovic Courtès 2019-06-13Merge branch 'master' into core-updatesLudovic Courtès 2019-06-07gnu: glibc-locales: Install symlinks using the normalized codeset....Ludovic Courtès 2019-06-07Add (gnu build locale)....Ludovic Courtès 2019-06-05accounts: Call 'fdatasync' when writing databases....Ludovic Courtès 2019-06-05accounts: Close database before renaming it....Ludovic Courtès 2019-06-05activation: Lock /etc/.pwd.lock before accessing databases....Ludovic Courtès 2019-06-03linux-boot: Fix e2fsck warning....Danny Milosavljevic 2019-05-25Merge branch 'staging' into core-updatesMarius Bakke