[llvm] [llvm-lit] Resolve env subcommand required error (PR #98414)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 14:22:24 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/10] [llvm-lit]
When executing not --crash env without any arguments,
it fails with exit code 127 because env reuires a
subcommand. This path addresses the issue by encoding
the command to properly return environment variables
even when no arguments are provided.
---
llvm/utils/lit/lit/TestRunner.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index da7fa86fd3917..8f0cd801ae9ff 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -743,7 +743,8 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
cmd_shenv = ShellEnvironment(shenv.cwd, shenv.env)
args = updateEnv(cmd_shenv, args)
if not args:
- raise InternalShellError(j, "Error: 'env' requires a" " subcommand")
+ # Return the environment variables if no argument is provided
+ return {key: value for key, value in cmd_shenv.env.items()}
elif args[0] == "not":
not_args.append(args.pop(0))
not_count += 1
>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/10] [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 8f0cd801ae9ff..da541c6b742a3 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 dc5cdbad09afc..0eb724a2101c3 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 03bb4a3cae7dd..61ee9bc7d21ac 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/10] [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 61ee9bc7d21ac..7e6ad751a7a3d 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/10] 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 da541c6b742a3..b98e92071508f 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 7e6ad751a7a3d..96284c99fe5a1 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/10] [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 b98e92071508f..da541c6b742a3 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 96284c99fe5a1..7e6ad751a7a3d 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/10] [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 da541c6b742a3..8f0cd801ae9ff 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 0eb724a2101c3..dc5cdbad09afc 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 7e6ad751a7a3d..03bb4a3cae7dd 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/10] [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 8f0cd801ae9ff..da541c6b742a3 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 dc5cdbad09afc..0eb724a2101c3 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 03bb4a3cae7dd..7e6ad751a7a3d 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/10] [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 da541c6b742a3..1fb958c428dc9 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 0eb724a2101c3..2b636158a811f 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/10] [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 1fb958c428dc9..be9339491a782 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 2b636158a811f..d2a8957478cb3 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 7e6ad751a7a3d..48378f95bf4d9 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/10] 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 d2a8957478cb3..755f50a1c926d 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 df9df7da81daa..626c00f71d728 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 48378f95bf4d9..8bf7f6ca38830 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: --
More information about the llvm-commits
mailing list