From 2496a5871c28fb8be149b3e23f4d3d1b86f09ef6 Mon Sep 17 00:00:00 2001
From: CentOS CI <noreply@ci.centos.org>
Date: Nov 11 2019 18:05:04 +0000
Subject: [PATCH 1/3] Test defaults and overrides with .update_from_defaults_directory()


Signed-off-by: CentOS CI <noreply@ci.centos.org>

---

diff --git a/Dockerfile b/Dockerfile
index 2a12b0b..430eeb3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,6 +7,5 @@ RUN dnf -y --setopt=install_weak_deps=False install \
         make \
         python3-six \
         python3-libmodulemd \
-        python3-libmodulemd1 \
         python3-GitPython \
     && dnf -y clean all
diff --git a/tests/validate.py b/tests/validate.py
index 680d0c6..cb77ab6 100755
--- a/tests/validate.py
+++ b/tests/validate.py
@@ -102,9 +102,11 @@ def main():
         script_dir = os.path.abspath(sys.argv[1])
     else:
         script_dir = os.path.dirname(os.path.realpath(__file__))
+    defaults_dir = os.path.abspath(os.path.join(script_dir, '..'))
+    overrides_dir = os.path.join(defaults_dir, 'overrides')
 
     # Get the repo we're running in
-    repo = git.Repo(script_dir, search_parent_directories=True)
+    repo = git.Repo(defaults_dir, search_parent_directories=True)
 
     # Get the list of files in this repository
     files = [x for (x, y) in repo.index.entries.keys()]
@@ -120,7 +122,6 @@ def main():
             exclusions.append(line.strip())
 
     # Validate all of the files
-    merger = Modulemd.ModuleIndexMerger()
     for file in files:
         excluded = False
         for excl in exclusions:
@@ -132,16 +133,6 @@ def main():
             if not valid:
                 error("{} failed to validate".format(file))
                 result = os.EX_DATAERR
-            else:
-                try:
-                    merger.associate_index(idx, 0)
-                except GLib.Error as e:
-                    error(
-                        "Could not merge {} with other defaults: {}".format(
-                            file, e.message
-                        )
-                    )
-                    result = os.EX_DATAERR
 
     if result == os.EX_DATAERR:
         return result
@@ -150,7 +141,10 @@ def main():
     # conflicts arise that weren't detected by the above tests. This should be
     # impossible.
     try:
-        idx = merger.resolve_ext(strict_default_streams=True)
+        idx = Modulemd.ModuleIndex()
+        idx.update_from_defaults_directory(path=defaults_dir,
+                                           overrides_path=overrides_dir,
+                                           strict=True)
     except GLib.Error as e:
         error("Could not merge all defaults: {}".format(e.message))
         result = os.EX_DATAERR
@@ -158,6 +152,11 @@ def main():
     if result == os.EX_OK:
         info("Merging all of the documents encountered no errors.")
 
+    print("\nDefault streams:")
+    print("================")
+    for m, s in idx.get_default_streams().items():
+        print("{}:{}".format(m, s))
+
     return result
 
 

From 577c57bef1f28a0a523b7803bddebce518d2abcc Mon Sep 17 00:00:00 2001
From: CentOS CI <noreply@ci.centos.org>
Date: Nov 11 2019 18:14:58 +0000
Subject: [PATCH 2/3] Disable buildroot defaults for ant, gimp, maven and scala


Signed-off-by: CentOS CI <noreply@ci.centos.org>

---

diff --git a/overrides/ant.yaml b/overrides/ant.yaml
new file mode 100644
index 0000000..e973976
--- /dev/null
+++ b/overrides/ant.yaml
@@ -0,0 +1,6 @@
+document: modulemd-defaults
+version: 1
+data:
+    module: ant
+    profiles:
+        1.10: [default]
diff --git a/overrides/gimp.yaml b/overrides/gimp.yaml
new file mode 100644
index 0000000..4b92365
--- /dev/null
+++ b/overrides/gimp.yaml
@@ -0,0 +1,6 @@
+document: modulemd-defaults
+version: 1
+data:
+    module: gimp
+    profiles:
+        2.10: [default]
diff --git a/overrides/maven.yaml b/overrides/maven.yaml
new file mode 100644
index 0000000..e6244b5
--- /dev/null
+++ b/overrides/maven.yaml
@@ -0,0 +1,8 @@
+document: modulemd-defaults
+version: 1
+data:
+    module: maven
+    profiles:
+        3.5: [default]
+        3.6: [default]
+    modified: 201910251749
diff --git a/overrides/scala.yaml b/overrides/scala.yaml
new file mode 100644
index 0000000..e28a3ed
--- /dev/null
+++ b/overrides/scala.yaml
@@ -0,0 +1,6 @@
+document: modulemd-defaults
+version: 1
+data:
+    module: scala
+    profiles:
+        2.10: [default]

From 540c1bb660b3ea671f442a2e429db6d2bc1a7244 Mon Sep 17 00:00:00 2001
From: CentOS CI <noreply@ci.centos.org>
Date: Nov 11 2019 18:33:02 +0000
Subject: [PATCH 3/3] Test and display both runtime and buildroot defaults


Signed-off-by: CentOS CI <noreply@ci.centos.org>

---

diff --git a/tests/validate.py b/tests/validate.py
index cb77ab6..b6094af 100755
--- a/tests/validate.py
+++ b/tests/validate.py
@@ -143,6 +143,22 @@ def main():
     try:
         idx = Modulemd.ModuleIndex()
         idx.update_from_defaults_directory(path=defaults_dir,
+                                           strict=True)
+    except GLib.Error as e:
+        error("Could not merge all defaults: {}".format(e.message))
+        result = os.EX_DATAERR
+
+    if result == os.EX_OK:
+        info("Merging all of the documents encountered no errors.")
+
+    print("\nDefault streams (Runtime):")
+    print("================")
+    for m, s in idx.get_default_streams().items():
+        print("{}:{}".format(m, s))
+
+    try:
+        idx = Modulemd.ModuleIndex()
+        idx.update_from_defaults_directory(path=defaults_dir,
                                            overrides_path=overrides_dir,
                                            strict=True)
     except GLib.Error as e:
@@ -152,7 +168,7 @@ def main():
     if result == os.EX_OK:
         info("Merging all of the documents encountered no errors.")
 
-    print("\nDefault streams:")
+    print("\nDefault streams (Buildroot):")
     print("================")
     for m, s in idx.get_default_streams().items():
         print("{}:{}".format(m, s))

