Remove some duplication from the tests

Get rid of some of the duplication from the command line interface tests
by extracting a decorator that checks that the proper exception is
thrown when we run a command without one of its required arguments.

Change-Id: Ifd2b93b7ff1bb249c002f1b03c0a242feb1f39f9
diff --git a/tests/cli/testllvmprojects.py b/tests/cli/testllvmprojects.py
index 32cead4..d0f6d1d 100644
--- a/tests/cli/testllvmprojects.py
+++ b/tests/cli/testllvmprojects.py
@@ -14,7 +14,7 @@
 from uuid import uuid4
 
 from linaropy.cd import cd
-from llvmtestcase import LLVMTestCase
+from llvmtestcase import LLVMTestCase, require_command_arg
 
 
 class Testllvmprojs(LLVMTestCase):
@@ -98,36 +98,26 @@
                 "--remove",
                 "clang"))
 
+    @require_command_arg("--source-dir")
     def test_source_dir_is_compulsory(self):
         """
         Test that we must pass in the source dir for various combinations of
         input args.
         """
-        with self.assertRaises(subprocess.CalledProcessError) as context:
-            self.run_with_output(self.llvm_projects())
+        self.run_with_output(self.llvm_projects())
 
-        self.assertRegex(
-            str(context.exception.output),
-            "(.*\n)*.*the following arguments are required:(.*)--source-dir(.*\n)*")
+    @require_command_arg("--source-dir")
+    def test_source_dir_ir_compulsory_for_add(self):
+        self.run_with_output(
+            self.llvm_projects(
+                "--repos", self.repos,
+                "--add", "clang", env=None))
 
-        with self.assertRaises(subprocess.CalledProcessError) as context:
-            self.run_with_output(
-                self.llvm_projects(
-                    "--repos", self.repos,
-                    "--add", "clang", env=None))
-
-        self.assertRegex(
-            str(context.exception.output),
-            "(.*\n)*.*the following arguments are required:(.*)--source-dir(.*\n)*")
-
-        with self.assertRaises(subprocess.CalledProcessError) as context:
-            self.run_with_output(
-                self.llvm_projects(
-                    "--remove", "clang", env=None))
-
-        self.assertRegex(
-            str(context.exception.output),
-            "(.*\n)*.*the following arguments are required:(.*)--source-dir(.*\n)*")
+    @require_command_arg("--source-dir")
+    def test_source_dir_ir_compulsory_for_remove(self):
+        self.run_with_output(
+            self.llvm_projects(
+                "--remove", "clang", env=None))
 
     def test_dump_empty_config(self):
         """