Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2198980pxt; Sun, 8 Aug 2021 15:19:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxip2vCmZrrGR8U9OKwSg3y5/+jgbI8pfimCwE+SgE43R93sq7P1Ui6aDKf/ddfUAnee3hn X-Received: by 2002:a05:6e02:1d89:: with SMTP id h9mr43409ila.46.1628461156561; Sun, 08 Aug 2021 15:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628461156; cv=none; d=google.com; s=arc-20160816; b=XssWBZ7MHUX11HXeLPIV6dfL7CqGtsPOGV510LFd0VN60+VxJTF1R0yOZGdWae1yzc JAVTfpm0GGZxGtV9J8PUapxa4vnoukAPKt9jewPehundgu2iFvRxE0RBKDz1X0k+yM2r Tjno8vWBLqx5h6MOKfVSPnxxZflRBsdUbIHmYoGRqGapRUO3wNnjYOKf629TJPaSb4Qk 5s3MqzNnXlr/AGZO2gRdq781cz4TCIYYNUL8ncuPoQ0oYhBywuYQRheLc8ax7SG0NMuh dCdb6pt4bjMX6JjopHT/rSstptpcPetQIaP+KanFZGFiBHlqULLQYAAdcl9C28fxz4Uy GUmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4kG1mXWtWB69bM3i+ipzGpeiQaSj0wG4hutze7Mc17Y=; b=qBoqaERY6SZ+TFLJOnmJ+UnKqYgZBYmxiw/T9xkCGfDv6XxqCykWyeZduTMam4w2hf 8WerNekovR7Ghk8erADgCAbnGrSVhmLtqnLTtHjT0x+HHT+5Y1v/O4rlha3rUDMTNp07 Yv3/lxyVVC1piREVabYb3inLRNmKx5UBrEuHyhuAIFlZLN63jh4UDrXvvOH9W1uEkgW0 EUhI1PMHcPEz9Ms0uZLn5geSUuVN2bsfDGRhQY1FvOJ2h66mnsOrNxSKoAPwZC9rWfFZ N/rDXir/5MwAH+MZoeO/JDa1flbQKG/MVL+u+j7IyJzusmwM4DLengFN+aKIHsotrW5H j+5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QwfCn3Kb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r206si1447204ior.87.2021.08.08.15.19.05; Sun, 08 Aug 2021 15:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QwfCn3Kb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230509AbhHHWS1 (ORCPT + 99 others); Sun, 8 Aug 2021 18:18:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:48760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229662AbhHHWS0 (ORCPT ); Sun, 8 Aug 2021 18:18:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19A7A60F35; Sun, 8 Aug 2021 22:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628461086; bh=AhkExiTj7NgYDK7oXdA9gqLj35ImbC6c4czHxK2oQn0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QwfCn3KbXf7HgTJBDumrlNYfthmkNhnOhXLzc8c4t0p/DkwRRfmdCn6JiJKG8bFDP 5gk0EPuc0n4Y5HhJqb6Tub0vLgM/KMVowq/b0Cl8ZeHIbbHHeJnp/IsExIlPny4lMl sPsuB289/KGsSSPIbbYmVRSBRCN+OAZgZcNP/i91yfJQnQ0aQPkOI1A6twmRgPW46o i5dDSwJLVWdHOJJEr+tyN0W95HSyEoyIalUy3wyDWuBnDX3n+jzkvnOliS8MOlyGAK fvondkbzCGNsNV3OqJj9ZkUfGqpoNbmUwvpt/ftG5PEiGadkUCbNf5CscHDb9RvNTH PlNA6OHqi/Mjw== Date: Sun, 8 Aug 2021 15:18:04 -0700 From: Nathan Chancellor To: Maciej Falkowski Cc: natechancellor@gmail.com, ndesaulniers@google.com, masahiroy@kernel.org, michal.lkml@markovi.net, nhuck@google.com, clang-built-linux@googlegroups.com, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] clang-tools: Print information when clang-tidy tool is missing Message-ID: References: <20210807110116.7985-1-maciej.falkowski9@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210807110116.7985-1-maciej.falkowski9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 07, 2021 at 01:01:16PM +0200, Maciej Falkowski wrote: > When clang-tidy tool is missing in the system, the FileNotFoundError > exception is raised in the program reporting a stack trace to the user: > > $ ./scripts/clang-tools/run-clang-tools.py clang-tidy ./compile_commands.json > multiprocessing.pool.RemoteTraceback: > """ > Traceback (most recent call last): > File "/usr/lib64/python3.8/multiprocessing/pool.py", line 125, in worker > result = (True, func(*args, **kwds)) > File "/usr/lib64/python3.8/multiprocessing/pool.py", line 48, in mapstar > return list(map(*args)) > File "./scripts/clang-tools/run-clang-tools.py", line 54, in run_analysis > p = subprocess.run(["clang-tidy", "-p", args.path, checks, entry["file"]], > File "/usr/lib64/python3.8/subprocess.py", line 489, in run > with Popen(*popenargs, **kwargs) as process: > File "/usr/lib64/python3.8/subprocess.py", line 854, in __init__ > self._execute_child(args, executable, preexec_fn, close_fds, > File "/usr/lib64/python3.8/subprocess.py", line 1702, in _execute_child > raise child_exception_type(errno_num, err_msg, err_filename) > FileNotFoundError: [Errno 2] No such file or directory: 'clang-tidy' > """ > > The patch adds more user-friendly information about missing tool: > > $ ./scripts/clang-tools/run-clang-tools.py clang-tidy ./compile_commands.json > Command 'clang-tidy' is missing in the system > > Signed-off-by: Maciej Falkowski > Link: https://github.com/ClangBuiltLinux/linux/issues/1342 LGTM, I think this is much better than the stacktrace output as above as it is easier for someone who is not familiar with these scrips to act on. Reviewed-by: Nathan Chancellor > --- > Hi Masahiro, > > Thank you for your feedback! > I am sorry that I haven't replied for so long. > > I agree with your point, based on this I would like > to propose a second version of the patch. > > changes in v2: > - Solution has changed from LBYL style to EAFP > > Best regards, > Maciej Falkowski > --- > scripts/clang-tools/run-clang-tools.py | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py > index fa7655c7cec0..27ebe2f2069a 100755 > --- a/scripts/clang-tools/run-clang-tools.py > +++ b/scripts/clang-tools/run-clang-tools.py > @@ -67,7 +67,14 @@ def main(): > # Read JSON data into the datastore variable > with open(args.path, "r") as f: > datastore = json.load(f) > - pool.map(run_analysis, datastore) > + try: > + pool.map(run_analysis, datastore) > + except FileNotFoundError as err: > + if err.filename == 'clang-tidy': > + print("Command 'clang-tidy' is missing in the system", file=sys.stderr) > + sys.exit(127) > + else: > + raise err > > > if __name__ == "__main__": > -- > 2.26.3