Move compliance commands into subdirectories

Move each compliance command into its own directory to avoid Go tooling
considering all the files to be a single package and complaining about
conflicting global names.

Test: go test ./...
Change-Id: I3db6310e7368bcc7fe6a3704b40a84078ed44209
diff --git a/tools/compliance/Android.bp b/tools/compliance/Android.bp
index 17ce9d9..7037670 100644
--- a/tools/compliance/Android.bp
+++ b/tools/compliance/Android.bp
@@ -19,58 +19,58 @@
 
 blueprint_go_binary {
     name: "bom",
-    srcs: ["cmd/bom.go"],
+    srcs: ["cmd/bom/bom.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/bom_test.go"],
+    testSrcs: ["cmd/bom/bom_test.go"],
 }
 
 blueprint_go_binary {
     name: "checkshare",
-    srcs: ["cmd/checkshare.go"],
+    srcs: ["cmd/checkshare/checkshare.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/checkshare_test.go"],
+    testSrcs: ["cmd/checkshare/checkshare_test.go"],
 }
 
 blueprint_go_binary {
     name: "listshare",
-    srcs: ["cmd/listshare.go"],
+    srcs: ["cmd/listshare/listshare.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/listshare_test.go"],
+    testSrcs: ["cmd/listshare/listshare_test.go"],
 }
 
 blueprint_go_binary {
     name: "dumpgraph",
-    srcs: ["cmd/dumpgraph.go"],
+    srcs: ["cmd/dumpgraph/dumpgraph.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/dumpgraph_test.go"],
+    testSrcs: ["cmd/dumpgraph/dumpgraph_test.go"],
 }
 
 blueprint_go_binary {
     name: "dumpresolutions",
-    srcs: ["cmd/dumpresolutions.go"],
+    srcs: ["cmd/dumpresolutions/dumpresolutions.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/dumpresolutions_test.go"],
+    testSrcs: ["cmd/dumpresolutions/dumpresolutions_test.go"],
 }
 
 blueprint_go_binary {
     name: "htmlnotice",
-    srcs: ["cmd/htmlnotice.go"],
+    srcs: ["cmd/htmlnotice/htmlnotice.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/htmlnotice_test.go"],
+    testSrcs: ["cmd/htmlnotice/htmlnotice_test.go"],
 }
 
 blueprint_go_binary {
     name: "shippedlibs",
-    srcs: ["cmd/shippedlibs.go"],
+    srcs: ["cmd/shippedlibs/shippedlibs.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/shippedlibs_test.go"],
+    testSrcs: ["cmd/shippedlibs/shippedlibs_test.go"],
 }
 
 blueprint_go_binary {
     name: "textnotice",
-    srcs: ["cmd/textnotice.go"],
+    srcs: ["cmd/textnotice/textnotice.go"],
     deps: ["compliance-module"],
-    testSrcs: ["cmd/textnotice_test.go"],
+    testSrcs: ["cmd/textnotice/textnotice_test.go"],
 }
 
 bootstrap_go_package {
diff --git a/tools/compliance/cmd/bom.go b/tools/compliance/cmd/bom/bom.go
similarity index 100%
rename from tools/compliance/cmd/bom.go
rename to tools/compliance/cmd/bom/bom.go
diff --git a/tools/compliance/cmd/bom_test.go b/tools/compliance/cmd/bom/bom_test.go
similarity index 96%
rename from tools/compliance/cmd/bom_test.go
rename to tools/compliance/cmd/bom/bom_test.go
index fc61bbf..163ac2a 100644
--- a/tools/compliance/cmd/bom_test.go
+++ b/tools/compliance/cmd/bom/bom_test.go
@@ -17,11 +17,22 @@
 import (
 	"bufio"
 	"bytes"
+	"fmt"
 	"os"
 	"strings"
 	"testing"
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test(t *testing.T) {
 	tests := []struct {
 		condition   string
diff --git a/tools/compliance/cmd/checkshare.go b/tools/compliance/cmd/checkshare/checkshare.go
similarity index 100%
rename from tools/compliance/cmd/checkshare.go
rename to tools/compliance/cmd/checkshare/checkshare.go
diff --git a/tools/compliance/cmd/checkshare_test.go b/tools/compliance/cmd/checkshare/checkshare_test.go
similarity index 96%
rename from tools/compliance/cmd/checkshare_test.go
rename to tools/compliance/cmd/checkshare/checkshare_test.go
index 5036aa5..4589595 100644
--- a/tools/compliance/cmd/checkshare_test.go
+++ b/tools/compliance/cmd/checkshare/checkshare_test.go
@@ -17,10 +17,21 @@
 import (
 	"bytes"
 	"fmt"
+	"os"
 	"strings"
 	"testing"
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 type outcome struct {
 	target           string
 	privacyCondition string
diff --git a/tools/compliance/cmd/dumpgraph.go b/tools/compliance/cmd/dumpgraph/dumpgraph.go
similarity index 100%
rename from tools/compliance/cmd/dumpgraph.go
rename to tools/compliance/cmd/dumpgraph/dumpgraph.go
diff --git a/tools/compliance/cmd/dumpgraph_test.go b/tools/compliance/cmd/dumpgraph/dumpgraph_test.go
similarity index 99%
rename from tools/compliance/cmd/dumpgraph_test.go
rename to tools/compliance/cmd/dumpgraph/dumpgraph_test.go
index 6555aab..516c1db 100644
--- a/tools/compliance/cmd/dumpgraph_test.go
+++ b/tools/compliance/cmd/dumpgraph/dumpgraph_test.go
@@ -17,10 +17,21 @@
 import (
 	"bytes"
 	"fmt"
+	"os"
 	"strings"
 	"testing"
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test_plaintext(t *testing.T) {
 	tests := []struct {
 		condition   string
diff --git a/tools/compliance/cmd/dumpresolutions.go b/tools/compliance/cmd/dumpresolutions/dumpresolutions.go
similarity index 100%
rename from tools/compliance/cmd/dumpresolutions.go
rename to tools/compliance/cmd/dumpresolutions/dumpresolutions.go
diff --git a/tools/compliance/cmd/dumpresolutions_test.go b/tools/compliance/cmd/dumpresolutions/dumpresolutions_test.go
similarity index 99%
rename from tools/compliance/cmd/dumpresolutions_test.go
rename to tools/compliance/cmd/dumpresolutions/dumpresolutions_test.go
index 50a6319..b698bf2 100644
--- a/tools/compliance/cmd/dumpresolutions_test.go
+++ b/tools/compliance/cmd/dumpresolutions/dumpresolutions_test.go
@@ -17,12 +17,23 @@
 import (
 	"bytes"
 	"fmt"
+	"os"
 	"strings"
 	"testing"
 
 	"android/soong/tools/compliance"
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test_plaintext(t *testing.T) {
 	tests := []struct {
 		condition   string
diff --git a/tools/compliance/cmd/htmlnotice.go b/tools/compliance/cmd/htmlnotice/htmlnotice.go
similarity index 100%
rename from tools/compliance/cmd/htmlnotice.go
rename to tools/compliance/cmd/htmlnotice/htmlnotice.go
diff --git a/tools/compliance/cmd/htmlnotice_test.go b/tools/compliance/cmd/htmlnotice/htmlnotice_test.go
similarity index 98%
rename from tools/compliance/cmd/htmlnotice_test.go
rename to tools/compliance/cmd/htmlnotice/htmlnotice_test.go
index 35a25bf..fc935c1 100644
--- a/tools/compliance/cmd/htmlnotice_test.go
+++ b/tools/compliance/cmd/htmlnotice/htmlnotice_test.go
@@ -39,6 +39,16 @@
 	libReference   = regexp.MustCompile(`^\s*<li><a href="#[^"]{32}">(.*)</a>\s*$`)
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test(t *testing.T) {
 	tests := []struct {
 		condition   string
diff --git a/tools/compliance/cmd/listshare.go b/tools/compliance/cmd/listshare/listshare.go
similarity index 100%
rename from tools/compliance/cmd/listshare.go
rename to tools/compliance/cmd/listshare/listshare.go
diff --git a/tools/compliance/cmd/listshare_test.go b/tools/compliance/cmd/listshare/listshare_test.go
similarity index 97%
rename from tools/compliance/cmd/listshare_test.go
rename to tools/compliance/cmd/listshare/listshare_test.go
index 71a0be6..91e9a43 100644
--- a/tools/compliance/cmd/listshare_test.go
+++ b/tools/compliance/cmd/listshare/listshare_test.go
@@ -16,10 +16,22 @@
 
 import (
 	"bytes"
+	"fmt"
+	"os"
 	"strings"
 	"testing"
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test(t *testing.T) {
 	type projectShare struct {
 		project    string
diff --git a/tools/compliance/cmd/shippedlibs.go b/tools/compliance/cmd/shippedlibs/shippedlibs.go
similarity index 100%
rename from tools/compliance/cmd/shippedlibs.go
rename to tools/compliance/cmd/shippedlibs/shippedlibs.go
diff --git a/tools/compliance/cmd/shippedlibs_test.go b/tools/compliance/cmd/shippedlibs/shippedlibs_test.go
similarity index 95%
rename from tools/compliance/cmd/shippedlibs_test.go
rename to tools/compliance/cmd/shippedlibs/shippedlibs_test.go
index dbf3274..b6aad6d 100644
--- a/tools/compliance/cmd/shippedlibs_test.go
+++ b/tools/compliance/cmd/shippedlibs/shippedlibs_test.go
@@ -17,11 +17,22 @@
 import (
 	"bufio"
 	"bytes"
+	"fmt"
 	"os"
 	"strings"
 	"testing"
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test(t *testing.T) {
 	tests := []struct {
 		condition   string
diff --git a/tools/compliance/cmd/textnotice.go b/tools/compliance/cmd/textnotice/textnotice.go
similarity index 100%
rename from tools/compliance/cmd/textnotice.go
rename to tools/compliance/cmd/textnotice/textnotice.go
diff --git a/tools/compliance/cmd/textnotice_test.go b/tools/compliance/cmd/textnotice/textnotice_test.go
similarity index 97%
rename from tools/compliance/cmd/textnotice_test.go
rename to tools/compliance/cmd/textnotice/textnotice_test.go
index 8b6a4b5..7993532 100644
--- a/tools/compliance/cmd/textnotice_test.go
+++ b/tools/compliance/cmd/textnotice/textnotice_test.go
@@ -28,6 +28,16 @@
 	horizontalRule = regexp.MustCompile("^===[=]*===$")
 )
 
+func TestMain(m *testing.M) {
+	// Change into the parent directory before running the tests
+	// so they can find the testdata directory.
+	if err := os.Chdir(".."); err != nil {
+		fmt.Printf("failed to change to testdata directory: %s\n", err)
+		os.Exit(1)
+	}
+	os.Exit(m.Run())
+}
+
 func Test(t *testing.T) {
 	tests := []struct {
 		condition   string