All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: yocto@yoctoproject.org
Cc: richard.purdie@intel.com, benjamin.esquivel@intel.com
Subject: [[PATCH][qa-tools] 14/16] toaster/toaster.py: Add command line options.
Date: Tue,  9 Feb 2016 16:45:18 -0600	[thread overview]
Message-ID: <1455057920-11174-5-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1455057920-11174-1-git-send-email-anibal.limon@linux.intel.com>

Now toaster script can receive options from command line like
the repository/branch and the work directory to use.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 toaster/toaster.py | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/toaster/toaster.py b/toaster/toaster.py
index 8afd286..4b5b077 100755
--- a/toaster/toaster.py
+++ b/toaster/toaster.py
@@ -18,13 +18,25 @@ sys.path.insert(0, os.path.join(os.path.dirname(
     os.path.abspath(__file__)), '../'))
 from toaster.helpers import ToasterHelper
 
-WORK_DIRECTORY = '/tmp/toaster'
-POKY_URL = 'http://git.yoctoproject.org/git/poky.git'
+DEFAULT_WORK_DIRECTORY = '/tmp/toaster'
+DEFAULT_POKY_URL = 'http://git.yoctoproject.org/git/poky.git'
+DEFAULT_POKY_BRANCH = 'master'
 
-class InitToaster(unittest.TestCase):
+args = None
+help_text = """Usage examples:
+
+* To execute the Toaster test suite over poky master:
+    $ ./toaster/toaster.py
+
+* To execute the Toaster test suite over poky release:
+    $ ./toaster/toaster.py -r jethro
+"""
+
+class ToasterTests(unittest.TestCase):
     @classmethod
     def setUpClass(self):
-        self.toaster_helper = ToasterHelper(WORK_DIRECTORY, POKY_URL)
+        self.toaster_helper = ToasterHelper(args.work_directory,
+            args.url_repository, repo_ref=args.revision)
         self.toaster_helper.clone(rm=True)
         self.toaster_helper.setup()
         self.toaster_helper.start()
@@ -128,4 +140,21 @@ class InitToaster(unittest.TestCase):
         print "Builds complete!"
 
 if __name__ == "__main__":
-    unittest.main()
+    parser = argparse.ArgumentParser(description='Toaster Test suite',
+                                     formatter_class=argparse.RawTextHelpFormatter,
+                                     epilog=help_text)
+    parser.add_argument("-d", "--work-directory", default=DEFAULT_WORK_DIRECTORY,
+                        help="Directory for setup toaster")
+    parser.add_argument("-u", "--url-repository", default=DEFAULT_POKY_URL,
+                        help="GIT repository for setup toaster")
+    parser.add_argument("-r", "--revision", default=DEFAULT_POKY_BRANCH,
+                        help="GIT repository revision (branch, tag, hash) for setup toaster")
+
+    parser.add_argument("-v", "--verbose", type=int, default=1, choices=range(1, 6),
+                        help="Verbose level")
+
+    args = parser.parse_args()
+
+    runner = unittest.TextTestRunner(verbosity=args.verbose)
+    suite = unittest.TestLoader().loadTestsFromTestCase(ToasterTests)
+    runner.run(suite)
-- 
2.1.4



  parent reply	other threads:[~2016-02-09 22:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 22:45 [[PATCH][qa-tools] 10/16] Reorder source code tree, Aníbal Limón
2016-02-09 22:45 ` [[PATCH][qa-tools] 11/16] README.md: Update with information about setup, toaster and maintainence Aníbal Limón
2016-02-09 22:45 ` [[PATCH][qa-tools] 12/16] toaster/toaster.py: Add missing shebang to call python Aníbal Limón
2016-02-09 22:45 ` [[PATCH][qa-tools] 13/16] toaster: Add header to specify license to MIT Aníbal Limón
2016-02-09 22:45 ` Aníbal Limón [this message]
2016-02-09 22:45 ` [[PATCH][qa-tools] 15/16] toaster/helpers.py: Fix ToasterHelper setup method git checkout Aníbal Limón
2016-02-09 22:45 ` [[PATCH][qa-tools] 16/16] README.md: Add recommendation to use vncserver for run Toaster tests Aníbal Limón

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455057920-11174-5-git-send-email-anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=benjamin.esquivel@intel.com \
    --cc=richard.purdie@intel.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.