From f7aab483320e92d4acf52a7035553e6766034f43 Mon Sep 17 00:00:00 2001 From: Harini Date: Wed, 31 Jul 2024 20:44:28 +0000 Subject: [PATCH 1/4] [llvm-lit] Unhashable type Support Used expand_glob_expressions to resolve all GlobItem instances in args list to their acutal paths. Checked and converted args[0] if it is a Glob instance and ensured the resolved path is a string (hashable) before using it as a key in the inproc_builtins dictionary. To sum everything, this patch eliminates the 'unhashable type: GlobItem' error. --- llvm/utils/lit/lit/TestRunner.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index da7fa86fd3917..ca8028f380ae8 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -767,6 +767,13 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): # echo-appending to a file. # FIXME: Standardize on the builtin echo implementation. We can use a # temporary file to sidestep blocking pipe write issues. + + # Ensure args[0] is hashable before using it in inproc_builtins + if isinstance(args[0], GlobItem): + expanded_args = expand_glob(args[0], cmd_shenv.cwd) + if expanded_args: + args[0] = expanded_args[0] + inproc_builtin = inproc_builtins.get(args[0], None) if inproc_builtin and (args[0] != "echo" or len(cmd.commands) == 1): # env calling an in-process builtin is useless, so we take the safe From 24080401e918cb9a4dd61cd6ed73dcdf91160f31 Mon Sep 17 00:00:00 2001 From: Harini Date: Wed, 7 Aug 2024 06:04:25 +0000 Subject: [PATCH 2/4] [llvm-lit] Fix handling of GlobItem in args[0] to ensure it is hashable Removed the previous complex implementation to a simipler verison. Added direct expansion and conversion of args[0] to ensure it is always a resolved path string. This patch ensures that args[0] is consistently a string, preventing TypeError when args[0] is used as a dictionary key or in other contexts that require a hashable type. --- llvm/utils/lit/lit/TestRunner.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index ca8028f380ae8..144362841c472 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -768,12 +768,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): # FIXME: Standardize on the builtin echo implementation. We can use a # temporary file to sidestep blocking pipe write issues. - # Ensure args[0] is hashable before using it in inproc_builtins - if isinstance(args[0], GlobItem): - expanded_args = expand_glob(args[0], cmd_shenv.cwd) - if expanded_args: - args[0] = expanded_args[0] - + args[0] = expand_glob(args[0], cmd_shenv.cwd)[0] inproc_builtin = inproc_builtins.get(args[0], None) if inproc_builtin and (args[0] != "echo" or len(cmd.commands) == 1): # env calling an in-process builtin is useless, so we take the safe From 25b1bd77ce192b5a096ad8c66042a508269e3513 Mon Sep 17 00:00:00 2001 From: Harini Date: Thu, 8 Aug 2024 08:03:01 +0000 Subject: [PATCH 3/4] [llvm-lit] Simplify args[0] Hashability Check and Expansion Refactored the code to simplify the hashability check and expansion of args[0]. The pervious commit included a conditional check to determine if args[0] was a GlobItem and subsequently expanded it. The new implementation directly assigns the expanded value of args[0]. This patch simplifies the logic by removing unnecessary conditionals and ensures that args[0] is always assigned an expanded value. --- llvm/utils/lit/lit/TestRunner.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index 144362841c472..b4d53eeb6f0ff 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -768,7 +768,9 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): # FIXME: Standardize on the builtin echo implementation. We can use a # temporary file to sidestep blocking pipe write issues. + # Ensure args[0] is hashable args[0] = expand_glob(args[0], cmd_shenv.cwd)[0] + inproc_builtin = inproc_builtins.get(args[0], None) if inproc_builtin and (args[0] != "echo" or len(cmd.commands) == 1): # env calling an in-process builtin is useless, so we take the safe From bdea9959a057018f61e5269d909dd9f817eae2d3 Mon Sep 17 00:00:00 2001 From: Harini Date: Fri, 9 Aug 2024 17:25:34 +0000 Subject: [PATCH 4/4] [llvm-lit] Fixed a comment Added a period to the end of my comment. --- llvm/utils/lit/lit/TestRunner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py index b4d53eeb6f0ff..cc903f9e3a152 100644 --- a/llvm/utils/lit/lit/TestRunner.py +++ b/llvm/utils/lit/lit/TestRunner.py @@ -768,7 +768,7 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper): # FIXME: Standardize on the builtin echo implementation. We can use a # temporary file to sidestep blocking pipe write issues. - # Ensure args[0] is hashable + # Ensure args[0] is hashable. args[0] = expand_glob(args[0], cmd_shenv.cwd)[0] inproc_builtin = inproc_builtins.get(args[0], None)