]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
test: Check for patches in recipe rather than relying on the existence of a branch
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 19 May 2017 17:03:07 +0000 (18:03 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 19 May 2017 17:03:07 +0000 (18:03 +0100)
Implement Recipe.HasPatches(), which returns true if any of the trees
has patches.

Call it in test.go:test() before applying and/or building.

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
recipe.go
test.go

index 6edc0f831d21c28363c0881787c04dfa863cdee1..f48e1c94940a346ce215f0b0fbcfd72140ef751f 100644 (file)
--- a/recipe.go
+++ b/recipe.go
@@ -66,6 +66,20 @@ func (r *Recipe) ForEachTree(f func(Tree) error) (err error) {
        return
 }
 
+// Return 'true' if any tree recipe has patches
+// FIXME: Should this be *all* specified tree recipes instead?
+func (r *Recipe) HasPatches() (has bool) {
+       r.ForEachTree(func (t Tree) error {
+               tr := r.Recipes[t]
+               if tr.HasPatches() {
+                       has = true
+                       return fmt.Errorf("Stop processing")
+               }
+               return nil
+       })
+       return
+}
+
 func (r *Recipe) MakePatches(prefix string, sync bool) (count int, err error) {
        branch, baseline := r.branchName(prefix)
 
diff --git a/test.go b/test.go
index b29a4e228ba7c83ab18488047cc0d8ba0dcc4c89..e39447091752e25553f100cea9ac41d97e1e6ecf 100644 (file)
--- a/test.go
+++ b/test.go
@@ -50,6 +50,11 @@ func test(xsa *XSAMeta, args []string, apply bool, build bool) (ret int) {
                        return 1
                }
 
+               if !r.HasPatches() {
+                       fmt.Printf("No patches for version %s, skipping\n", v)
+                       continue
+               }
+
                if apply {
                        err := r.Apply(prefix)
                        if err != nil {