[llvm] [llvm-lit] Print environment variables when using env without subcommand (PR #98414)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 28 13:56:23 PDT 2024


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

>From bd4f8975b8374e8e242c66834f38f2a0099dcec0 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 10 Jul 2024 23:22:04 +0000
Subject: [PATCH 01/23] [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 da7fa86fd39173..8f0cd801ae9ff5 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

>From a44f93b5579214d3269903e76ae3020e307f00f8 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 18 Jul 2024 07:13:21 +0000
Subject: [PATCH 02/23] [llvm-lit] Resolve env subcommand required error

This patch addresses an issue where calling env without any arguments incorrectly returns
a "requires subcommand" message. The patch modifies the env command to properly display
the current environment variables even when no arguments are provided. Additionally,
the test cases have been updated: instead of returning an error, the tests now pass
and check if the environment variables are output correctly.
---
 llvm/utils/lit/lit/TestRunner.py              |  4 ++-
 .../tests/Inputs/shtest-env/env-args-none.txt | 31 ++++++++++++++++++-
 llvm/utils/lit/tests/shtest-env.py            | 30 +++++++++---------
 3 files changed, 48 insertions(+), 17 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 8f0cd801ae9ff5..da541c6b742a3d 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -744,7 +744,9 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                 args = updateEnv(cmd_shenv, args)
                 if not args:
                     # Return the environment variables if no argument is provided 
-                    return {key: value for key, value in cmd_shenv.env.items()}
+                    env_str = "\n".join(f"{key}={value}" for key, value in cmd_shenv.env.items())
+                    results.append(ShellCommandResult(j, env_str, "", 0 , timeoutHelper.timeoutReached(), []))
+                    return 0
             elif args[0] == "not":
                 not_args.append(args.pop(0))
                 not_count += 1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index dc5cdbad09afc9..0eb724a2101c34 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -1 +1,30 @@
-# RUN: env
+# Check Default Environment
+# RUN: env | FileCheck -check-prefix=CHECK-2-EMPTY %s
+#
+# CHECK-2-EMPTY: BAR = 2
+# CHECK-2-EMPTY: FOO = 1
+
+# Set Environment Variables
+# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s
+#
+# CHECK-2-VAL: BAR = 1
+# CHECK-2-VAL: FOO = 2
+
+# Unset Environment Variables
+# RUN: env -u FOO -u BAR | FileCheck -check-prefix=CHECK-2-U %s
+#
+# CHECK-2-U-NOT: BAR
+# CHECK-2-U-NOT: FOO
+
+# Mixed Set and Unset Environment Variables
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s
+#
+# CHECK-2-U-VAL-NOT: BAR
+# CHECK-2-U-VAL: FOO = 2
+ 
+# Mixed Set and Unset with Additional Variable
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=CHECK-3 %s
+#
+# CHECK-3-NOT: BAR
+# CHECK-3: BAZ = 3
+# CHECK-3: FOO = 2
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 03bb4a3cae7dd1..61ee9bc7d21ace 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -9,35 +9,35 @@
 
 # CHECK: -- Testing: 16 tests{{.*}}
 
-# CHECK: FAIL: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
 # CHECK: # executed command: env FOO=1
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}} 
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
 # CHECK: # executed command: env -u FOO
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}} 
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
 # CHECK: env -u
 # CHECK: # executed command: env -u
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}}
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
 # CHECK: env env env
 # CHECK: # executed command: env env env
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}}
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-none.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
 # CHECK: env
 # CHECK: # executed command: env
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}}
+# CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 cd foobar

>From cded1a6df0b51d2206ca443a3f42a13392fa9de8 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 18 Jul 2024 07:16:05 +0000
Subject: [PATCH 03/23] [llvm-lit] Resolve env subcommand required error

This patch addresses an issue where calling env without any arguments incorrectly returns
a "requires subcommand" message. The patch modifies the env command to properly display
the current environment variables even when no arguments are provided. Additionally, the
test cases have been updated: instead of returning an error, the tests now pass and check
if the environment variables are output correctly.
---
 llvm/utils/lit/tests/shtest-env.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 61ee9bc7d21ace..7e6ad751a7a3d1 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -121,6 +121,6 @@
 # CHECK: --
 
 # CHECK: Total Discovered Tests: 16
-# CHECK: Passed:  4 {{\([0-9]*\.[0-9]*%\)}}
-# CHECK: Failed: 12 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK: Passed:  9 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK: Failed: 7 {{\([0-9]*\.[0-9]*%\)}}
 # CHECK-NOT: {{.}}

>From 94d958a1cec6dec59a3dfaa4797aa60900eee4b6 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 18 Jul 2024 07:20:00 +0000
Subject: [PATCH 04/23] hi

---
 llvm/utils/lit/lit/TestRunner.py   | 2 +-
 llvm/utils/lit/tests/shtest-env.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da541c6b742a3d..b98e92071508f9 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1,4 +1,4 @@
-from __future__ import absolute_import
+rom __future__ import absolute_import
 import errno
 import io
 import itertools
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 7e6ad751a7a3d1..96284c99fe5a19 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -1,4 +1,4 @@
-# Check the env command
+ Check the env command
 
 # RUN: not %{lit} -a -v %{inputs}/shtest-env \
 # RUN: | FileCheck -match-full-lines %s

>From e359516da66681e2050995e3df2f4318c139d6c2 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 18 Jul 2024 07:21:14 +0000
Subject: [PATCH 05/23] [llvm-lit] Resolve env subcommand required error

This patch addresses an issue where calling env without any arguments incorrectly returns a "requires subcommand" message. The patch modifies the env command to properly display the current environment variables even when no arguments are provided. Additionally, the test cases have been updated: instead of returning an error, the tests now pass and check if the environment variables are output correctly.
---
 llvm/utils/lit/lit/TestRunner.py   | 2 +-
 llvm/utils/lit/tests/shtest-env.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index b98e92071508f9..da541c6b742a3d 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -1,4 +1,4 @@
-rom __future__ import absolute_import
+from __future__ import absolute_import
 import errno
 import io
 import itertools
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 96284c99fe5a19..7e6ad751a7a3d1 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -1,4 +1,4 @@
- Check the env command
+# Check the env command
 
 # RUN: not %{lit} -a -v %{inputs}/shtest-env \
 # RUN: | FileCheck -match-full-lines %s

>From 3a9a91985236b91e9728d980b1fce0332af88f43 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 18 Jul 2024 07:43:16 +0000
Subject: [PATCH 06/23] [llvm-lit] Resolve env subcommand required error

This patch addresses an issue where calling env without any arguments incorrectly
returns a "requires subcommand" message. The patch modifies the env command to
properly display the current environment variables even when no arguments are provided.
Additionally, the test cases have been updated: instead of returning an error, the tests
now pass and check if the environment variables are output correctly.
---
 llvm/utils/lit/lit/TestRunner.py              |  4 +--
 .../tests/Inputs/shtest-env/env-args-none.txt | 31 +----------------
 llvm/utils/lit/tests/shtest-env.py            | 34 +++++++++----------
 3 files changed, 19 insertions(+), 50 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da541c6b742a3d..8f0cd801ae9ff5 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -744,9 +744,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                 args = updateEnv(cmd_shenv, args)
                 if not args:
                     # Return the environment variables if no argument is provided 
-                    env_str = "\n".join(f"{key}={value}" for key, value in cmd_shenv.env.items())
-                    results.append(ShellCommandResult(j, env_str, "", 0 , timeoutHelper.timeoutReached(), []))
-                    return 0
+                    return {key: value for key, value in cmd_shenv.env.items()}
             elif args[0] == "not":
                 not_args.append(args.pop(0))
                 not_count += 1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index 0eb724a2101c34..dc5cdbad09afc9 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -1,30 +1 @@
-# Check Default Environment
-# RUN: env | FileCheck -check-prefix=CHECK-2-EMPTY %s
-#
-# CHECK-2-EMPTY: BAR = 2
-# CHECK-2-EMPTY: FOO = 1
-
-# Set Environment Variables
-# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s
-#
-# CHECK-2-VAL: BAR = 1
-# CHECK-2-VAL: FOO = 2
-
-# Unset Environment Variables
-# RUN: env -u FOO -u BAR | FileCheck -check-prefix=CHECK-2-U %s
-#
-# CHECK-2-U-NOT: BAR
-# CHECK-2-U-NOT: FOO
-
-# Mixed Set and Unset Environment Variables
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s
-#
-# CHECK-2-U-VAL-NOT: BAR
-# CHECK-2-U-VAL: FOO = 2
- 
-# Mixed Set and Unset with Additional Variable
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=CHECK-3 %s
-#
-# CHECK-3-NOT: BAR
-# CHECK-3: BAZ = 3
-# CHECK-3: FOO = 2
+# RUN: env
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 7e6ad751a7a3d1..03bb4a3cae7dd1 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -9,35 +9,35 @@
 
 # CHECK: -- Testing: 16 tests{{.*}}
 
-# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
+# CHECK: FAIL: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
 # CHECK: # executed command: env FOO=1
-# CHECK-NOT: {{^[^#]}} 
-# CHECK: --
+# CHECK: # | Error: 'env' requires a subcommand
+# CHECK: # error: command failed with exit status: {{.*}}
 
-# CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
+# CHECK: FAIL: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
 # CHECK: # executed command: env -u FOO
-# CHECK-NOT: {{^[^#]}} 
-# CHECK: --
+# CHECK: # | Error: 'env' requires a subcommand
+# CHECK: # error: command failed with exit status: {{.*}}
 
-# CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
+# CHECK: FAIL: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
 # CHECK: env -u
 # CHECK: # executed command: env -u
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
+# CHECK: # | Error: 'env' requires a subcommand
+# CHECK: # error: command failed with exit status: {{.*}}
 
-# CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
+# CHECK: FAIL: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
 # CHECK: env env env
 # CHECK: # executed command: env env env
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
+# CHECK: # | Error: 'env' requires a subcommand
+# CHECK: # error: command failed with exit status: {{.*}}
 
-# CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
+# CHECK: FAIL: shtest-env :: env-args-none.txt ({{[^)]*}})
 # CHECK: env
 # CHECK: # executed command: env
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
+# CHECK: # | Error: 'env' requires a subcommand
+# CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 cd foobar
@@ -121,6 +121,6 @@
 # CHECK: --
 
 # CHECK: Total Discovered Tests: 16
-# CHECK: Passed:  9 {{\([0-9]*\.[0-9]*%\)}}
-# CHECK: Failed: 7 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK: Passed:  4 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK: Failed: 12 {{\([0-9]*\.[0-9]*%\)}}
 # CHECK-NOT: {{.}}

>From 4990d398ca41a7d3efd4dc27630962125bbb0d5e Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 18 Jul 2024 07:13:21 +0000
Subject: [PATCH 07/23] [llvm-lit] Resolve env subcommand required error

This patch addresses an issue where calling env without any arguments incorrectly returns
a "requires subcommand" message. The patch modifies the env command to properly display
the current environment variables even when no arguments are provided. Additionally,
the test cases have been updated: instead of returning an error, the tests now pass
and check if the environment variables are output correctly.
---
 llvm/utils/lit/lit/TestRunner.py              |  4 ++-
 .../tests/Inputs/shtest-env/env-args-none.txt | 31 ++++++++++++++++-
 llvm/utils/lit/tests/shtest-env.py            | 34 +++++++++----------
 3 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 8f0cd801ae9ff5..da541c6b742a3d 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -744,7 +744,9 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                 args = updateEnv(cmd_shenv, args)
                 if not args:
                     # Return the environment variables if no argument is provided 
-                    return {key: value for key, value in cmd_shenv.env.items()}
+                    env_str = "\n".join(f"{key}={value}" for key, value in cmd_shenv.env.items())
+                    results.append(ShellCommandResult(j, env_str, "", 0 , timeoutHelper.timeoutReached(), []))
+                    return 0
             elif args[0] == "not":
                 not_args.append(args.pop(0))
                 not_count += 1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index dc5cdbad09afc9..0eb724a2101c34 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -1 +1,30 @@
-# RUN: env
+# Check Default Environment
+# RUN: env | FileCheck -check-prefix=CHECK-2-EMPTY %s
+#
+# CHECK-2-EMPTY: BAR = 2
+# CHECK-2-EMPTY: FOO = 1
+
+# Set Environment Variables
+# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s
+#
+# CHECK-2-VAL: BAR = 1
+# CHECK-2-VAL: FOO = 2
+
+# Unset Environment Variables
+# RUN: env -u FOO -u BAR | FileCheck -check-prefix=CHECK-2-U %s
+#
+# CHECK-2-U-NOT: BAR
+# CHECK-2-U-NOT: FOO
+
+# Mixed Set and Unset Environment Variables
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s
+#
+# CHECK-2-U-VAL-NOT: BAR
+# CHECK-2-U-VAL: FOO = 2
+ 
+# Mixed Set and Unset with Additional Variable
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=CHECK-3 %s
+#
+# CHECK-3-NOT: BAR
+# CHECK-3: BAZ = 3
+# CHECK-3: FOO = 2
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 03bb4a3cae7dd1..7e6ad751a7a3d1 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -9,35 +9,35 @@
 
 # CHECK: -- Testing: 16 tests{{.*}}
 
-# CHECK: FAIL: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
 # CHECK: # executed command: env FOO=1
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}} 
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
 # CHECK: # executed command: env -u FOO
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}} 
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
 # CHECK: env -u
 # CHECK: # executed command: env -u
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}}
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
 # CHECK: env env env
 # CHECK: # executed command: env env env
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}}
+# CHECK: --
 
-# CHECK: FAIL: shtest-env :: env-args-none.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
 # CHECK: env
 # CHECK: # executed command: env
-# CHECK: # | Error: 'env' requires a subcommand
-# CHECK: # error: command failed with exit status: {{.*}}
+# CHECK-NOT: {{^[^#]}}
+# CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 cd foobar
@@ -121,6 +121,6 @@
 # CHECK: --
 
 # CHECK: Total Discovered Tests: 16
-# CHECK: Passed:  4 {{\([0-9]*\.[0-9]*%\)}}
-# CHECK: Failed: 12 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK: Passed:  9 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK: Failed: 7 {{\([0-9]*\.[0-9]*%\)}}
 # CHECK-NOT: {{.}}

>From 37cbf4f0e67af55e610fa2126fbe7bebafcff156 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 24 Jul 2024 01:22:50 +0000
Subject: [PATCH 08/23] [llvm-lit] Using a commit ID that passes all test cases

This will pass the test cases
---
 llvm/utils/lit/lit/TestRunner.py              | 12 +++--
 .../tests/Inputs/shtest-env/env-args-none.txt | 44 +++++++++----------
 2 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da541c6b742a3d..1fb958c428dc9a 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -743,9 +743,15 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                     cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env)
                 args = updateEnv(cmd_shenv, args)
                 if not args:
-                    # Return the environment variables if no argument is provided 
-                    env_str = "\n".join(f"{key}={value}" for key, value in cmd_shenv.env.items())
-                    results.append(ShellCommandResult(j, env_str, "", 0 , timeoutHelper.timeoutReached(), []))
+                    # Return the environment variables if no argument is provided.
+                    env_str = "\n".join(
+                            f"{key}={value}" for key, value in sorted(cmd_shenv.env.items())
+                        )
+                    results.append(
+                        ShellCommandResult(
+                            j, env_str, "", 0, timeoutHelper.timeoutReached(), []
+                        )
+                    )
                     return 0
             elif args[0] == "not":
                 not_args.append(args.pop(0))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index 0eb724a2101c34..2b636158a811fe 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -1,30 +1,30 @@
-# Check Default Environment
-# RUN: env | FileCheck -check-prefix=CHECK-2-EMPTY %s
+# Check default environment.
+# RUN: env | FileCheck -check-prefix=NO-ARGS %s
 #
-# CHECK-2-EMPTY: BAR = 2
-# CHECK-2-EMPTY: FOO = 1
+# NO-ARGS: BAR=2
+# NO-ARGS: FOO=1
 
-# Set Environment Variables
-# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s
+# Set environment variables.
+# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
 #
-# CHECK-2-VAL: BAR = 1
-# CHECK-2-VAL: FOO = 2
+# SET-VAL: BAR=1
+# SET-VAL: FOO=2
 
-# Unset Environment Variables
-# RUN: env -u FOO -u BAR | FileCheck -check-prefix=CHECK-2-U %s
+# Unset environment variables.
+# RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
 #
-# CHECK-2-U-NOT: BAR
-# CHECK-2-U-NOT: FOO
+# UNSET_U-NOT: BAR
+# UNSET-U-NOT: FOO
 
-# Mixed Set and Unset Environment Variables
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s
+# Mixed set and unset environment variables.
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
 #
-# CHECK-2-U-VAL-NOT: BAR
-# CHECK-2-U-VAL: FOO = 2
- 
-# Mixed Set and Unset with Additional Variable
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=CHECK-3 %s
+# MIXED-SET-UNSET-NOT: BAR
+# MIXED-SET-UNSET: FOO=2
+
+# Mixed set and unset with additional variable.
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
 #
-# CHECK-3-NOT: BAR
-# CHECK-3: BAZ = 3
-# CHECK-3: FOO = 2
+# MIXED-SET-UNSET-ADD-NOT: BAR
+# MIXED-SET-UNSET-ADD: BAZ=3
+# MIXED-SET-UNSET-ADD: FOO=2

>From 06d2481667d93a0a5b1f297269989733e0130bab Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 24 Jul 2024 12:10:46 +0000
Subject: [PATCH 09/23] [llvm-lit] Formatting Python files

In my last commit, I attempted to format the Python files using `darker`,
but the changes were not applied correctly. This commit ensures that
`darker` has been properly used to format the code.
---
 llvm/utils/lit/lit/TestRunner.py                         | 4 ++--
 llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt | 8 ++++++--
 llvm/utils/lit/tests/shtest-env.py                       | 4 ++--
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 1fb958c428dc9a..be9339491a782d 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -745,8 +745,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
                 if not args:
                     # Return the environment variables if no argument is provided.
                     env_str = "\n".join(
-                            f"{key}={value}" for key, value in sorted(cmd_shenv.env.items())
-                        )
+                        f"{key}={value}" for key, value in sorted(cmd_shenv.env.items())
+                    )
                     results.append(
                         ShellCommandResult(
                             j, env_str, "", 0, timeoutHelper.timeoutReached(), []
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index 2b636158a811fe..d2a8957478cb32 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -3,28 +3,32 @@
 #
 # NO-ARGS: BAR=2
 # NO-ARGS: FOO=1
+# NO-ARGS: BAZ=3
 
 # Set environment variables.
 # RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
 #
 # SET-VAL: BAR=1
 # SET-VAL: FOO=2
+# SET-VAL: BAZ=3
 
 # Unset environment variables.
 # RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
 #
-# UNSET_U-NOT: BAR
+# UNSET-U-NOT: BAR
 # UNSET-U-NOT: FOO
+# UNSET-U: BAZ=3
 
 # Mixed set and unset environment variables.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
 #
 # MIXED-SET-UNSET-NOT: BAR
 # MIXED-SET-UNSET: FOO=2
+# MIXED-SET-UNSET: BAZ=3
 
 # Mixed set and unset with additional variable.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
 #
 # MIXED-SET-UNSET-ADD-NOT: BAR
-# MIXED-SET-UNSET-ADD: BAZ=3
+# MIXED-SET-UNSET-ADD: BAZ=4
 # MIXED-SET-UNSET-ADD: FOO=2
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 7e6ad751a7a3d1..48378f95bf4d93 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -12,13 +12,13 @@
 # CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
 # CHECK: # executed command: env FOO=1
-# CHECK-NOT: {{^[^#]}} 
+# CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
 # CHECK: # executed command: env -u FOO
-# CHECK-NOT: {{^[^#]}} 
+# CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})

>From 964cc3023770d209266d1927565dbce356aee421 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Tue, 30 Jul 2024 21:21:09 +0000
Subject: [PATCH 10/23] Resolved conflicts and added changes to
 env-args-none.txt, lit.cfg, and shtest-env.py

---
 .../tests/Inputs/shtest-env/env-args-none.txt | 13 +++---
 .../utils/lit/tests/Inputs/shtest-env/lit.cfg |  1 +
 llvm/utils/lit/tests/shtest-env.py            | 46 +++++++++----------
 3 files changed, 31 insertions(+), 29 deletions(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index d2a8957478cb32..755f50a1c926dc 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -1,34 +1,35 @@
-# Check default environment.
+#Check default environment.
 # RUN: env | FileCheck -check-prefix=NO-ARGS %s
 #
 # NO-ARGS: BAR=2
 # NO-ARGS: FOO=1
-# NO-ARGS: BAZ=3
+# NO-ARGS: QUX=3
 
 # Set environment variables.
 # RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
 #
 # SET-VAL: BAR=1
 # SET-VAL: FOO=2
-# SET-VAL: BAZ=3
+# SET-VAL: QUX=3
 
 # Unset environment variables.
 # RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
 #
 # UNSET-U-NOT: BAR
 # UNSET-U-NOT: FOO
-# UNSET-U: BAZ=3
+# UNSET-U: QUX=3
 
 # Mixed set and unset environment variables.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
 #
 # MIXED-SET-UNSET-NOT: BAR
 # MIXED-SET-UNSET: FOO=2
-# MIXED-SET-UNSET: BAZ=3
+# MIXED-SET-UNSET: QUX=3
 
 # Mixed set and unset with additional variable.
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=3 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
 #
 # MIXED-SET-UNSET-ADD-NOT: BAR
 # MIXED-SET-UNSET-ADD: BAZ=4
 # MIXED-SET-UNSET-ADD: FOO=2
+# MIXED-SET-UNSET-ADD: QUX=3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg
index df9df7da81daaf..626c00f71d7287 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg
@@ -7,4 +7,5 @@ config.test_source_root = None
 config.test_exec_root = None
 config.environment["FOO"] = "1"
 config.environment["BAR"] = "2"
+config.environment["QUX"] = "3"
 config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 48378f95bf4d93..8bf7f6ca388300 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -11,112 +11,112 @@
 
 # CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
-# CHECK: # executed command: env FOO=1
+# CHECK-NEXT: # executed command: env FOO=1
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
-# CHECK: # executed command: env -u FOO
+# CHECK-NEXT: # executed command: env -u FOO
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
 # CHECK: env -u
-# CHECK: # executed command: env -u
+# CHECK-NEXT: # executed command: env -u
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
 # CHECK: env env env
-# CHECK: # executed command: env env env
+# CHECK-NEXT: # executed command: env env env
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
 # CHECK: env
-# CHECK: # executed command: env
+# CHECK-NEXT: # executed command: env
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 cd foobar
-# CHECK: # executed command: env -u FOO BAR=3 cd foobar
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 cd foobar
 # CHECK: # | Error: 'env' cannot call 'cd'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 :
-# CHECK: # executed command: env -u FOO BAR=3 :
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 :
 # CHECK: # | Error: 'env' cannot call ':'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 echo hello world
-# CHECK: # executed command: env -u FOO BAR=3 echo hello world
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 echo hello world
 # CHECK: # | Error: 'env' cannot call 'echo'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
 # CHECK: env env [[PYTHON:.+]] print_environment.py | {{.*}}
-# CHECK: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
+# CHECK-NEXT: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
 # CHECK: env FOO=2 env BAR=1 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env FOO=2 env BAR=1 [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env FOO=2 env BAR=1 [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO env -u BAR [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO env -u BAR [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env -u FOO env -u BAR [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 export BAZ=3
-# CHECK: # executed command: env -u FOO BAR=3 export BAZ=3
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 export BAZ=3
 # CHECK: # | Error: 'env' cannot call 'export'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 mkdir foobar
-# CHECK: # executed command: env -u FOO BAR=3 mkdir foobar
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 mkdir foobar
 # CHECK: # | Error: 'env' cannot call 'mkdir'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 not rm {{.+}}.no-such-file
-# CHECK: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}}
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}}
 # CHECK: # | Error: 'env' cannot call 'rm'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 rm foobar
-# CHECK: # executed command: env -u FOO BAR=3 rm foobar
+# CHECK-NEXT: # executed command: env -u FOO BAR=3 rm foobar
 # CHECK: # | Error: 'env' cannot call 'rm'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
 # CHECK: [[PYTHON]] print_environment.py | {{.*}}
 # CHECK: env -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env -u FOO [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO -u BAR [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO -u BAR [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env -u FOO -u BAR [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
 # CHECK: env A_FOO=999 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=999 [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env A_FOO=999 [[PYTHON_BARE]] print_environment.py
 # CHECK: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
 # CHECK: env A_FOO=999 -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE]] print_environment.py
 # CHECK: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON_BARE]] print_environment.py
+# CHECK-NEXT: # executed command: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 

>From d6a37da0535f326d27adfdd3d277bc0a4257d133 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Tue, 30 Jul 2024 23:04:35 +0000
Subject: [PATCH 11/23] [llvm-lit] Add pattern to CHECK lines for env command

Added '| {{.*}}' to ensure proper matching for env command output.
---
 llvm/utils/lit/tests/shtest-env.py | 54 +++++++++++++++---------------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 8bf7f6ca388300..b8e7d714a78cb8 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -11,112 +11,112 @@
 
 # CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
-# CHECK-NEXT: # executed command: env FOO=1
-# CHECK-NOT: {{^[^#]}}
+# CHECK: # executed command: env FOO=1
+# CHECK-NOT: {{^[^#]}} 
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
-# CHECK-NEXT: # executed command: env -u FOO
-# CHECK-NOT: {{^[^#]}}
+# CHECK: # executed command: env -u FOO
+# CHECK-NOT: {{^[^#]}} 
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
 # CHECK: env -u
-# CHECK-NEXT: # executed command: env -u
+# CHECK: # executed command: env -u
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
 # CHECK: env env env
-# CHECK-NEXT: # executed command: env env env
+# CHECK: # executed command: env env env
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
-# CHECK: env
-# CHECK-NEXT: # executed command: env
-# CHECK-NOT: {{^[^#]}}
+# CHECK: env | {{.*}}
+# CHECK: # executed command: env
+# CHECK-NOT: {{^[^#]}} | {{.*}}
 # CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 cd foobar
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 cd foobar
+# CHECK: # executed command: env -u FOO BAR=3 cd foobar
 # CHECK: # | Error: 'env' cannot call 'cd'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 :
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 :
+# CHECK: # executed command: env -u FOO BAR=3 :
 # CHECK: # | Error: 'env' cannot call ':'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 echo hello world
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 echo hello world
+# CHECK: # executed command: env -u FOO BAR=3 echo hello world
 # CHECK: # | Error: 'env' cannot call 'echo'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
 # CHECK: env env [[PYTHON:.+]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
+# CHECK: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
 # CHECK: env FOO=2 env BAR=1 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env FOO=2 env BAR=1 [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env FOO=2 env BAR=1 [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO env -u BAR [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env -u FOO env -u BAR [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env -u FOO env -u BAR [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 export BAZ=3
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 export BAZ=3
+# CHECK: # executed command: env -u FOO BAR=3 export BAZ=3
 # CHECK: # | Error: 'env' cannot call 'export'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 mkdir foobar
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 mkdir foobar
+# CHECK: # executed command: env -u FOO BAR=3 mkdir foobar
 # CHECK: # | Error: 'env' cannot call 'mkdir'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 not rm {{.+}}.no-such-file
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}}
+# CHECK: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}}
 # CHECK: # | Error: 'env' cannot call 'rm'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
 # CHECK: env -u FOO BAR=3 rm foobar
-# CHECK-NEXT: # executed command: env -u FOO BAR=3 rm foobar
+# CHECK: # executed command: env -u FOO BAR=3 rm foobar
 # CHECK: # | Error: 'env' cannot call 'rm'
 # CHECK: # error: command failed with exit status: {{.*}}
 
 # CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
 # CHECK: [[PYTHON]] print_environment.py | {{.*}}
 # CHECK: env -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env -u FOO [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env -u FOO [[PYTHON_BARE]] print_environment.py
 # CHECK: env -u FOO -u BAR [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env -u FOO -u BAR [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env -u FOO -u BAR [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
 # CHECK: env A_FOO=999 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env A_FOO=999 [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env A_FOO=999 [[PYTHON_BARE]] print_environment.py
 # CHECK: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
 # CHECK: env A_FOO=999 -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE]] print_environment.py
 # CHECK: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK-NEXT: # executed command: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON_BARE]] print_environment.py
+# CHECK: # executed command: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON_BARE]] print_environment.py
 # CHECK-NOT: {{^[^#]}}
 # CHECK: --
 

>From ac03f43b6ec7128c7497ccc2eab6fc7cd84b9a72 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 31 Jul 2024 05:54:37 +0000
Subject: [PATCH 12/23] [llvm-lit] Used darker to format the python files

Used darker to format the llvm/utils/lit/tests/shtest-env.py file.
---
 llvm/utils/lit/tests/shtest-env.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index b8e7d714a78cb8..86821d71e90c7d 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -12,13 +12,13 @@
 # CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
 # CHECK: # executed command: env FOO=1
-# CHECK-NOT: {{^[^#]}} 
+# CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
 # CHECK: # executed command: env -u FOO
-# CHECK-NOT: {{^[^#]}} 
+# CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})

>From 4fe54d440e1ff94ef70c4a5ff211a2dda967d5d9 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 5 Aug 2024 09:29:39 +0000
Subject: [PATCH 13/23] [llvm-lit] Added a space in env-args-none.txt

Reverted back to # Check default environment.
---
 llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
index 755f50a1c926dc..ffea70bc61f329 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
@@ -1,4 +1,4 @@
-#Check default environment.
+# Check default environment.
 # RUN: env | FileCheck -check-prefix=NO-ARGS %s
 #
 # NO-ARGS: BAR=2

>From fcec36128a54b325612acfc0d37504a9496f695e Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 5 Aug 2024 17:35:07 +0000
Subject: [PATCH 14/23] [llvm-lit] Updated shtest-env.py for Consistent Output
 Checking

Reformatted test checks in env-args-none.txt to stay consistent with
existing passing tests.
---
 llvm/utils/lit/tests/shtest-env.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 86821d71e90c7d..9f5f39d7a2968b 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -36,7 +36,15 @@
 # CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
 # CHECK: env | {{.*}}
 # CHECK: # executed command: env
-# CHECK-NOT: {{^[^#]}} | {{.*}}
+# CHECK: env FOO=2 BAR=1 | {{.*}}
+# CHECK: # executed command: env FOO=2 BAR=1
+# CHECK: env -u FOO -u BAR | {{.*}}
+# CHECK: # executed command: env -u FOO -u BAR
+# CHECK: env -u FOO BAR=1 -u BAR FOO=2 | {{.*}}
+# CHECK: # executed command: env -u FOO BAR=1 -u BAR FOO=2
+# CHECK: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | {{.*}}
+# CHECK: # executed command: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4
+# CHECK-NOT: {{^[^#]}}
 # CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})

>From 957c7a6d721ff7a0c2501b2e593561c7c2725fea Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 7 Aug 2024 17:18:14 +0000
Subject: [PATCH 15/23] [llvm-lit] Modified `CHECK-NOT: {{^[^#]}}`

Updated test cases to use `CHECK-NOT: # error`.
---
 llvm/utils/lit/tests/shtest-env.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
index 9f5f39d7a2968b..fa9e69a231b96a 100644
--- a/llvm/utils/lit/tests/shtest-env.py
+++ b/llvm/utils/lit/tests/shtest-env.py
@@ -12,25 +12,25 @@
 # CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
 # CHECK: env FOO=1
 # CHECK: # executed command: env FOO=1
-# CHECK-NOT: {{^[^#]}}
+# CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
 # CHECK: env -u FOO
 # CHECK: # executed command: env -u FOO
-# CHECK-NOT: {{^[^#]}}
+# CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
 # CHECK: env -u
 # CHECK: # executed command: env -u
-# CHECK-NOT: {{^[^#]}}
+# CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
 # CHECK: env env env
 # CHECK: # executed command: env env env
-# CHECK-NOT: {{^[^#]}}
+# CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
@@ -44,7 +44,7 @@
 # CHECK: # executed command: env -u FOO BAR=1 -u BAR FOO=2
 # CHECK: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | {{.*}}
 # CHECK: # executed command: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4
-# CHECK-NOT: {{^[^#]}}
+# CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})

>From b18939ed4b41af4e6709e9be0843b28fd226dd53 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 12 Aug 2024 19:21:58 +0000
Subject: [PATCH 16/23] [llvm-lit] Split shtest-env tests into separate
 positive and negative test files

Created `shtest-env-positive.py` for positive tests, removing `not` from the RUN
line and using `CHECK-NOT: # error:` to ensure no errors occur. Created `shtest-env-negative.py`
for negative tests, keeping `not` in the RUN line and using `CHECK: # error: command failed with
exit status: {{.*}}` to verify expected failures. Split `tests/Inputs/shtest-env` into
`tests/Inputs/shtest-env-positive` and `tests/Inputs/shtest-env-negative`, organizing
the respective passing and failing tests into their appropriate directories.
---
 .../shtest-env-negative/env-calls-cd.txt      |  1 +
 .../shtest-env-negative/env-calls-colon.txt   |  1 +
 .../shtest-env-negative/env-calls-echo.txt    |  1 +
 .../shtest-env-negative/env-calls-export.txt  |  1 +
 .../shtest-env-negative/env-calls-mkdir.txt   |  1 +
 .../env-calls-not-builtin.txt                 |  4 ++
 .../shtest-env-negative/env-calls-rm.txt      |  1 +
 .../tests/Inputs/shtest-env-negative/lit.cfg  | 11 +++
 .../shtest-env-negative/print_environment.py  |  9 +++
 .../env-args-last-is-assign.txt               |  1 +
 .../env-args-last-is-u-arg.txt                |  1 +
 .../env-args-last-is-u.txt                    |  1 +
 .../env-args-nested-none.txt                  |  1 +
 .../shtest-env-positive/env-args-none.txt     | 35 ++++++++++
 .../shtest-env-positive/env-calls-env.txt     | 32 +++++++++
 .../Inputs/shtest-env-positive/env-u.txt      | 23 +++++++
 .../tests/Inputs/shtest-env-positive/env.txt  | 15 ++++
 .../tests/Inputs/shtest-env-positive/lit.cfg  | 11 +++
 .../Inputs/shtest-env-positive/mixed.txt      | 18 +++++
 .../shtest-env-positive/print_environment.py  |  9 +++
 llvm/utils/lit/tests/shtest-env-negative.py   | 49 +++++++++++++
 llvm/utils/lit/tests/shtest-env-positive.py   | 69 +++++++++++++++++++
 22 files changed, 295 insertions(+)
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-cd.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-colon.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-echo.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-export.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-mkdir.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-not-builtin.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-rm.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/lit.cfg
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-assign.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u-arg.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-nested-none.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/lit.cfg
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
 create mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py
 create mode 100644 llvm/utils/lit/tests/shtest-env-negative.py
 create mode 100644 llvm/utils/lit/tests/shtest-env-positive.py

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-cd.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-cd.txt
new file mode 100644
index 00000000000000..b045506ba31b7f
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-cd.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO BAR=3 cd foobar
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-colon.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-colon.txt
new file mode 100644
index 00000000000000..f2566c43b2d203
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-colon.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO BAR=3 :
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-echo.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-echo.txt
new file mode 100644
index 00000000000000..b4591ee5f231ac
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-echo.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO BAR=3 echo hello world
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-export.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-export.txt
new file mode 100644
index 00000000000000..9712e42f202591
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-export.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO BAR=3 export BAZ=3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-mkdir.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-mkdir.txt
new file mode 100644
index 00000000000000..6116a25c94f3d2
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-mkdir.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO BAR=3 mkdir foobar
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-not-builtin.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-not-builtin.txt
new file mode 100644
index 00000000000000..b8aa57120b8899
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-not-builtin.txt
@@ -0,0 +1,4 @@
+# Other tests thoroughly check that 'env' cannot call various builtin commands.
+# Pick one and make sure it fails even if there's a 'not' in the way.
+
+# RUN: env -u FOO BAR=3 not rm %t.no-such-file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-rm.txt b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-rm.txt
new file mode 100644
index 00000000000000..6c5e8e873914fe
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/env-calls-rm.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO BAR=3 rm foobar
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-env-negative/lit.cfg
new file mode 100644
index 00000000000000..626c00f71d7287
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/lit.cfg
@@ -0,0 +1,11 @@
+import lit.formats
+
+config.name = "shtest-env"
+config.suffixes = [".txt"]
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+config.environment["FOO"] = "1"
+config.environment["BAR"] = "2"
+config.environment["QUX"] = "3"
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py b/llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py
new file mode 100644
index 00000000000000..e39bd73e44a108
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import os
+
+sorted_environment = sorted(os.environ.items())
+
+for name, value in sorted_environment:
+    print(name, "=", value)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-assign.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-assign.txt
new file mode 100644
index 00000000000000..837210f0196ed3
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-assign.txt
@@ -0,0 +1 @@
+# RUN: env FOO=1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u-arg.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u-arg.txt
new file mode 100644
index 00000000000000..27c81db8ed5d19
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u-arg.txt
@@ -0,0 +1 @@
+# RUN: env -u FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u.txt
new file mode 100644
index 00000000000000..29134ac2e29a98
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-last-is-u.txt
@@ -0,0 +1 @@
+# RUN: env -u
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-nested-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-nested-none.txt
new file mode 100644
index 00000000000000..262c749bc65394
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-nested-none.txt
@@ -0,0 +1 @@
+# RUN: env env env
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
new file mode 100644
index 00000000000000..ffea70bc61f329
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
@@ -0,0 +1,35 @@
+# Check default environment.
+# RUN: env | FileCheck -check-prefix=NO-ARGS %s
+#
+# NO-ARGS: BAR=2
+# NO-ARGS: FOO=1
+# NO-ARGS: QUX=3
+
+# Set environment variables.
+# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
+#
+# SET-VAL: BAR=1
+# SET-VAL: FOO=2
+# SET-VAL: QUX=3
+
+# Unset environment variables.
+# RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
+#
+# UNSET-U-NOT: BAR
+# UNSET-U-NOT: FOO
+# UNSET-U: QUX=3
+
+# Mixed set and unset environment variables.
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
+#
+# MIXED-SET-UNSET-NOT: BAR
+# MIXED-SET-UNSET: FOO=2
+# MIXED-SET-UNSET: QUX=3
+
+# Mixed set and unset with additional variable.
+# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
+#
+# MIXED-SET-UNSET-ADD-NOT: BAR
+# MIXED-SET-UNSET-ADD: BAZ=4
+# MIXED-SET-UNSET-ADD: FOO=2
+# MIXED-SET-UNSET-ADD: QUX=3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
new file mode 100644
index 00000000000000..26150c413dc03d
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
@@ -0,0 +1,32 @@
+# Check that internal env can call internal env.
+
+# RUN: env env %{python} print_environment.py \
+# RUN: | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s
+#
+# CHECK-2-EMPTY-ARGS: BAR = 2
+# CHECK-2-EMPTY-ARGS: FOO = 1
+
+# RUN: env FOO=2 env BAR=1 %{python} print_environment.py \
+# RUN: | FileCheck -check-prefix=CHECK-2-VAL %s
+#
+# CHECK-2-VAL: BAR = 1
+# CHECK-2-VAL: FOO = 2
+
+# RUN: env -u FOO env -u BAR %{python} print_environment.py \
+# RUN: | FileCheck -check-prefix=CHECK-2-U %s
+#
+# CHECK-2-U-NOT: BAR
+# CHECK-2-U-NOT: FOO
+
+# RUN: env -u FOO BAR=1 env -u BAR FOO=2 %{python} print_environment.py \
+# RUN: | FileCheck -check-prefix=CHECK-2-U-VAL %s
+#
+# CHECK-2-U-VAL-NOT: BAR
+# CHECK-2-U-VAL: FOO = 2
+
+# RUN: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 %{python} print_environment.py \
+# RUN: | FileCheck -check-prefix=CHECK-3 %s
+#
+# CHECK-3-NOT: BAR
+# CHECK-3: BAZ = 3
+# CHECK-3: FOO = 2
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
new file mode 100644
index 00000000000000..9cdf9d08850f78
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
@@ -0,0 +1,23 @@
+# Check and make sure preset environment variable were set in lit.cfg
+#
+# RUN: %{python} print_environment.py \
+# RUN:   | FileCheck --check-prefix=CHECK-ENV-PRESET %s
+#
+# Check single unset of environment variable
+#
+# RUN: env -u FOO %{python} print_environment.py \
+# RUN:  | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s
+#
+# Check multiple unsets of environment variables
+#
+# RUN: env -u FOO -u BAR %{python} print_environment.py \
+# RUN:  | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s
+
+# CHECK-ENV-PRESET: BAR = 2
+# CHECK-ENV-PRESET: FOO = 1
+
+# CHECK-ENV-UNSET-1: BAR = 2
+# CHECK-ENV-UNSET-1-NOT: FOO
+
+# CHECK-ENV-UNSET-MULTIPLE-NOT: BAR
+# CHECK-ENV-UNSET-MULTIPLE-NOT: FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
new file mode 100644
index 00000000000000..aa697b0c4081f4
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
@@ -0,0 +1,15 @@
+# Check for simple one environment variable setting
+#
+# RUN: env A_FOO=999 %{python} print_environment.py \
+# RUN:   | FileCheck --check-prefix=CHECK-ENV-1 %s
+#
+# Check for multiple environment variable settings
+#
+# RUN: env A_FOO=1 B_BAR=2 C_OOF=3 %{python} print_environment.py \
+# RUN:   | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
+
+# CHECK-ENV-1: A_FOO = 999
+
+# CHECK-ENV-MULTIPLE: A_FOO = 1
+# CHECK-ENV-MULTIPLE: B_BAR = 2
+# CHECK-ENV-MULTIPLE: C_OOF = 3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-env-positive/lit.cfg
new file mode 100644
index 00000000000000..626c00f71d7287
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/lit.cfg
@@ -0,0 +1,11 @@
+import lit.formats
+
+config.name = "shtest-env"
+config.suffixes = [".txt"]
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+config.environment["FOO"] = "1"
+config.environment["BAR"] = "2"
+config.environment["QUX"] = "3"
+config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
new file mode 100644
index 00000000000000..be32d458843bc3
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
@@ -0,0 +1,18 @@
+# Check for setting and removing one environment variable
+#
+# RUN: env A_FOO=999 -u FOO %{python} print_environment.py \
+# RUN:   | FileCheck --check-prefix=CHECK-ENV-1 %s
+#
+# Check for setting/unsetting multiple environment variables
+#
+# RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 %{python} print_environment.py \
+# RUN:   | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
+
+# CHECK-ENV-1: A_FOO = 999
+# CHECK-ENV-1-NOT: FOO
+
+# CHECK-ENV-MULTIPLE: A_FOO = 1
+# CHECK-ENV-MULTIPLE-NOT: BAR
+# CHECK-ENV-MULTIPLE: B_BAR = 2
+# CHECK-ENV-MULTIPLE: C_OOF = 3
+# CHECK-ENV-MULTIPLE-NOT: FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py b/llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py
new file mode 100644
index 00000000000000..e39bd73e44a108
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+from __future__ import print_function
+import os
+
+sorted_environment = sorted(os.environ.items())
+
+for name, value in sorted_environment:
+    print(name, "=", value)
diff --git a/llvm/utils/lit/tests/shtest-env-negative.py b/llvm/utils/lit/tests/shtest-env-negative.py
new file mode 100644
index 00000000000000..07776547e07502
--- /dev/null
+++ b/llvm/utils/lit/tests/shtest-env-negative.py
@@ -0,0 +1,49 @@
+# Check the env command (failing tests)
+
+# RUN: not %{lit} -a -v %{inputs}/shtest-env-negative \
+# RUN: | FileCheck -match-full-lines %s
+#
+# END.
+
+# Check the env command's expected failures.
+
+# CHECK: -- Testing: 7 tests{{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 cd foobar
+# CHECK: # executed command: env -u FOO BAR=3 cd foobar
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 :
+# CHECK: # executed command: env -u FOO BAR=3 :
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 echo hello world
+# CHECK: # executed command: env -u FOO BAR=3 echo hello world
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 export BAZ=3
+# CHECK: # executed command: env -u FOO BAR=3 export BAZ=3
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 mkdir foobar
+# CHECK: # executed command: env -u FOO BAR=3 mkdir foobar
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 not rm {{.+}}.no-such-file
+# CHECK: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}}
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
+# CHECK: env -u FOO BAR=3 rm foobar
+# CHECK: # executed command: env -u FOO BAR=3 rm foobar
+# CHECK: # error: command failed with exit status: {{.*}}
+
+# CHECK: Total Discovered Tests: 7
+# CHECK: Failed: 7 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK-NOT: {{.}}
diff --git a/llvm/utils/lit/tests/shtest-env-positive.py b/llvm/utils/lit/tests/shtest-env-positive.py
new file mode 100644
index 00000000000000..36b93c41de98c0
--- /dev/null
+++ b/llvm/utils/lit/tests/shtest-env-positive.py
@@ -0,0 +1,69 @@
+# Check the env command (passing tests)
+
+# RUN: %{lit} -a -v %{inputs}/shtest-env-positive \
+# RUN: | FileCheck -match-full-lines %s
+#
+# END.
+
+# Check the env command's successful executions.
+
+# CHECK: -- Testing: 9 tests{{.*}}
+
+# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
+# CHECK: env FOO=1
+# CHECK: # executed command: env FOO=1
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
+# CHECK: env -u FOO
+# CHECK: # executed command: env -u FOO
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
+# CHECK: env -u
+# CHECK: # executed command: env -u
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
+# CHECK: env env env
+# CHECK: # executed command: env env env
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
+# CHECK: env | {{.*}}
+# CHECK: # executed command: env
+# CHECK: env FOO=2 BAR=1 | {{.*}}
+# CHECK: # executed command: env FOO=2 BAR=1
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
+# CHECK: env env [[PYTHON:.+]] print_environment.py | {{.*}}
+# CHECK: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
+# CHECK: env -u FOO [[PYTHON]] print_environment.py | {{.*}}
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
+# CHECK: env A_FOO=999 [[PYTHON]] print_environment.py | {{.*}}
+# CHECK: # executed command: env A_FOO=999 [[PYTHON_BARE:.+]] print_environment.py
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
+# CHECK: env A_FOO=999 -u FOO [[PYTHON]] print_environment.py | {{.*}}
+# CHECK: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE:.+]] print_environment.py
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: Total Discovered Tests: 9
+# CHECK: Passed: 9 {{\([0-9]*\.[0-9]*%\)}}
+# CHECK-NOT: {{.}}

>From 8c0168ac45a1a3f902fd7a57c2c2edef4cf14bb9 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 12 Aug 2024 19:33:27 +0000
Subject: [PATCH 17/23] [llvm-lit] Remove shtest-env files after restructuring

As part of the recent restructuring, the `shtest-env` directory
has been split into separate `shtest-env-positive` and
`shtest-env-negative` directories to better organize the
test cases. This commit removes the now obsolete files
from the original `shtest-env` directory that have been
migrated to the new structure.
---
 .../shtest-env/env-args-last-is-assign.txt    |   1 -
 .../shtest-env/env-args-last-is-u-arg.txt     |   1 -
 .../Inputs/shtest-env/env-args-last-is-u.txt  |   1 -
 .../shtest-env/env-args-nested-none.txt       |   1 -
 .../tests/Inputs/shtest-env/env-args-none.txt |  35 -----
 .../tests/Inputs/shtest-env/env-calls-cd.txt  |   1 -
 .../Inputs/shtest-env/env-calls-colon.txt     |   1 -
 .../Inputs/shtest-env/env-calls-echo.txt      |   1 -
 .../tests/Inputs/shtest-env/env-calls-env.txt |  32 -----
 .../Inputs/shtest-env/env-calls-export.txt    |   1 -
 .../Inputs/shtest-env/env-calls-mkdir.txt     |   1 -
 .../shtest-env/env-calls-not-builtin.txt      |   4 -
 .../tests/Inputs/shtest-env/env-calls-rm.txt  |   1 -
 .../lit/tests/Inputs/shtest-env/env-u.txt     |  23 ---
 .../utils/lit/tests/Inputs/shtest-env/env.txt |  15 --
 .../utils/lit/tests/Inputs/shtest-env/lit.cfg |  11 --
 .../lit/tests/Inputs/shtest-env/mixed.txt     |  18 ---
 .../Inputs/shtest-env/print_environment.py    |   9 --
 llvm/utils/lit/tests/shtest-env.py            | 134 ------------------
 19 files changed, 291 deletions(-)
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-assign.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u-arg.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-args-nested-none.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-cd.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-colon.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-echo.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-env.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-export.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-mkdir.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-not-builtin.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-calls-rm.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env-u.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/env.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/mixed.txt
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env/print_environment.py
 delete mode 100644 llvm/utils/lit/tests/shtest-env.py

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-assign.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-assign.txt
deleted file mode 100644
index 837210f0196ed3..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-assign.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env FOO=1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u-arg.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u-arg.txt
deleted file mode 100644
index 27c81db8ed5d19..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u-arg.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u.txt
deleted file mode 100644
index 29134ac2e29a98..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-last-is-u.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-nested-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-nested-none.txt
deleted file mode 100644
index 262c749bc65394..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-nested-none.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env env env
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
deleted file mode 100644
index ffea70bc61f329..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-args-none.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Check default environment.
-# RUN: env | FileCheck -check-prefix=NO-ARGS %s
-#
-# NO-ARGS: BAR=2
-# NO-ARGS: FOO=1
-# NO-ARGS: QUX=3
-
-# Set environment variables.
-# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
-#
-# SET-VAL: BAR=1
-# SET-VAL: FOO=2
-# SET-VAL: QUX=3
-
-# Unset environment variables.
-# RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
-#
-# UNSET-U-NOT: BAR
-# UNSET-U-NOT: FOO
-# UNSET-U: QUX=3
-
-# Mixed set and unset environment variables.
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
-#
-# MIXED-SET-UNSET-NOT: BAR
-# MIXED-SET-UNSET: FOO=2
-# MIXED-SET-UNSET: QUX=3
-
-# Mixed set and unset with additional variable.
-# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
-#
-# MIXED-SET-UNSET-ADD-NOT: BAR
-# MIXED-SET-UNSET-ADD: BAZ=4
-# MIXED-SET-UNSET-ADD: FOO=2
-# MIXED-SET-UNSET-ADD: QUX=3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-cd.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-cd.txt
deleted file mode 100644
index b045506ba31b7f..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-cd.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO BAR=3 cd foobar
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-colon.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-colon.txt
deleted file mode 100644
index f2566c43b2d203..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-colon.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO BAR=3 :
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-echo.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-echo.txt
deleted file mode 100644
index b4591ee5f231ac..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-echo.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO BAR=3 echo hello world
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-env.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-env.txt
deleted file mode 100644
index 26150c413dc03d..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-env.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Check that internal env can call internal env.
-
-# RUN: env env %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s
-#
-# CHECK-2-EMPTY-ARGS: BAR = 2
-# CHECK-2-EMPTY-ARGS: FOO = 1
-
-# RUN: env FOO=2 env BAR=1 %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-VAL %s
-#
-# CHECK-2-VAL: BAR = 1
-# CHECK-2-VAL: FOO = 2
-
-# RUN: env -u FOO env -u BAR %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-U %s
-#
-# CHECK-2-U-NOT: BAR
-# CHECK-2-U-NOT: FOO
-
-# RUN: env -u FOO BAR=1 env -u BAR FOO=2 %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-U-VAL %s
-#
-# CHECK-2-U-VAL-NOT: BAR
-# CHECK-2-U-VAL: FOO = 2
-
-# RUN: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-3 %s
-#
-# CHECK-3-NOT: BAR
-# CHECK-3: BAZ = 3
-# CHECK-3: FOO = 2
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-export.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-export.txt
deleted file mode 100644
index 9712e42f202591..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-export.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO BAR=3 export BAZ=3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-mkdir.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-mkdir.txt
deleted file mode 100644
index 6116a25c94f3d2..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-mkdir.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO BAR=3 mkdir foobar
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-not-builtin.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-not-builtin.txt
deleted file mode 100644
index b8aa57120b8899..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-not-builtin.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Other tests thoroughly check that 'env' cannot call various builtin commands.
-# Pick one and make sure it fails even if there's a 'not' in the way.
-
-# RUN: env -u FOO BAR=3 not rm %t.no-such-file
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-rm.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-rm.txt
deleted file mode 100644
index 6c5e8e873914fe..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-calls-rm.txt
+++ /dev/null
@@ -1 +0,0 @@
-# RUN: env -u FOO BAR=3 rm foobar
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env-u.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env-u.txt
deleted file mode 100644
index 9cdf9d08850f78..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env-u.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Check and make sure preset environment variable were set in lit.cfg
-#
-# RUN: %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-PRESET %s
-#
-# Check single unset of environment variable
-#
-# RUN: env -u FOO %{python} print_environment.py \
-# RUN:  | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s
-#
-# Check multiple unsets of environment variables
-#
-# RUN: env -u FOO -u BAR %{python} print_environment.py \
-# RUN:  | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s
-
-# CHECK-ENV-PRESET: BAR = 2
-# CHECK-ENV-PRESET: FOO = 1
-
-# CHECK-ENV-UNSET-1: BAR = 2
-# CHECK-ENV-UNSET-1-NOT: FOO
-
-# CHECK-ENV-UNSET-MULTIPLE-NOT: BAR
-# CHECK-ENV-UNSET-MULTIPLE-NOT: FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/env.txt b/llvm/utils/lit/tests/Inputs/shtest-env/env.txt
deleted file mode 100644
index aa697b0c4081f4..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/env.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-# Check for simple one environment variable setting
-#
-# RUN: env A_FOO=999 %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-1 %s
-#
-# Check for multiple environment variable settings
-#
-# RUN: env A_FOO=1 B_BAR=2 C_OOF=3 %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
-
-# CHECK-ENV-1: A_FOO = 999
-
-# CHECK-ENV-MULTIPLE: A_FOO = 1
-# CHECK-ENV-MULTIPLE: B_BAR = 2
-# CHECK-ENV-MULTIPLE: C_OOF = 3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg b/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg
deleted file mode 100644
index 626c00f71d7287..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/lit.cfg
+++ /dev/null
@@ -1,11 +0,0 @@
-import lit.formats
-
-config.name = "shtest-env"
-config.suffixes = [".txt"]
-config.test_format = lit.formats.ShTest()
-config.test_source_root = None
-config.test_exec_root = None
-config.environment["FOO"] = "1"
-config.environment["BAR"] = "2"
-config.environment["QUX"] = "3"
-config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/mixed.txt b/llvm/utils/lit/tests/Inputs/shtest-env/mixed.txt
deleted file mode 100644
index be32d458843bc3..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/mixed.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-# Check for setting and removing one environment variable
-#
-# RUN: env A_FOO=999 -u FOO %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-1 %s
-#
-# Check for setting/unsetting multiple environment variables
-#
-# RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
-
-# CHECK-ENV-1: A_FOO = 999
-# CHECK-ENV-1-NOT: FOO
-
-# CHECK-ENV-MULTIPLE: A_FOO = 1
-# CHECK-ENV-MULTIPLE-NOT: BAR
-# CHECK-ENV-MULTIPLE: B_BAR = 2
-# CHECK-ENV-MULTIPLE: C_OOF = 3
-# CHECK-ENV-MULTIPLE-NOT: FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env/print_environment.py b/llvm/utils/lit/tests/Inputs/shtest-env/print_environment.py
deleted file mode 100644
index e39bd73e44a108..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env/print_environment.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-import os
-
-sorted_environment = sorted(os.environ.items())
-
-for name, value in sorted_environment:
-    print(name, "=", value)
diff --git a/llvm/utils/lit/tests/shtest-env.py b/llvm/utils/lit/tests/shtest-env.py
deleted file mode 100644
index fa9e69a231b96a..00000000000000
--- a/llvm/utils/lit/tests/shtest-env.py
+++ /dev/null
@@ -1,134 +0,0 @@
-# Check the env command
-
-# RUN: not %{lit} -a -v %{inputs}/shtest-env \
-# RUN: | FileCheck -match-full-lines %s
-#
-# END.
-
-# Make sure env commands are included in printed commands.
-
-# CHECK: -- Testing: 16 tests{{.*}}
-
-# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
-# CHECK: env FOO=1
-# CHECK: # executed command: env FOO=1
-# CHECK-NOT: # error:
-# CHECK: --
-
-# CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
-# CHECK: env -u FOO
-# CHECK: # executed command: env -u FOO
-# CHECK-NOT: # error:
-# CHECK: --
-
-# CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
-# CHECK: env -u
-# CHECK: # executed command: env -u
-# CHECK-NOT: # error:
-# CHECK: --
-
-# CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
-# CHECK: env env env
-# CHECK: # executed command: env env env
-# CHECK-NOT: # error:
-# CHECK: --
-
-# CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
-# CHECK: env | {{.*}}
-# CHECK: # executed command: env
-# CHECK: env FOO=2 BAR=1 | {{.*}}
-# CHECK: # executed command: env FOO=2 BAR=1
-# CHECK: env -u FOO -u BAR | {{.*}}
-# CHECK: # executed command: env -u FOO -u BAR
-# CHECK: env -u FOO BAR=1 -u BAR FOO=2 | {{.*}}
-# CHECK: # executed command: env -u FOO BAR=1 -u BAR FOO=2
-# CHECK: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | {{.*}}
-# CHECK: # executed command: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4
-# CHECK-NOT: # error:
-# CHECK: --
-
-# CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 cd foobar
-# CHECK: # executed command: env -u FOO BAR=3 cd foobar
-# CHECK: # | Error: 'env' cannot call 'cd'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 :
-# CHECK: # executed command: env -u FOO BAR=3 :
-# CHECK: # | Error: 'env' cannot call ':'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 echo hello world
-# CHECK: # executed command: env -u FOO BAR=3 echo hello world
-# CHECK: # | Error: 'env' cannot call 'echo'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
-# CHECK: env env [[PYTHON:.+]] print_environment.py | {{.*}}
-# CHECK: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
-# CHECK: env FOO=2 env BAR=1 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env FOO=2 env BAR=1 [[PYTHON_BARE]] print_environment.py
-# CHECK: env -u FOO env -u BAR [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO env -u BAR [[PYTHON_BARE]] print_environment.py
-# CHECK: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON_BARE]] print_environment.py
-# CHECK: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON_BARE]] print_environment.py
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
-
-# CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 export BAZ=3
-# CHECK: # executed command: env -u FOO BAR=3 export BAZ=3
-# CHECK: # | Error: 'env' cannot call 'export'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 mkdir foobar
-# CHECK: # executed command: env -u FOO BAR=3 mkdir foobar
-# CHECK: # | Error: 'env' cannot call 'mkdir'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 not rm {{.+}}.no-such-file
-# CHECK: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}}
-# CHECK: # | Error: 'env' cannot call 'rm'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
-# CHECK: env -u FOO BAR=3 rm foobar
-# CHECK: # executed command: env -u FOO BAR=3 rm foobar
-# CHECK: # | Error: 'env' cannot call 'rm'
-# CHECK: # error: command failed with exit status: {{.*}}
-
-# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
-# CHECK: [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: env -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO [[PYTHON_BARE]] print_environment.py
-# CHECK: env -u FOO -u BAR [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env -u FOO -u BAR [[PYTHON_BARE]] print_environment.py
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
-
-# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
-# CHECK: env A_FOO=999 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=999 [[PYTHON_BARE]] print_environment.py
-# CHECK: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON_BARE]] print_environment.py
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
-
-# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
-# CHECK: env A_FOO=999 -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE]] print_environment.py
-# CHECK: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON_BARE]] print_environment.py
-# CHECK-NOT: {{^[^#]}}
-# CHECK: --
-
-# CHECK: Total Discovered Tests: 16
-# CHECK: Passed:  9 {{\([0-9]*\.[0-9]*%\)}}
-# CHECK: Failed: 7 {{\([0-9]*\.[0-9]*%\)}}
-# CHECK-NOT: {{.}}

>From a6dc004b5f82f9103861ace77a33b5f9b093904f Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Thu, 22 Aug 2024 00:21:18 +0000
Subject: [PATCH 18/23] [llvm-lit] Removed `print_environment.py` file and
 Refactored some tests

This patch removes the print_environment.py file, which was previously
used to print environment variables in the format KEY=VALUE. The tests
have been refactored to directly use the env command, with the output
being validated using FileCheck. Comments were updated to use ## for
better readability, and the test cases were rewritten to ensure
consistency.
---
 .../shtest-env-negative/print_environment.py  |  9 ---------
 .../shtest-env-positive/env-args-none.txt     | 10 +++++-----
 .../shtest-env-positive/env-calls-env.txt     | 15 +++++----------
 .../Inputs/shtest-env-positive/env-u.txt      |  9 +++------
 .../tests/Inputs/shtest-env-positive/env.txt  |  6 ++----
 .../Inputs/shtest-env-positive/mixed.txt      |  6 ++----
 .../shtest-env-positive/print_environment.py  |  9 ---------
 llvm/utils/lit/tests/shtest-env-negative.py   |  4 ++--
 llvm/utils/lit/tests/shtest-env-positive.py   | 19 ++++++++++---------
 9 files changed, 29 insertions(+), 58 deletions(-)
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py
 delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py b/llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py
deleted file mode 100644
index e39bd73e44a108..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env-negative/print_environment.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-import os
-
-sorted_environment = sorted(os.environ.items())
-
-for name, value in sorted_environment:
-    print(name, "=", value)
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
index ffea70bc61f329..78482196c36e8f 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
@@ -1,32 +1,32 @@
-# Check default environment.
+## Check default environment.
 # RUN: env | FileCheck -check-prefix=NO-ARGS %s
 #
 # NO-ARGS: BAR=2
 # NO-ARGS: FOO=1
 # NO-ARGS: QUX=3
 
-# Set environment variables.
+## Set environment variables.
 # RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
 #
 # SET-VAL: BAR=1
 # SET-VAL: FOO=2
 # SET-VAL: QUX=3
 
-# Unset environment variables.
+## Unset environment variables.
 # RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
 #
 # UNSET-U-NOT: BAR
 # UNSET-U-NOT: FOO
 # UNSET-U: QUX=3
 
-# Mixed set and unset environment variables.
+## Mixed set and unset environment variables.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
 #
 # MIXED-SET-UNSET-NOT: BAR
 # MIXED-SET-UNSET: FOO=2
 # MIXED-SET-UNSET: QUX=3
 
-# Mixed set and unset with additional variable.
+## Mixed set and unset with additional variable.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
 #
 # MIXED-SET-UNSET-ADD-NOT: BAR
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
index 26150c413dc03d..6c4587a0f3638d 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
@@ -1,31 +1,26 @@
 # Check that internal env can call internal env.
 
-# RUN: env env %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s
+# RUN: env env | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s
 #
 # CHECK-2-EMPTY-ARGS: BAR = 2
 # CHECK-2-EMPTY-ARGS: FOO = 1
 
-# RUN: env FOO=2 env BAR=1 %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-VAL %s
+# RUN: env FOO=2 env BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s
 #
 # CHECK-2-VAL: BAR = 1
 # CHECK-2-VAL: FOO = 2
 
-# RUN: env -u FOO env -u BAR %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-U %s
+# RUN: env -u FOO env -u BAR | FileCheck -check-prefix=CHECK-2-U %s
 #
 # CHECK-2-U-NOT: BAR
 # CHECK-2-U-NOT: FOO
 
-# RUN: env -u FOO BAR=1 env -u BAR FOO=2 %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-2-U-VAL %s
+# RUN: env -u FOO BAR=1 env -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s
 #
 # CHECK-2-U-VAL-NOT: BAR
 # CHECK-2-U-VAL: FOO = 2
 
-# RUN: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 %{python} print_environment.py \
-# RUN: | FileCheck -check-prefix=CHECK-3 %s
+# RUN: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 | FileCheck -check-prefix=CHECK-3 %s
 #
 # CHECK-3-NOT: BAR
 # CHECK-3: BAZ = 3
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
index 9cdf9d08850f78..8159bd1fb56425 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
@@ -1,17 +1,14 @@
 # Check and make sure preset environment variable were set in lit.cfg
 #
-# RUN: %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-PRESET %s
+# RUN: env | FileCheck --check-prefix=CHECK-ENV-PRESET %s
 #
 # Check single unset of environment variable
 #
-# RUN: env -u FOO %{python} print_environment.py \
-# RUN:  | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s
+# RUN: env -u FOO | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s
 #
 # Check multiple unsets of environment variables
 #
-# RUN: env -u FOO -u BAR %{python} print_environment.py \
-# RUN:  | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s
+# RUN: env -u FOO -u BAR | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s
 
 # CHECK-ENV-PRESET: BAR = 2
 # CHECK-ENV-PRESET: FOO = 1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
index aa697b0c4081f4..df2897e850ad64 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
@@ -1,12 +1,10 @@
 # Check for simple one environment variable setting
 #
-# RUN: env A_FOO=999 %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-1 %s
+# RUN: env A_FOO=999 | FileCheck --check-prefix=CHECK-ENV-1 %s
 #
 # Check for multiple environment variable settings
 #
-# RUN: env A_FOO=1 B_BAR=2 C_OOF=3 %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
+# RUN: env A_FOO=1 B_BAR=2 C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
 
 # CHECK-ENV-1: A_FOO = 999
 
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
index be32d458843bc3..e247bcc4514607 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
@@ -1,12 +1,10 @@
 # Check for setting and removing one environment variable
 #
-# RUN: env A_FOO=999 -u FOO %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-1 %s
+# RUN: env A_FOO=999 -u FOO | FileCheck --check-prefix=CHECK-ENV-1 %s
 #
 # Check for setting/unsetting multiple environment variables
 #
-# RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 %{python} print_environment.py \
-# RUN:   | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
+# RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
 
 # CHECK-ENV-1: A_FOO = 999
 # CHECK-ENV-1-NOT: FOO
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py b/llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py
deleted file mode 100644
index e39bd73e44a108..00000000000000
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/print_environment.py
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-import os
-
-sorted_environment = sorted(os.environ.items())
-
-for name, value in sorted_environment:
-    print(name, "=", value)
diff --git a/llvm/utils/lit/tests/shtest-env-negative.py b/llvm/utils/lit/tests/shtest-env-negative.py
index 07776547e07502..c8b59b224e7c43 100644
--- a/llvm/utils/lit/tests/shtest-env-negative.py
+++ b/llvm/utils/lit/tests/shtest-env-negative.py
@@ -1,11 +1,11 @@
-# Check the env command (failing tests)
+## Test the env command (failing tests).
 
 # RUN: not %{lit} -a -v %{inputs}/shtest-env-negative \
 # RUN: | FileCheck -match-full-lines %s
 #
 # END.
 
-# Check the env command's expected failures.
+## Test the env command's expected failures.
 
 # CHECK: -- Testing: 7 tests{{.*}}
 
diff --git a/llvm/utils/lit/tests/shtest-env-positive.py b/llvm/utils/lit/tests/shtest-env-positive.py
index 36b93c41de98c0..283701da32e5eb 100644
--- a/llvm/utils/lit/tests/shtest-env-positive.py
+++ b/llvm/utils/lit/tests/shtest-env-positive.py
@@ -1,11 +1,11 @@
-# Check the env command (passing tests)
+## Test the env command (passing tests).
 
 # RUN: %{lit} -a -v %{inputs}/shtest-env-positive \
 # RUN: | FileCheck -match-full-lines %s
 #
 # END.
 
-# Check the env command's successful executions.
+## Test the env command's successful executions.
 
 # CHECK: -- Testing: 9 tests{{.*}}
 
@@ -42,25 +42,26 @@
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
-# CHECK: env env [[PYTHON:.+]] print_environment.py | {{.*}}
-# CHECK: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
+# CHECK: env env | {{.*}}
+# CHECK: # executed command: env env
 # CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
-# CHECK: env -u FOO [[PYTHON]] print_environment.py | {{.*}}
+# CHECK: env -u FOO | {{.*}}
+# CHECK: # executed command: env -u FOO
 # CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
-# CHECK: env A_FOO=999 [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=999 [[PYTHON_BARE:.+]] print_environment.py
+# CHECK: env A_FOO=999 | {{.*}}
+# CHECK: # executed command: env A_FOO=999
 # CHECK-NOT: # error:
 # CHECK: --
 
 # CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
-# CHECK: env A_FOO=999 -u FOO [[PYTHON]] print_environment.py | {{.*}}
-# CHECK: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE:.+]] print_environment.py
+# CHECK: env A_FOO=999 -u FOO | {{.*}}
+# CHECK: # executed command: env A_FOO=999 -u FOO
 # CHECK-NOT: # error:
 # CHECK: --
 

>From 053e7eb9fabf06acdfe4f35047d61b0466c6e7be Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Fri, 23 Aug 2024 05:39:09 +0000
Subject: [PATCH 19/23] [llvm-lit] Improved comments

Added a comment at the top of every file that I modified explaining the
general purpose of the tests in the file.
---
 .../tests/Inputs/shtest-env-positive/env-args-none.txt    | 2 ++
 .../tests/Inputs/shtest-env-positive/env-calls-env.txt    | 7 ++++++-
 llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt | 8 +++++---
 llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt   | 6 ++++--
 llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt | 6 ++++--
 5 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
index 78482196c36e8f..ef83e9b59a8c60 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
@@ -1,3 +1,5 @@
+## Tests the env command's ability to handle setting, unsetting, and mixing environment variables.
+
 ## Check default environment.
 # RUN: env | FileCheck -check-prefix=NO-ARGS %s
 #
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
index 6c4587a0f3638d..baa9c78994b62a 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
@@ -1,25 +1,30 @@
-# Check that internal env can call internal env.
+## Tests env command's handling of nested calls, setting, unsetting, and variable retention.
 
+## Check that internal env can call internal env.
 # RUN: env env | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s
 #
 # CHECK-2-EMPTY-ARGS: BAR = 2
 # CHECK-2-EMPTY-ARGS: FOO = 1
 
+## Check setting variables in a nested env call.
 # RUN: env FOO=2 env BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s
 #
 # CHECK-2-VAL: BAR = 1
 # CHECK-2-VAL: FOO = 2
 
+## Check unsetting variables in a nested env call.
 # RUN: env -u FOO env -u BAR | FileCheck -check-prefix=CHECK-2-U %s
 #
 # CHECK-2-U-NOT: BAR
 # CHECK-2-U-NOT: FOO
 
+## Check mixed setting and unsetting in nested env calls.
 # RUN: env -u FOO BAR=1 env -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s
 #
 # CHECK-2-U-VAL-NOT: BAR
 # CHECK-2-U-VAL: FOO = 2
 
+## Check setting, unsetting, and adding a new variable in nested env calls.
 # RUN: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 | FileCheck -check-prefix=CHECK-3 %s
 #
 # CHECK-3-NOT: BAR
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
index 8159bd1fb56425..2945639c0642df 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-u.txt
@@ -1,12 +1,14 @@
-# Check and make sure preset environment variable were set in lit.cfg
+## Tests env command for preset variables and handling single/multiple unsets.
+
+## Check and make sure preset environment variable were set in lit.cfg.
 #
 # RUN: env | FileCheck --check-prefix=CHECK-ENV-PRESET %s
 #
-# Check single unset of environment variable
+## Check single unset of environment variable.
 #
 # RUN: env -u FOO | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s
 #
-# Check multiple unsets of environment variables
+## Check multiple unsets of environment variables.
 #
 # RUN: env -u FOO -u BAR | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s
 
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
index df2897e850ad64..2f6324fcb84273 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
@@ -1,8 +1,10 @@
-# Check for simple one environment variable setting
+## Tests env command for setting single and multiple environment variables.
+
+## Check for simple one environment variable setting
 #
 # RUN: env A_FOO=999 | FileCheck --check-prefix=CHECK-ENV-1 %s
 #
-# Check for multiple environment variable settings
+## Check for multiple environment variable settings
 #
 # RUN: env A_FOO=1 B_BAR=2 C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
 
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
index e247bcc4514607..c2c4e8bfdfc8bd 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/mixed.txt
@@ -1,8 +1,10 @@
-# Check for setting and removing one environment variable
+## Tests env command for setting and unsetting single and multiple environment variables.
+
+## Check for setting and removing one environment variable
 #
 # RUN: env A_FOO=999 -u FOO | FileCheck --check-prefix=CHECK-ENV-1 %s
 #
-# Check for setting/unsetting multiple environment variables
+## Check for setting/unsetting multiple environment variables
 #
 # RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
 

>From 61f2bf974ac126ed2f258b4360cc165ed8913f54 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Fri, 23 Aug 2024 19:47:58 +0000
Subject: [PATCH 20/23] Updated the comments in files modified

---
 .../lit/tests/Inputs/shtest-env-positive/env-args-none.txt    | 2 +-
 .../lit/tests/Inputs/shtest-env-positive/env-calls-env.txt    | 2 +-
 llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt       | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
index ef83e9b59a8c60..41637a74abaa3c 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
@@ -1,4 +1,4 @@
-## Tests the env command's ability to handle setting, unsetting, and mixing environment variables.
+## Tests the env command in various scenarios: without arguments, setting, unsetting, and mixing envrionment variables. 
 
 ## Check default environment.
 # RUN: env | FileCheck -check-prefix=NO-ARGS %s
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
index baa9c78994b62a..ee40c60a1e4b65 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
@@ -1,4 +1,4 @@
-## Tests env command's handling of nested calls, setting, unsetting, and variable retention.
+## Tests the behaviour of chaining env commands together.
 
 ## Check that internal env can call internal env.
 # RUN: env env | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s
diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
index 2f6324fcb84273..74a2a65d260f41 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env.txt
@@ -1,10 +1,10 @@
 ## Tests env command for setting single and multiple environment variables.
 
-## Check for simple one environment variable setting
+## Check for simple one environment variable setting.
 #
 # RUN: env A_FOO=999 | FileCheck --check-prefix=CHECK-ENV-1 %s
 #
-## Check for multiple environment variable settings
+## Check for multiple environment variable settings.
 #
 # RUN: env A_FOO=1 B_BAR=2 C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
 

>From 69809a6cd15e933603155b2f96e3deef171409e3 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Fri, 23 Aug 2024 22:59:37 +0000
Subject: [PATCH 21/23] Fixed trailing space.

---
 .../lit/tests/Inputs/shtest-env-positive/env-args-none.txt      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
index 41637a74abaa3c..4bae79e99b4574 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
@@ -1,4 +1,4 @@
-## Tests the env command in various scenarios: without arguments, setting, unsetting, and mixing envrionment variables. 
+## Tests the env command in various scenarios: without arguments, setting, unsetting, and mixing envrionment variables.
 
 ## Check default environment.
 # RUN: env | FileCheck -check-prefix=NO-ARGS %s

>From 070ccde6923bc32a3c3f9397effa9b363de5726f Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Tue, 27 Aug 2024 17:33:12 +0000
Subject: [PATCH 22/23] Renamed env-args-none.txt to env-no-subcommand.txt and
 alphabetized test order

---
 .../{env-args-none.txt => env-no-subcommand.txt}  | 10 +++++-----
 llvm/utils/lit/tests/shtest-env-positive.py       | 15 +++++++--------
 2 files changed, 12 insertions(+), 13 deletions(-)
 rename llvm/utils/lit/tests/Inputs/shtest-env-positive/{env-args-none.txt => env-no-subcommand.txt} (96%)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
similarity index 96%
rename from llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
rename to llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
index 4bae79e99b4574..f52690c26a53e4 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-args-none.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
@@ -6,32 +6,32 @@
 # NO-ARGS: BAR=2
 # NO-ARGS: FOO=1
 # NO-ARGS: QUX=3
-
+   
 ## Set environment variables.
 # RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
 #
 # SET-VAL: BAR=1
 # SET-VAL: FOO=2
 # SET-VAL: QUX=3
-
+ 
 ## Unset environment variables.
 # RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
 #
 # UNSET-U-NOT: BAR
 # UNSET-U-NOT: FOO
 # UNSET-U: QUX=3
-
+ 
 ## Mixed set and unset environment variables.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
 #
 # MIXED-SET-UNSET-NOT: BAR
 # MIXED-SET-UNSET: FOO=2
 # MIXED-SET-UNSET: QUX=3
-
+ 
 ## Mixed set and unset with additional variable.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
 #
 # MIXED-SET-UNSET-ADD-NOT: BAR
 # MIXED-SET-UNSET-ADD: BAZ=4
 # MIXED-SET-UNSET-ADD: FOO=2
-# MIXED-SET-UNSET-ADD: QUX=3
+# MIXED-SET-UNSET-ADD: QUX=3 
diff --git a/llvm/utils/lit/tests/shtest-env-positive.py b/llvm/utils/lit/tests/shtest-env-positive.py
index 283701da32e5eb..65bff0e40856eb 100644
--- a/llvm/utils/lit/tests/shtest-env-positive.py
+++ b/llvm/utils/lit/tests/shtest-env-positive.py
@@ -33,7 +33,13 @@
 # CHECK-NOT: # error:
 # CHECK: --
 
-# CHECK: PASS: shtest-env :: env-args-none.txt ({{[^)]*}})
+# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
+# CHECK: env env | {{.*}}
+# CHECK: # executed command: env env
+# CHECK-NOT: # error:
+# CHECK: --
+
+# CHECK: PASS: shtest-env :: env-no-subcommand.txt ({{[^)]*}})
 # CHECK: env | {{.*}}
 # CHECK: # executed command: env
 # CHECK: env FOO=2 BAR=1 | {{.*}}
@@ -41,17 +47,10 @@
 # CHECK-NOT: # error:
 # CHECK: --
 
-# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
-# CHECK: env env | {{.*}}
-# CHECK: # executed command: env env
-# CHECK-NOT: # error:
-# CHECK: --
-
 # CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
 # CHECK: env -u FOO | {{.*}}
 # CHECK: # executed command: env -u FOO
 # CHECK-NOT: # error:
-# CHECK: --
 
 # CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
 # CHECK: env A_FOO=999 | {{.*}}

>From 7e2be8b443f7fc04e79cf3f1bfb3c3bfc6391466 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Wed, 28 Aug 2024 07:35:55 +0000
Subject: [PATCH 23/23] Fixed trailing whitespaces and `# CHECK: --` which I
 accidentally removed in my last commit.

---
 .../Inputs/shtest-env-positive/env-no-subcommand.txt      | 8 ++++----
 llvm/utils/lit/tests/shtest-env-positive.py               | 1 +
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
index f52690c26a53e4..761a8061a0b0de 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
@@ -6,28 +6,28 @@
 # NO-ARGS: BAR=2
 # NO-ARGS: FOO=1
 # NO-ARGS: QUX=3
-   
+
 ## Set environment variables.
 # RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
 #
 # SET-VAL: BAR=1
 # SET-VAL: FOO=2
 # SET-VAL: QUX=3
- 
+
 ## Unset environment variables.
 # RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
 #
 # UNSET-U-NOT: BAR
 # UNSET-U-NOT: FOO
 # UNSET-U: QUX=3
- 
+
 ## Mixed set and unset environment variables.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s
 #
 # MIXED-SET-UNSET-NOT: BAR
 # MIXED-SET-UNSET: FOO=2
 # MIXED-SET-UNSET: QUX=3
- 
+
 ## Mixed set and unset with additional variable.
 # RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s
 #
diff --git a/llvm/utils/lit/tests/shtest-env-positive.py b/llvm/utils/lit/tests/shtest-env-positive.py
index 65bff0e40856eb..863fbda8c5b6dc 100644
--- a/llvm/utils/lit/tests/shtest-env-positive.py
+++ b/llvm/utils/lit/tests/shtest-env-positive.py
@@ -51,6 +51,7 @@
 # CHECK: env -u FOO | {{.*}}
 # CHECK: # executed command: env -u FOO
 # CHECK-NOT: # error:
+# CHECK: --
 
 # CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
 # CHECK: env A_FOO=999 | {{.*}}



More information about the llvm-commits mailing list