lua: add support for ethernet addresses to the Address class
[metze/wireshark/wip.git] / test / test.py
index 78421bd911f647788508eb9fb4bffa38c0a86983..a1c0b059fc74b7046cf828d0ac76ba3d61596a0c 100755 (executable)
@@ -50,7 +50,8 @@ def main():
     list_group = parser.add_mutually_exclusive_group()
     list_group.add_argument('-l', '--list', action='store_true', help='List tests. One of "all" or a full or partial test name.')
     list_group.add_argument('--list-suites', action='store_true', help='List all suites.')
-    list_group.add_argument('--list-cases', action='store_true', help='List all suites and cases.')
+    list_group.add_argument('--list-groups', action='store_true', help='List all suites and groups.')
+    list_group.add_argument('--list-cases', action='store_true', help='List all suites, groups, and cases.')
     parser.add_argument('-v', '--verbose', action='store_const', const=2, default=1, help='Verbose tests.')
     parser.add_argument('tests_to_run', nargs='*', metavar='test', default=['all'], help='Tests to run. One of "all" or a full or partial test name. Default is "all".')
     args = parser.parse_args()
@@ -87,12 +88,29 @@ def main():
         print('\n'.join(run_ids))
         sys.exit(0)
 
+    all_suites = set()
+    for aid in all_ids:
+        aparts = aid.split('.')
+        all_suites |= {aparts[0]}
+    config.all_suites = list(all_suites)
+    config.all_suites.sort()
+
+    all_groups = set()
+    for aid in all_ids:
+        aparts = aid.split('.')
+        if aparts[1].startswith('group_'):
+            all_groups |= {'.'.join(aparts[:2])}
+        else:
+            all_groups |= {aparts[0]}
+    config.all_groups = list(all_groups)
+    config.all_groups.sort()
+
     if args.list_suites:
-        suites = set()
-        for rid in run_ids:
-            rparts = rid.split('.')
-            suites |= {rparts[0]}
-        print('\n'.join(list(suites)))
+        print('\n'.join(config.all_suites))
+        sys.exit(0)
+
+    if args.list_groups:
+        print('\n'.join(config.all_groups))
         sys.exit(0)
 
     if args.list_cases:
@@ -109,6 +127,18 @@ def main():
         parser.print_usage()
         sys.exit(1)
 
+    #
+    if sys.stdout.encoding != 'UTF-8':
+        import codecs
+        import locale
+        sys.stderr.write('Warning: Output encoding is {0} and not UTF-8.\n'.format(sys.stdout.encoding))
+        if sys.version_info[0] >= 3:
+            sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout.buffer, 'backslashreplace')
+            sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr.buffer, 'backslashreplace')
+        else:
+            sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout, 'backslashreplace')
+            sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr, 'backslashreplace')
+
     run_suite = unittest.defaultTestLoader.loadTestsFromNames(run_ids)
     runner = unittest.TextTestRunner(verbosity=args.verbose)
     test_result = runner.run(run_suite)