unit-test.py: allow code format check only

Some OpenBMC repos use unit-test.py for the code formatting only and do
not use one of the supported build environments. Ensure this use case
still works.

Tested:
Verified all worked fine against meson based repo and also verified it
now works against openbmc-test-automation (unsupported build env)

Change-Id: Ie8af04daaee76b9ecde1e55d312d010338d1d2de
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 950f7e1..fe29daf 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -942,7 +942,10 @@
         return (instance for instance in instances if instance.probe())
 
     def build_system(self, preferred=None):
-        systems = self.build_systems()
+        systems = list(self.build_systems())
+
+        if not systems:
+            return None
 
         if preferred:
             return {type(system): system for system in systems}[preferred]
@@ -1082,6 +1085,12 @@
     if FORMAT_CODE:
         check_call_cmd("./format-code.sh", CODE_SCAN_DIR)
 
+    # Check if this repo has a supported make infrastructure
+    pkg = Package(UNIT_TEST_PKG, os.path.join(WORKSPACE, UNIT_TEST_PKG))
+    if not pkg.build_system():
+        print("No valid build system, exit")
+        sys.exit(0)
+
     prev_umask = os.umask(000)
 
     # Determine dependencies and add them