[llvm] [llvm-lit] Resolve env subcommand required error (PR #98414)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 16:28:16 PDT 2024


https://github.com/Harini0924 created https://github.com/llvm/llvm-project/pull/98414

When executing not --crash env in lit's internal shell without any arguments, it fails with exit code 127 because env requires a subcommand. This patch addresses the issue by encoding the command to properly return environment variables even when no arguments are provided.

>From 95cc2cc1da3108d13cae3d5fe42e3113c6ede1cf Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 10 Jul 2024 23:22:04 +0000
Subject: [PATCH] [llvm-lit]

When executing not --crash env without any arguments,
it fails with exit code 127 because env reuires a
subcommand. This path addresses the issue by encoding
the command to properly return environment variables
even when no arguments are provided.
---
 llvm/utils/lit/lit/TestRunner.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da7fa86fd3917..8f0cd801ae9ff 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -743,7 +743,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                     cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env)
                 args = updateEnv(cmd_shenv, args)
                 if not args:
-                    raise InternalShellError(j, "Error: 'env' requires a" " subcommand")
+                    # Return the environment variables if no argument is provided 
+                    return {key: value for key, value in cmd_shenv.env.items()}
             elif args[0] == "not":
                 not_args.append(args.pop(0))
                 not_count += 1



More information about the llvm-commits mailing list