[testsharder] Begin soft transition s/location/path
Change-Id: I93e478aa57d3d9491b3c92f1f25cad659be649d1
diff --git a/cmd/testrunner/tester.go b/cmd/testrunner/tester.go
index 4ae0a43..f7a171e 100644
--- a/cmd/testrunner/tester.go
+++ b/cmd/testrunner/tester.go
@@ -32,8 +32,8 @@
func (t *SubprocessTester) Test(ctx context.Context, test testsharder.Test, stdout io.Writer, stderr io.Writer) error {
var command []string
- if len(test.Location) > 0 {
- command = []string{test.Location}
+ if len(test.Path) > 0 {
+ command = []string{test.Path}
} else {
command = test.Command
}
@@ -109,7 +109,7 @@
}
func (t *FuchsiaTester) Test(ctx context.Context, test testsharder.Test, stdout io.Writer, stderr io.Writer) error {
- name := path.Base(test.Location)
+ name := path.Base(test.Path)
test.Command = []string{"runtests", "-t", name, "-o", t.remoteOutputDir + "runtests"}
return t.delegate.Test(ctx, test, stdout, stderr)
}
diff --git a/testsharder/shard.go b/testsharder/shard.go
index 3b92672..ea70c9b 100644
--- a/testsharder/shard.go
+++ b/testsharder/shard.go
@@ -45,7 +45,7 @@
for _, env := range envs {
specs := envToSuites[env]
sort.Slice(specs, func(i, j int) bool {
- return specs[i].Test.Location < specs[i].Test.Location
+ return specs[i].Test.Path < specs[i].Test.Path
})
var tests []Test
for _, spec := range specs {
diff --git a/testsharder/test_spec.go b/testsharder/test_spec.go
index 1e8237a..91e4aff 100644
--- a/testsharder/test_spec.go
+++ b/testsharder/test_spec.go
@@ -39,12 +39,15 @@
// (e.g., //garnet/bin/foo/tests:foo_tests).
Name string `json:"name"`
- // (Deprecated. Use `Command` instead)
+ // TODO(joshuaseaton): Remove and replace by `Path`.
//
// Location is a unique reference to a test: for example, a filesystem
// path or a Fuchsia URI.
Location string `json:"location"`
+ // Path is the path to the test.
+ Path string `json:"path"`
+
// OS is the operating system in which this test must be executed.
OS OS `json:"os"`
@@ -65,8 +68,8 @@
if spec.Test.Name == "" {
return fmt.Errorf("A test spec's test must have a non-empty name")
}
- if spec.Test.Location == "" {
- return fmt.Errorf("A test spec's test must have a non-empty location")
+ if spec.Test.Path == "" && spec.Test.Location == "" {
+ return fmt.Errorf("A test spec's test must have a non-empty path")
}
if spec.Test.OS == "" {
return fmt.Errorf("A test spec's test must have a non-empty OS")
@@ -124,6 +127,10 @@
}
for i, _ := range specs {
+ if specs[i].Path == "" {
+ specs[i].Path = specs[i].Location
+ }
+
if specs[i].DepsFile == "" {
continue
}
diff --git a/testsharder/test_spec_test.go b/testsharder/test_spec_test.go
index 1312942..f62a7f6 100644
--- a/testsharder/test_spec_test.go
+++ b/testsharder/test_spec_test.go
@@ -50,37 +50,37 @@
var specFoo1 = TestSpec{
Test: Test{
- Name: "//obsidian/bin/foo:foo_unittests",
- Location: "/system/test/foo_unittests",
- OS: Fuchsia,
- Command: []string{"/system/test/foo_unittests", "bar", "baz"},
+ Name: "//obsidian/bin/foo:foo_unittests",
+ Path: "/system/test/foo_unittests",
+ OS: Fuchsia,
+ Command: []string{"/system/test/foo_unittests", "bar", "baz"},
},
Envs: []Environment{qemuEnv},
}
var specFoo2 = TestSpec{
Test: Test{
- Name: "//obsidian/bin/foo:foo_integration_tests",
- Location: "/system/test/foo_integration_tests",
- OS: Fuchsia,
+ Name: "//obsidian/bin/foo:foo_integration_tests",
+ Path: "/system/test/foo_integration_tests",
+ OS: Fuchsia,
},
Envs: []Environment{qemuEnv, nucEnv},
}
var specBar = TestSpec{
Test: Test{
- Name: "//obsidian/lib/bar:bar_tests",
- Location: "/system/test/bar_tests",
- OS: Fuchsia,
+ Name: "//obsidian/lib/bar:bar_tests",
+ Path: "/system/test/bar_tests",
+ OS: Fuchsia,
},
Envs: []Environment{qemuEnv},
}
var specBaz = TestSpec{
Test: Test{
- Name: "//obsidian/public/lib/baz:baz_host_tests",
- Location: "/$root_build_dir/baz_host_tests",
- OS: Linux,
+ Name: "//obsidian/public/lib/baz:baz_host_tests",
+ Path: "/$root_build_dir/baz_host_tests",
+ OS: Linux,
},
Envs: []Environment{linuxEnv, macEnv},
}
@@ -148,12 +148,12 @@
func TestValidateTestSpecs(t *testing.T) {
noTestNameSpec := TestSpec{
Test: Test{
- Location: "/system/test/baz_tests",
- OS: Linux,
+ Path: "/system/test/baz_tests",
+ OS: Linux,
},
Envs: []Environment{qemuEnv},
}
- noTestLocationSpec := TestSpec{
+ noTestPathSpec := TestSpec{
Test: Test{
Name: "//obsidian/public/lib/baz:baz_tests",
OS: Linux,
@@ -162,15 +162,15 @@
}
noOSSpec := TestSpec{
Test: Test{
- Name: "//obsidian/bin/foo:foo_unittests",
- Location: "/system/test/foo_unittests",
+ Name: "//obsidian/bin/foo:foo_unittests",
+ Path: "/system/test/foo_unittests",
},
}
badEnvSpec := TestSpec{
Test: Test{
- Name: "//obsidian/public/lib/baz:baz_tests",
- Location: "/system/test/baz_tests",
- OS: Linux,
+ Name: "//obsidian/public/lib/baz:baz_tests",
+ Path: "/system/test/baz_tests",
+ OS: Linux,
},
Envs: []Environment{
Environment{
@@ -197,10 +197,10 @@
t.Run("invalid specs are invalidated", func(t *testing.T) {
invalidSpecLists := [][]TestSpec{
- {noOSSpec}, {noTestNameSpec}, {noTestLocationSpec}, {badEnvSpec},
- {noTestNameSpec, noTestLocationSpec}, {noTestNameSpec, badEnvSpec},
- {noTestLocationSpec, badEnvSpec},
- {noTestNameSpec, noTestLocationSpec, badEnvSpec},
+ {noOSSpec}, {noTestNameSpec}, {noTestPathSpec}, {badEnvSpec},
+ {noTestNameSpec, noTestPathSpec}, {noTestNameSpec, badEnvSpec},
+ {noTestPathSpec, badEnvSpec},
+ {noTestNameSpec, noTestPathSpec, badEnvSpec},
}
for _, list := range invalidSpecLists {
if err := ValidateTestSpecs(list, platforms); err == nil {