[debuginfo-tests] 487ab53 - [dexter] Add keyword argument 'on_line' to DexLabel

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 23 04:03:17 PDT 2021


Author: OCHyams
Date: 2021-04-23T12:00:16+01:00
New Revision: 487ab5345920b2cfd2162f04b467dd39fb1a8627

URL: https://github.com/llvm/llvm-project/commit/487ab5345920b2cfd2162f04b467dd39fb1a8627
DIFF: https://github.com/llvm/llvm-project/commit/487ab5345920b2cfd2162f04b467dd39fb1a8627.diff

LOG: [dexter] Add keyword argument 'on_line' to DexLabel

Add optional keyword argument 'on_line' to DexLabel to label the specifed line
instead of the line the command is found on.

This will be helpful when used alongside DexDeclareFile (D99651).

Reviewed By: TWeaver

Differential Revision: https://reviews.llvm.org/D101055

Added: 
    debuginfo-tests/dexter/feature_tests/subtools/test/err_label_kwarg.cpp
    debuginfo-tests/dexter/feature_tests/subtools/test/label_another_line.cpp

Modified: 
    debuginfo-tests/dexter/Commands.md
    debuginfo-tests/dexter/dex/command/commands/DexLabel.py

Removed: 
    


################################################################################
diff  --git a/debuginfo-tests/dexter/Commands.md b/debuginfo-tests/dexter/Commands.md
index 71e7c35287931..d95ea32741f8d 100644
--- a/debuginfo-tests/dexter/Commands.md
+++ b/debuginfo-tests/dexter/Commands.md
@@ -205,14 +205,17 @@ large test cases that would normally take much longer to complete.
 
 ----
 ## DexLabel
-    DexLabel(name)
+    DexLabel(name [, **on_line])
 
     Args:
         name (str): A unique name for this line.
 
+    Keyword args:
+        on_line (int): Specify a line number to label.
+
 ### Description
-Name the line this command is found on. Line names can be referenced by other
-commands expecting line number arguments.
+Name the line this command is found on or 'on_line' if it is provided. Line
+names can be referenced by other commands expecting line number arguments.
 For example, `DexExpectWatchValues(..., on_line='my_line_name')`.
 
 ### Heuristic

diff  --git a/debuginfo-tests/dexter/dex/command/commands/DexLabel.py b/debuginfo-tests/dexter/dex/command/commands/DexLabel.py
index 8a0325e663445..9f42d42e0ffee 100644
--- a/debuginfo-tests/dexter/dex/command/commands/DexLabel.py
+++ b/debuginfo-tests/dexter/dex/command/commands/DexLabel.py
@@ -12,16 +12,27 @@
 
 
 class DexLabel(CommandBase):
-    def __init__(self, label):
+    def __init__(self, label, **kwargs):
 
         if not isinstance(label, str):
             raise TypeError('invalid argument type')
 
+        try:
+            self.on_line = kwargs.pop('on_line')
+        except KeyError:
+            # We cannot use self.lineno because it hasn't been set yet.
+            pass
+        if kwargs:
+            raise TypeError(f'unexpected named args: {", ".join(kwargs)}')
+
         self._label = label
         super(DexLabel, self).__init__()
 
+    def get_line(self):
+        return getattr(self, 'on_line', self.lineno)
+
     def get_as_pair(self):
-        return (self._label, self.lineno)
+        return (self._label, self.get_line())
 
     @staticmethod
     def get_name():

diff  --git a/debuginfo-tests/dexter/feature_tests/subtools/test/err_label_kwarg.cpp b/debuginfo-tests/dexter/feature_tests/subtools/test/err_label_kwarg.cpp
new file mode 100644
index 0000000000000..b0bd50a248d12
--- /dev/null
+++ b/debuginfo-tests/dexter/feature_tests/subtools/test/err_label_kwarg.cpp
@@ -0,0 +1,8 @@
+// Purpose:
+//    Check that bad keyword args in \DexLabel are reported.
+//    Use --binary switch to trick dexter into skipping the build step.
+//
+// RUN: not %dexter_base test --binary %s --debugger 'lldb' -- %s | FileCheck %s
+// CHECK: parser error:{{.*}}err_label_kwarg.cpp(8): unexpected named args: bad_arg
+
+// DexLabel('test', bad_arg=0)

diff  --git a/debuginfo-tests/dexter/feature_tests/subtools/test/label_another_line.cpp b/debuginfo-tests/dexter/feature_tests/subtools/test/label_another_line.cpp
new file mode 100644
index 0000000000000..c6284ef320272
--- /dev/null
+++ b/debuginfo-tests/dexter/feature_tests/subtools/test/label_another_line.cpp
@@ -0,0 +1,14 @@
+// Purpose:
+//    Check that the optional keyword argument 'on_line' makes a \DexLabel label
+//    that line instead of the line the command is found on.
+//
+// RUN: %dexter_regression_test -- %s | FileCheck %s
+// CHECK: label_another_line.cpp: (1.0000)
+
+int main() {
+  int result = 0;
+  return result;
+}
+
+// DexLabel('test', on_line=10)
+// DexExpectWatchValue('result', '0', on_line='test')


        


More information about the llvm-commits mailing list