On 7/2/19 5:44 AM, Michal Koutný wrote:
On Thu, Jun 27, 2019 at 01:08:38PM -0600, Tom Hromatka 
<tom.hroma...@oracle.com> wrote:
Example test invocations:
[...]
Maybe these examples could be in the file tree itself (either one of the
Python files or README-like file).

Good idea.  I'll make a README as well.  Thanks.


diff --git a/tests/ftests/ftests.py b/tests/ftests/ftests.py
+    args = parser.parse_args()
+
+    config = Config()
+
+    if args.name:
+        config.name = args.name
+    if args.config:
+        config.container.cfg_path = args.config
+    if args.distro:
+        config.container.distro = args.distro
+    if args.release:
+        config.container.release = args.release
+    if args.arch:
+        config.container.arch = args.arch
+    if args.timeout:
+        config.container.stop_timeout = args.timeout
+    if args.loglevel:
+        log.log_level = args.loglevel
+    if args.logfile:
+        log.log_file = args.logfile
+    if args.num:
+        config.test_num = args.num
+    if args.suite:
+        config.test_suite = args.suite
+    if args.unpriv:
+        raise ValueError('Unprivileged containers are not currently supported')
+        config.container.privileged = False
+    config.verbose = args.verbose
Is the Config class worth all this copying? What about using parsed args
directly (with the defaults).

Good question.  the Config class did turn out to be more
copy-pasting than I would like.  I'll try and clean this up.

+    if passed_cnt == 1:
+        test_str = "1  test"
+        print('\t%s%s' % ('{0: <30}'.format("Passed:"), '{0: 
>15}'.format(test_str)))
+    else:
+        test_str = "%d tests" % passed_cnt
+        print('\t%s%s' % ('{0: <30}'.format("Passed:"), '{0: 
>15}'.format(test_str)))
This duplication is prone to typos and hard to maintain. What about
     "test%s".format("" if cnt == 1 else "s")
?

Agreed.  It was less than ideal.  What do you think of
this?

test_str = "%d test%s" % (passed_cnt, ' ' if passed_cnt == 1 else 's')
print('\t%s%s' % ('{0: <30}'.format("Passed:"), '{0: >15}'.format(test_str)))

It results in output like the following:

-----------------------------------------------------------------
Test Results:
        Run Date:                     Jul 03 07:58:31
        Passed:                               1 test
        Skipped:                              0 tests
        Failed:                               0 tests
-----------------------------------------------------------------

or

-----------------------------------------------------------------
Test Results:
        Run Date:                     Jul 03 07:57:22
        Passed:                               3 tests
        Skipped:                              0 tests
        Failed:                               0 tests
-----------------------------------------------------------------




_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to