moveconfig: Allow adding unit tests
authorSimon Glass <sjg@chromium.org>
Sat, 18 Dec 2021 15:09:45 +0000 (08:09 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 24 Jan 2022 22:36:29 +0000 (17:36 -0500)
Add a -t option to run unit tests in this program. So far, there is none.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/moveconfig.py

index 3695897..71a7736 100755 (executable)
@@ -14,6 +14,7 @@ import asteval
 import collections
 import copy
 import difflib
+import doctest
 import filecmp
 import fnmatch
 import glob
@@ -28,6 +29,7 @@ import sys
 import tempfile
 import threading
 import time
+import unittest
 
 from buildman import bsettings
 from buildman import kconfiglib
@@ -1621,6 +1623,13 @@ def main():
 
     (options, configs) = parser.parse_args()
 
+    if options.test:
+        sys.argv = [sys.argv[0]]
+        fail, count = doctest.testmod()
+        if fail:
+            return 1
+        unittest.main()
+
     if len(configs) == 0 and not any((options.force_sync, options.build_db,
                                       options.imply)):
         parser.print_usage()