[llvm] [llvm-lit] Resolve env subcommand required error (PR #98414)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 09:41:06 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/11] [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/11] [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/11] [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/11] 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/11] [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/11] [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/11] [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 86c213b859ff6f2ca5ab26bec2ea0b5aadf2f600 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Fri, 19 Jul 2024 21:06:47 +0000
Subject: [PATCH 08/11] [llvm-lit] Update comments and adjust prefix names in
env-args-none.txt
Revised comments for clarity and consistency, and modified prefix names
in env-args-none.txt to better align with testing requirements.
---
llvm/utils/lit/lit/TestRunner.py | 6 ++--
.../tests/Inputs/shtest-env/env-args-none.txt | 31 ++++++++++++++++-
llvm/utils/lit/tests/shtest-env.py | 34 +++++++++----------
3 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 8f0cd801ae9ff..fcd2969afc5e4 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -743,8 +743,10 @@ 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
- return {key: value for key, value in cmd_shenv.env.items()}
+ # 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
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..e1afd95c05dc4 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=NO-ARGS %s
+#
+# NO-ARGS: BAR = 2
+# NO-ARGS: FOO = 1
+
+# Set environment variables.
+# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s
+#
+# SET-VAL: BAR = 1
+# SET-VAL: FOO = 2
+
+# Unset environment variables.
+# RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s
+#
+# 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=MIXED-SET-UNSET %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
+#
+# MIXED-SET-UNSET-ADD-NOT: BAR
+# MIXED-SET-UNSET-ADD: BAZ = 3
+# 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 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 343518e615386d950df58c9285f685b9d029c0c0 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 22 Jul 2024 08:07:36 +0000
Subject: [PATCH 09/11] [llvm-lit] Updated all python files Updated all the
python files to be updated with darker
---
llvm/utils/lit/lit/TestRunner.py | 41 ++++++++++++-------
.../custom_format.py | 9 ++--
.../per-test-coverage-by-lit-cfg.py | 2 +-
.../per-test-coverage/per-test-coverage.py | 2 +-
llvm/utils/lit/tests/shtest-env.py | 4 +-
5 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index fcd2969afc5e4..b2fa92c52062a 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -417,7 +417,7 @@ def maybeUnescape(arg):
if write_newline:
stdout.write(encode("\n"))
- for (name, mode, f, path) in opened_files:
+ for name, mode, f, path in opened_files:
f.close()
output = "" if is_redirected else stdout.getvalue()
@@ -583,7 +583,7 @@ def processRedirects(cmd, stdin_source, cmd_shenv, opened_files):
# from a file are represented with a list [file, mode, file-object]
# where file-object is initially None.
redirects = [(0,), (1,), (2,)]
- for (op, filename) in cmd.redirects:
+ for op, filename in cmd.redirects:
if op == (">", 2):
redirects[2] = [filename, "w", None]
elif op == (">>", 2):
@@ -605,7 +605,7 @@ def processRedirects(cmd, stdin_source, cmd_shenv, opened_files):
# Open file descriptors in a second pass.
std_fds = [None, None, None]
- for (index, r) in enumerate(redirects):
+ for index, r in enumerate(redirects):
# Handle the sentinel values for defaults up front.
if isinstance(r, tuple):
if r == (0,):
@@ -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 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))
@@ -914,7 +920,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
# need to release any handles we may have on the temporary files (important
# on Win32, for example). Since we have already spawned the subprocess, our
# handles have already been transferred so we do not need them anymore.
- for (name, mode, f, path) in opened_files:
+ for name, mode, f, path in opened_files:
f.close()
# FIXME: There is probably still deadlock potential here. Yawn.
@@ -968,7 +974,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
# Gather the redirected output files for failed commands.
output_files = []
if res != 0:
- for (name, mode, f, path) in sorted(opened_files):
+ for name, mode, f, path in sorted(opened_files):
if path is not None and mode in ("w", "a"):
try:
with open(path, "rb") as f:
@@ -1133,7 +1139,7 @@ def executeScriptInternal(
# Otherwise, something failed or was printed, show it.
# Add the command output, if redirected.
- for (name, path, data) in result.outputFiles:
+ for name, path, data in result.outputFiles:
data = to_string(data.decode("utf-8", errors="replace"))
out += formatOutput(f"redirected output from '{name}'", data, limit=1024)
if result.stdout.strip():
@@ -1372,8 +1378,11 @@ def regex_escape(s):
return s
path_substitutions = [
- ("s", sourcepath), ("S", sourcedir), ("p", sourcedir),
- ("t", tmpName), ("T", tmpDir)
+ ("s", sourcepath),
+ ("S", sourcedir),
+ ("p", sourcedir),
+ ("t", tmpName),
+ ("T", tmpDir),
]
for path_substitution in path_substitutions:
letter = path_substitution[0]
@@ -1391,15 +1400,17 @@ def regex_escape(s):
# need the fully expanded path.
real_path = os.path.realpath(path)
substitutions.append(("%{" + letter + ":real}", real_path))
- substitutions.append(("%{/" + letter + ":real}",
- real_path.replace("\\", "/")))
+ substitutions.append(("%{/" + letter + ":real}", real_path.replace("\\", "/")))
# "%{/[STpst]:regex_replacement}" should be normalized like
# "%/[STpst]" but we're also in a regex replacement context
# of a s@@@ regex.
substitutions.append(
- ("%{/" + letter + ":regex_replacement}",
- regex_escape(path.replace("\\", "/"))))
+ (
+ "%{/" + letter + ":regex_replacement}",
+ regex_escape(path.replace("\\", "/")),
+ )
+ )
# "%:[STpst]" are normalized paths without colons and without
# a leading slash.
diff --git a/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py b/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
index c6f469fc81d53..e902643aad85d 100644
--- a/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
+++ b/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
@@ -1,12 +1,13 @@
import os
import lit.formats
+
class CustomFormat(lit.formats.ShTest):
def getTestsForPath(self, testSuite, path_in_suite, litConfig, localConfig):
- for sub in ['one.test', 'two.test']:
+ for sub in ["one.test", "two.test"]:
basePath = os.path.dirname(testSuite.getExecPath(path_in_suite))
os.makedirs(basePath, exist_ok=True)
generatedFile = os.path.join(basePath, sub)
- with open(generatedFile, 'w') as f:
- f.write('RUN: true')
- yield lit.Test.Test(testSuite, (generatedFile, ), localConfig)
+ with open(generatedFile, "w") as f:
+ f.write("RUN: true")
+ yield lit.Test.Test(testSuite, (generatedFile,), localConfig)
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
index a8790f74f178c..d446ef4867885 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
@@ -6,7 +6,7 @@
# and print its value
import os
-llvm_profile_file = os.environ.get('LLVM_PROFILE_FILE')
+llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE")
print(llvm_profile_file)
# CHECK: per-test-coverage-by-lit-cfg[[INDEX]].profraw
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py b/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
index 59e806939a23a..cfe3df641b64f 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
@@ -6,7 +6,7 @@
# and print its value
import os
-llvm_profile_file = os.environ.get('LLVM_PROFILE_FILE')
+llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE")
print(llvm_profile_file)
# CHECK: per-test-coverage[[INDEX]].profraw
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 6acbf5fda4933605101b68c65c3ddd0251eb3b14 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 22 Jul 2024 15:17:06 +0000
Subject: [PATCH 10/11] [llvm-lit] Removed unrelated files
Removed untouched files in this PR
---
.../discovery-getTestsForPath/custom_format.py | 14 ++------------
.../per-test-coverage-by-lit-cfg.py | 15 +++++++--------
.../Inputs/per-test-coverage/per-test-coverage.py | 15 +++++++--------
3 files changed, 16 insertions(+), 28 deletions(-)
diff --git a/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py b/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
index e902643aad85d..5e1771d51d871 100644
--- a/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
+++ b/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
@@ -1,13 +1,3 @@
-import os
-import lit.formats
+import os import lit.formats
-
-class CustomFormat(lit.formats.ShTest):
- def getTestsForPath(self, testSuite, path_in_suite, litConfig, localConfig):
- for sub in ["one.test", "two.test"]:
- basePath = os.path.dirname(testSuite.getExecPath(path_in_suite))
- os.makedirs(basePath, exist_ok=True)
- generatedFile = os.path.join(basePath, sub)
- with open(generatedFile, "w") as f:
- f.write("RUN: true")
- yield lit.Test.Test(testSuite, (generatedFile,), localConfig)
+ class CustomFormat(lit.formats.ShTest) :def getTestsForPath(self, testSuite, path_in_suite, litConfig, localConfig) : for sub in["one.test", "two.test"] :basePath = os.path.dirname(testSuite.getExecPath(path_in_suite)) os.makedirs(basePath, exist_ok = True) generatedFile = os.path.join(basePath, sub) with open(generatedFile, "w") as f:f.write("RUN: true") yield lit.Test.Test(testSuite, (generatedFile, ), localConfig)
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
index d446ef4867885..58f93bc765a8f 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
@@ -1,12 +1,11 @@
-# Check that the environment variable is set correctly
-# RUN: %{python} %s | FileCheck -DINDEX=1 %s
-# RUN: %{python} %s | FileCheck -DINDEX=2 %s
+#Check that the environment variable is set correctly
+#RUN : % {python } % s | FileCheck - DINDEX = 1 % s
+#RUN : % {python } % s | FileCheck - DINDEX = 2 % s
-# Python script to read the environment variable
-# and print its value
+#Python script to read the environment variable
+#and print its value
import os
-llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE")
-print(llvm_profile_file)
+ llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE") print(llvm_profile_file)
-# CHECK: per-test-coverage-by-lit-cfg[[INDEX]].profraw
+#CHECK : per - test - coverage - by - lit - cfg[[INDEX]].profraw
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py b/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
index cfe3df641b64f..b526cbc859755 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
@@ -1,12 +1,11 @@
-# Check that the environment variable is set correctly
-# RUN: %{python} %s | FileCheck -DINDEX=1 %s
-# RUN: %{python} %s | FileCheck -DINDEX=2 %s
+#Check that the environment variable is set correctly
+#RUN : % {python } % s | FileCheck - DINDEX = 1 % s
+#RUN : % {python } % s | FileCheck - DINDEX = 2 % s
-# Python script to read the environment variable
-# and print its value
+#Python script to read the environment variable
+#and print its value
import os
-llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE")
-print(llvm_profile_file)
+ llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE") print(llvm_profile_file)
-# CHECK: per-test-coverage[[INDEX]].profraw
+#CHECK : per - test - coverage[[INDEX]].profraw
>From a2edd4548109f98d85cbbdaac711c31f81366f32 Mon Sep 17 00:00:00 2001
From: Harini <harinidonthula at google.com>
Date: Mon, 22 Jul 2024 16:17:37 +0000
Subject: [PATCH 11/11] [llvm-lit] Changed untouched files back to original
Restored files from main branch
---
.../discovery-getTestsForPath/custom_format.py | 13 +++++++++++--
.../per-test-coverage-by-lit-cfg.py | 15 ++++++++-------
.../Inputs/per-test-coverage/per-test-coverage.py | 15 ++++++++-------
3 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py b/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
index 5e1771d51d871..c6f469fc81d53 100644
--- a/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
+++ b/llvm/utils/lit/tests/Inputs/discovery-getTestsForPath/custom_format.py
@@ -1,3 +1,12 @@
-import os import lit.formats
+import os
+import lit.formats
- class CustomFormat(lit.formats.ShTest) :def getTestsForPath(self, testSuite, path_in_suite, litConfig, localConfig) : for sub in["one.test", "two.test"] :basePath = os.path.dirname(testSuite.getExecPath(path_in_suite)) os.makedirs(basePath, exist_ok = True) generatedFile = os.path.join(basePath, sub) with open(generatedFile, "w") as f:f.write("RUN: true") yield lit.Test.Test(testSuite, (generatedFile, ), localConfig)
+class CustomFormat(lit.formats.ShTest):
+ def getTestsForPath(self, testSuite, path_in_suite, litConfig, localConfig):
+ for sub in ['one.test', 'two.test']:
+ basePath = os.path.dirname(testSuite.getExecPath(path_in_suite))
+ os.makedirs(basePath, exist_ok=True)
+ generatedFile = os.path.join(basePath, sub)
+ with open(generatedFile, 'w') as f:
+ f.write('RUN: true')
+ yield lit.Test.Test(testSuite, (generatedFile, ), localConfig)
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
index 58f93bc765a8f..a8790f74f178c 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage-by-lit-cfg/per-test-coverage-by-lit-cfg.py
@@ -1,11 +1,12 @@
-#Check that the environment variable is set correctly
-#RUN : % {python } % s | FileCheck - DINDEX = 1 % s
-#RUN : % {python } % s | FileCheck - DINDEX = 2 % s
+# Check that the environment variable is set correctly
+# RUN: %{python} %s | FileCheck -DINDEX=1 %s
+# RUN: %{python} %s | FileCheck -DINDEX=2 %s
-#Python script to read the environment variable
-#and print its value
+# Python script to read the environment variable
+# and print its value
import os
- llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE") print(llvm_profile_file)
+llvm_profile_file = os.environ.get('LLVM_PROFILE_FILE')
+print(llvm_profile_file)
-#CHECK : per - test - coverage - by - lit - cfg[[INDEX]].profraw
+# CHECK: per-test-coverage-by-lit-cfg[[INDEX]].profraw
diff --git a/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py b/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
index b526cbc859755..59e806939a23a 100644
--- a/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
+++ b/llvm/utils/lit/tests/Inputs/per-test-coverage/per-test-coverage.py
@@ -1,11 +1,12 @@
-#Check that the environment variable is set correctly
-#RUN : % {python } % s | FileCheck - DINDEX = 1 % s
-#RUN : % {python } % s | FileCheck - DINDEX = 2 % s
+# Check that the environment variable is set correctly
+# RUN: %{python} %s | FileCheck -DINDEX=1 %s
+# RUN: %{python} %s | FileCheck -DINDEX=2 %s
-#Python script to read the environment variable
-#and print its value
+# Python script to read the environment variable
+# and print its value
import os
- llvm_profile_file = os.environ.get("LLVM_PROFILE_FILE") print(llvm_profile_file)
+llvm_profile_file = os.environ.get('LLVM_PROFILE_FILE')
+print(llvm_profile_file)
-#CHECK : per - test - coverage[[INDEX]].profraw
+# CHECK: per-test-coverage[[INDEX]].profraw
More information about the llvm-commits
mailing list