[llvm] [llvm-objcopy] Check for missing argument values (PR #70710)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 1 00:45:37 PDT 2023


================
@@ -0,0 +1,4 @@
+## An error must be reported if a required argument value is missing.
+# RUN: not llvm-objcopy --only-section 2>&1 | FileCheck --check-prefix=CHECK-NO-VALUE %s
+# RUN: not llvm-objcopy -O 2>&1 | FileCheck --check-prefix=CHECK-NO-VALUE %s
+# CHECK-NO-VALUE: error: argument to '{{.*}}' is missing
----------------
jh7370 wrote:

> I think there is enough context in the message to avoid misidentification for other messages.

Agreed.

> I don't think a random corruption in the output is likely, and testing for it would be outside of the scope of this test.

This isn't why I think you should check the exact contents. Checking the exact contents explicitly will show that you've used the correct `%*` stuff in your `createStringError` call. Equally, should the code change in the future to use a different mechanism to parse the command-line/report the error/etc, it would show that the change is still reporting the context correctly.

https://github.com/llvm/llvm-project/pull/70710


More information about the llvm-commits mailing list