From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 918F6C4332F for ; Tue, 20 Dec 2022 03:29:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 24C9D85177; Tue, 20 Dec 2022 04:29:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FpILqgo3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E09C84F87; Tue, 20 Dec 2022 04:29:43 +0100 (CET) Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9138C83673 for ; Tue, 20 Dec 2022 04:29:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=maxim.cournoyer@gmail.com Received: by mail-qv1-xf2b.google.com with SMTP id o12so7553957qvn.3 for ; Mon, 19 Dec 2022 19:29:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=p+BgsuiXM0Xm6tE9QQxpX14T08L7/ftxBCXGLlxVMGM=; b=FpILqgo3VOEkgSNnbPSwTcex2LXwoiG01t9Se1DLITtkfdWrRLaL4tyLb+ZDm2O0co O/QiA68c7iHfnkleeHfJxXSwR62a0RiNg8/42Qh5+vNxLA9VGLEy+MFCBGnICCysIOcc wwyBM9obpmLOMcSd4PjOgkctWPhUcjTrTfBfrHcL2T/Akr4b1a67OdHMwzu6v8ryXEOf ZmSfnEO2ijwPdFfNBXNH6QJAtJTLOSiM0FWp4OeVR7fTxPsIflkUIzaXtFVrYIGYyMau rQdlR1MWTq27AHwdvq5IY+g/tqvmIlpkofgc4Z9VOBmLwuF16YaiBB4deXdlJYTgWfps aSZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=p+BgsuiXM0Xm6tE9QQxpX14T08L7/ftxBCXGLlxVMGM=; b=Srl5RXxiyJhr9yoXq51By7I3bthW55G0/9EELH83eyJaJs9tGSiNV3IYM8K0PwPu/D cALA6Enaf2/Q2hc4pcE3CjGtolYNGh9yxeOEL+8L5flrIFILvTBDQAmoVs/X3MlC8zQn AiwZYlUobSmXEKFEOzoWblGrQu8Pzg321k6RBX/n43iJ8FY5in7i5RYPSkgfRR3W/2nr TJyMwIvYf9tSF2s5TQNlQxg4k4plInoYIlms9ygaeuOQIS58orAkXIlTR0V+KgMfhJuN pg0fhCwgZ+yaw32goubn46Hx+LkImPMmK5Dt5OZay5SNaECxjMndAdP79VHbFggCuXGc XUJg== X-Gm-Message-State: AFqh2kqbEwrOnGqsHYvYWOOblGEI9WBO+eyBE2TXv7PPjuFNcMFuFBFH NeKZob19XeGadhSpXWjYzEg= X-Google-Smtp-Source: AMrXdXs2vc76VJkJmJQuwXqdrFlsN0rSl59ah+ruCQpT3JjTca+e9eHUDYzxwHTd/Atqtx8x4OXZ3w== X-Received: by 2002:a05:6214:1c5:b0:515:5e33:505b with SMTP id c5-20020a05621401c500b005155e33505bmr7400360qvt.20.1671506979223; Mon, 19 Dec 2022 19:29:39 -0800 (PST) Received: from hurd (dsl-10-133-202.b2b2c.ca. [72.10.133.202]) by smtp.gmail.com with ESMTPSA id d136-20020ae9ef8e000000b006fef157c8aesm8038082qkg.36.2022.12.19.19.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Dec 2022 19:29:38 -0800 (PST) From: Maxim Cournoyer To: Simon Glass Cc: U-Boot Mailing List , Maxim Cournoyer Subject: Re: [PATCH 6/6] patman: additionally honor a local .patman config file References: <20221219155009.16589-1-maxim.cournoyer@savoirfairelinux.com> <20221219155009.16589-7-maxim.cournoyer@savoirfairelinux.com> Date: Mon, 19 Dec 2022 22:29:37 -0500 In-Reply-To: (Simon Glass's message of "Mon, 19 Dec 2022 12:20:59 -0700") Message-ID: <87sfha4use.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Hi Simon, Simon Glass writes: > Hi Maxim, > > On Mon, 19 Dec 2022 at 08:50, Maxim Cournoyer wrote: >> >> This enables versioning a project specific patman configuration file. >> It also makes it possible to declare the the project name is, >> which is not a useful thing to do in $HOME/.patman. A new test is >> added, along updated documentation. >> >> Signed-off-by: Maxim Cournoyer >> --- >> >> tools/patman/patman.rst | 8 ++++++- >> tools/patman/settings.py | 24 +++++++++++++++---- >> tools/patman/test_settings.py | 43 +++++++++++++++++++++++++++++++++++ >> 3 files changed, 70 insertions(+), 5 deletions(-) >> create mode 100644 tools/patman/test_settings.py [...] >> diff --git a/tools/patman/test_settings.py b/tools/patman/test_settings.py >> new file mode 100644 >> index 0000000000..9c14b4aaa3 >> --- /dev/null >> +++ b/tools/patman/test_settings.py >> @@ -0,0 +1,43 @@ >> +# SPDX-License-Identifier: GPL-2.0+ >> +# >> +# Copyright (c) 2022 Maxim Cournoyer >> +# >> + >> +import argparse >> +import contextlib >> +import os >> +import subprocess >> +import tempfile >> + >> +from patman import settings >> + >> + >> +@contextlib.contextmanager >> +def empty_git_repository(): >> + with tempfile.TemporaryDirectory() as tmpdir: >> + os.chdir(tmpdir) >> + subprocess.check_call(['git', 'init']) > > We normally use tools.run() Adjusted like so: --8<---------------cut here---------------start------------->8--- modified tools/patman/test_settings.py @@ -6,18 +6,18 @@ import argparse import contextlib import os -import subprocess import sys import tempfile from patman import settings +from patman import tools @contextlib.contextmanager def empty_git_repository(): with tempfile.TemporaryDirectory() as tmpdir: os.chdir(tmpdir) - subprocess.check_call(['git', 'init']) + tools.run('git', 'init', raise_on_error=True) yield tmpdir --8<---------------cut here---------------end--------------->8--- >> + yield tmpdir >> + >> + >> +def test_git_local_config(): >> + with empty_git_repository(): >> + with tempfile.NamedTemporaryFile() as global_config: >> + global_config.write(b'[settings]\n' >> + b'project=u-boot\n') >> + global_config.flush() >> + parser = argparse.ArgumentParser() >> + parser.add_argument('-p', '--project', default='unknown') >> + >> + # Test "global" config is used. >> + settings.Setup(parser, 'unknown', global_config.name) >> + args, _ = parser.parse_known_args() >> + assert args.project == 'u-boot' >> + >> + # Test local config can shadow it. >> + with open('.patman', 'w', buffering=1) as f: > > Can this be created in the temporary dir? At present it looks like it > might overwrite a file in the current dir? The 'empty_git_repository' context manager chdir to a temporary directory upon entry, so anything that runs in its block such as the open call above will be executed in that temporary directory. See the 'os.chdir(tmpdir)' line above. I sent a v4 with the above change. -- Thanks, Maxim