[testsharder] Define constants for Test.OS values
Change-Id: I30d10af74a1d7db4bc1578dfbf5d657f9125c368
diff --git a/cmd/testrunner/main.go b/cmd/testrunner/main.go
index 96292e7..447c4b1 100644
--- a/cmd/testrunner/main.go
+++ b/cmd/testrunner/main.go
@@ -124,11 +124,11 @@
var linux, mac, fuchsia, unknown []testsharder.Test
for _, test := range tests {
switch test.OS {
- case "fuchsia":
+ case testsharder.Fuchsia:
fuchsia = append(fuchsia, test)
- case "linux":
+ case testsharder.Linux:
linux = append(linux, test)
- case "mac":
+ case testsharder.Mac:
mac = append(mac, test)
default:
unknown = append(unknown, test)
diff --git a/testsharder/test_spec.go b/testsharder/test_spec.go
index 64bd37b..5cb537f 100644
--- a/testsharder/test_spec.go
+++ b/testsharder/test_spec.go
@@ -25,6 +25,16 @@
TestDepsSuffix = ".spec.data"
)
+// OS is an operating system that a test may run in.
+type OS string
+
+// Acceptable OS constants.
+const (
+ Linux OS = "linux"
+ Fuchsia OS = "fuchsia"
+ Mac OS = "mac"
+)
+
// TestSpec is the specification for a single test and the environments it
// should be executed in.
type TestSpec struct {
@@ -48,7 +58,7 @@
Location string `json:"location"`
// OS is the operating system in which this test must be executed.
- OS string `json:"os"`
+ OS OS `json:"os"`
// Command is the command line to run to execute this test.
Command []string `json:"command,omitempty"`