[llvm-lit][test] Resolved typo in raising InternalShellError for export command in lit's internal shell (#105961)

This patch fixes the incorrect usage of lit's built-in `export` command.
There is a typo in raising the error itself where the error being raised
had the wrong number of parameters passed in.

Fixes https://github.com/llvm/llvm-project/issues/102386.
This commit is contained in:
Connie Zhu
2024-08-26 20:21:02 -07:00
committed by GitHub
parent ce2b488e90
commit 1990d8de33
4 changed files with 22 additions and 1 deletions

View File

@@ -356,7 +356,7 @@ def executeBuiltinPopd(cmd, shenv):
def executeBuiltinExport(cmd, shenv):
"""executeBuiltinExport - Set an environment variable."""
if len(cmd.args) != 2:
raise InternalShellError("'export' supports only one argument")
raise InternalShellError(cmd, "'export' supports only one argument")
updateEnv(shenv, cmd.args)
return ShellCommandResult(cmd, "", "", 0, False)

View File

@@ -0,0 +1,2 @@
## Test export command with too many arguments.
# RUN: export FOO=1 BAR=2

View File

@@ -0,0 +1,7 @@
import lit.formats
config.name = "shtest-export"
config.suffixes = [".txt"]
config.test_format = lit.formats.ShTest()
config.test_source_root = None
config.test_exec_root = None

View File

@@ -0,0 +1,12 @@
## Test the export command.
# RUN: not %{lit} -a -v %{inputs}/shtest-export \
# RUN: | FileCheck -match-full-lines %s
#
# END.
# CHECK: FAIL: shtest-export :: export-too-many-args.txt {{.*}}
# CHECK: export FOO=1 BAR=2
# CHECK: # executed command: export FOO=1 BAR=2
# CHECK: # | 'export' supports only one argument
# CHECK: # error: command failed with exit status: {{.*}}