[Lldb-commits] [PATCH] D129338: Tell the user which pathname was invalid...

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 15 15:20:05 PDT 2022


jingham updated this revision to Diff 445145.
jingham added a comment.

I added the pathname to the "invalid directory" output, but when the test passes an invalid directory we still execute the "invalid pathname" branch but not the "invalid directory" branch.  I don't know enough about the llvm filesystem stuff to know why that is...

I did add a test for the "empty path" however.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129338/new/

https://reviews.llvm.org/D129338

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/API/commands/command/script/import/TestImport.py


Index: lldb/test/API/commands/command/script/import/TestImport.py
===================================================================
--- lldb/test/API/commands/command/script/import/TestImport.py
+++ lldb/test/API/commands/command/script/import/TestImport.py
@@ -38,12 +38,13 @@
         self.runCmd("command script import ./foo/bar/foobar.py --allow-reload")
         self.runCmd("command script import ./bar/bar.py --allow-reload")
 
+        self.expect("command script import ''",
+                    error=True, startstr="error: module importing failed: empty path")
         self.expect("command script import ./nosuchfile.py",
-                    error=True, startstr='error: module importing failed')
+                    error=True, startstr="error: module importing failed: invalid pathname './nosuchfile.py'")
         self.expect("command script import ./nosuchfolder/",
-                    error=True, startstr='error: module importing failed')
+                    error=True, startstr="error: module importing failed: invalid pathname './nosuchfolder/'")
         self.expect("command script import ./foo/foo.py", error=False)
-
         self.runCmd("command script import --allow-reload ./thepackage")
         self.expect("TPcommandA", substrs=["hello world A"])
         self.expect("TPcommandB", substrs=["hello world B"])
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -2637,7 +2637,7 @@
                                          .SetSetLLDBGlobals(false);
 
   if (!pathname || !pathname[0]) {
-    error.SetErrorString("invalid pathname");
+    error.SetErrorString("empty path");
     return false;
   }
 
@@ -2707,14 +2707,14 @@
       // if not a valid file of any sort, check if it might be a filename still
       // dot can't be used but / and \ can, and if either is found, reject
       if (strchr(pathname, '\\') || strchr(pathname, '/')) {
-        error.SetErrorString("invalid pathname");
+        error.SetErrorStringWithFormatv("invalid pathname '{0}'", pathname);
         return false;
       }
       // Not a filename, probably a package of some sort, let it go through.
       possible_package = true;
     } else if (is_directory(st) || is_regular_file(st)) {
       if (module_file.GetDirectory().IsEmpty()) {
-        error.SetErrorString("invalid directory name");
+        error.SetErrorStringWithFormatv("invalid directory name '{0}'", pathname);
         return false;
       }
       if (llvm::Error e =


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129338.445145.patch
Type: text/x-patch
Size: 2715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220715/d1bf198a/attachment.bin>


More information about the lldb-commits mailing list