Refactor generateManifest infra tool

- Changed from using bash/perl to using go.
- Now "if" statements in .gjson files can be stacked, and there can be
  conditional "or" statements inside, like |#if defined(A || B)|.
- Go tests were added to make sure that the generateManifest tool
  continues to work as expected.
- Updated docs to reflect the fact that the manifest is now generated
  with a different tool, and Go is now required in the build phase.

Change-Id: Id866d1a49a7ab4aac2dcf8d188c56bb8254a80de
diff --git a/generateManifest_test.go b/generateManifest_test.go
new file mode 100644
index 0000000..57f2f56
--- /dev/null
+++ b/generateManifest_test.go
@@ -0,0 +1,79 @@
+package main
+
+import (
+  "bytes"
+  "crypto/sha256"
+  "encoding/hex"
+  "io"
+  "os"
+  "testing"
+)
+
+type Manifest struct {
+  name string
+  templateFile string
+  expectedFile string
+  dependencies []string
+}
+
+func TestManifestConversions(t *testing.T) {
+  testManifests := []Manifest{
+    {
+      name: "ManifestSmall",
+      templateFile: "testdata/manifest_small1.gjson",
+      expectedFile: "testdata/manifest_small1_expected.json",
+      dependencies: []string{"AAA", "BBB", "D"},
+    },
+    {
+      name: "ManifestFrozenChromium",
+      templateFile: "testdata/manifest_frozen.gjson",
+      expectedFile: "testdata/manifest_frozen_chromium_expected.json",
+      dependencies: []string{"CHROMIUM"},
+    },
+    {
+      name: "ManifestFrozenGecko",
+      templateFile: "testdata/manifest_frozen.gjson",
+      expectedFile: "testdata/manifest_frozen_gecko_expected.json",
+      dependencies: []string{"GECKO"},
+    },
+  }
+
+  for _, m := range testManifests {
+    t.Run(m.name, func(t *testing.T) {
+      template, err := os.Open(m.templateFile)
+      if err != nil {
+        t.Fatalf("Can't open test file: %v", err)
+      }
+      defer template.Close()
+
+      expected, err := os.Open(m.expectedFile)
+      if err != nil {
+        t.Fatalf("Can't open expected file: %v", err)
+      }
+      defer expected.Close()
+
+      dest := bytes.NewBufferString("")
+
+      WriteManifest(template, dest, m.dependencies)
+      if err != nil {
+        t.Fatal(err)
+      }
+
+      h1 := sha256.New()
+      if _, err := io.Copy(h1, dest); err != nil {
+        t.Fatalf("Can't prepare sha256 sum of the result: %v", err)
+      }
+
+      h2 := sha256.New()
+      if _, err := io.Copy(h2, expected); err != nil {
+        t.Fatalf("Can't prepare sha256 sum of the expected file: %v", err)
+      }
+
+      sum1 := h1.Sum(nil)
+      sum2 := h2.Sum(nil)
+      if bytes.Compare(sum1, sum2) != 0 {
+        t.Fatalf("The expected manifest file (sha256: %v) differs from what we got (sha256: %v).", hex.EncodeToString(sum2), hex.EncodeToString(sum1))
+      }
+    })
+  }
+}