[fuchsia] Delete testsharder code that was moved to tools

We're still publishing this code to CIPD unnecessarily, and
we no longer use this version for anything

Change-Id: Iadc768b118db79ea88b114641057582356be5e0a
diff --git a/cmd/testsharder/main.go b/cmd/testsharder/main.go
deleted file mode 100644
index 1a50878..0000000
--- a/cmd/testsharder/main.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-package main
-
-import (
-	"encoding/json"
-	"flag"
-	"log"
-	"os"
-
-	"fuchsia.googlesource.com/infra/infra/fuchsia"
-	"fuchsia.googlesource.com/infra/infra/fuchsia/testexec"
-)
-
-var (
-	// The path to the Fuchsia build output directory.
-	fuchsiaBuildDir string
-
-	// The filepath to write output to. If unspecified, stdout is used.
-	outputFile string
-
-	// Label is a key on which to filter environments, which are labeled.
-	label string
-)
-
-func init() {
-	flag.StringVar(&fuchsiaBuildDir, "fuchsia-build-dir", "", "(required) path to the fuchsia build output directory")
-	flag.StringVar(&outputFile, "output-file", "", "path to a file which will contain the shards as JSON, default is stdout")
-	flag.StringVar(&label, "label", "", "environment label on which to filter")
-}
-
-func main() {
-	flag.Parse()
-
-	if fuchsiaBuildDir == "" {
-		log.Fatal("must specify a Fuchsia build output directory")
-	}
-
-	// Load spec files.
-	pkgs, err := fuchsia.LoadPackages(fuchsiaBuildDir)
-	if err != nil {
-		log.Fatal(err)
-	}
-	hostTests, err := fuchsia.LoadHostTests(fuchsiaBuildDir)
-	if err != nil {
-		log.Fatal(err)
-	}
-	specs, err := testexec.LoadTestSpecs(fuchsiaBuildDir, pkgs, hostTests)
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	// Load test platform environments.
-	platforms, err := testexec.LoadPlatforms(fuchsiaBuildDir)
-	if err != nil {
-		log.Fatal(err)
-	}
-
-	// Verify that the produced specs specify valid test environments.
-	if err = testexec.ValidateTestSpecs(specs, platforms); err != nil {
-		log.Fatal(err)
-	}
-
-	// Create shards and write them to an output file if specifed, else stdout.
-	shards := testexec.MakeShards(specs, label)
-	f := os.Stdout
-	if outputFile != "" {
-		var err error
-		f, err = os.Create(outputFile)
-		if err != nil {
-			log.Fatalf("unable to create %s: %v", outputFile, err)
-		}
-		defer f.Close()
-	}
-
-	encoder := json.NewEncoder(f)
-	encoder.SetIndent("", "  ")
-	if err := encoder.Encode(&shards); err != nil {
-		log.Fatal("failed to encode shards: ", err)
-	}
-}
diff --git a/fuchsia/build.go b/fuchsia/build.go
deleted file mode 100644
index 0b88f86..0000000
--- a/fuchsia/build.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// This file includes build-specific concepts.
-
-package fuchsia
-
-import (
-	"encoding/json"
-	"os"
-	"path/filepath"
-)
-
-const (
-	// PackageManifestName is the name of the manifest of fuchsia package
-	// targets included in a build.
-	packageManifestName = "packages.json"
-
-	// HostTestManifestName is the name of the manifest of host-side test
-	// targets included in a build.
-	hostTestManifestName = "host_tests.json"
-
-	// PlatformManifestName is the name of the manifest of available test
-	// platforms.
-	PlatformManifestName = "platforms.json"
-)
-
-// Target provides information about a GN target.
-type Target struct {
-	// BuildDir is a relative path in the Fuchsia build directory to the location
-	// of the target's generated file directory.
-	BuildDir string `json:"build_dir"`
-
-	// Dir is the source-relative directory of the target (e.g.,
-	// //garnet/dir/of/build-dot-gn-file).
-	Dir string `json:"dir"`
-
-	// Name is the name of the target.
-	Name string `json:"name"`
-}
-
-type pkgManifest struct {
-	Pkgs []Target `json:"packages"`
-}
-
-// LoadPackages loads a list of packages targets from JSON package manifest
-// produced by the build, given the root of the build directory.
-func LoadPackages(fuchsiaBuildDir string) ([]Target, error) {
-	manifestPath := filepath.Join(fuchsiaBuildDir, packageManifestName)
-	manifestFile, err := os.Open(manifestPath)
-	if err != nil {
-		return nil, err
-	}
-	defer manifestFile.Close()
-	var pkgManifest pkgManifest
-	err = json.NewDecoder(manifestFile).Decode(&pkgManifest)
-	return pkgManifest.Pkgs, err
-}
-
-// LoadHostTests loads a list of host test targets from a JSON host test
-// manifest produced by the build, given the root of the build directory.
-func LoadHostTests(fuchsiaBuildDir string) ([]Target, error) {
-	manifestPath := filepath.Join(fuchsiaBuildDir, hostTestManifestName)
-	manifestFile, err := os.Open(manifestPath)
-	// TODO(IN-823): As of writing this, the host test manifest does not exist. Until it
-	// exists make non-existence not a point of failure.
-	if os.IsNotExist(err) {
-		return []Target{}, nil
-	} else if err != nil {
-		return nil, err
-	}
-	defer manifestFile.Close()
-	var hostTests []Target
-	err = json.NewDecoder(manifestFile).Decode(&hostTests)
-	return hostTests, err
-}
diff --git a/fuchsia/testexec/doc.go b/fuchsia/testexec/doc.go
deleted file mode 100644
index 23025ae..0000000
--- a/fuchsia/testexec/doc.go
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Test authors in the Fuchsia source will specify `environments`in GN within
-// the packages they define their tests. These specifications will be printed
-// to disk in JSON-form during a build.
-//
-// This package is concerned with reading in those specifications, validating
-// that they correspond to valid test environments supported by the
-// infrastructure, and ultimately sharding the associated tests along the lines
-// of those environments.
-
-package testexec
diff --git a/fuchsia/testexec/environment.go b/fuchsia/testexec/environment.go
deleted file mode 100644
index 1c86c7f..0000000
--- a/fuchsia/testexec/environment.go
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// The GN environments specified by test authors in the Fuchsia source
-// correspond directly to the Environment struct defined here.
-//
-// Note that by "platforms" we mean a specific group of dimension sets which
-// correspond to the currently available test platforms supported by the
-// infrastructure.
-package testexec
-
-import (
-	"encoding/json"
-	"io/ioutil"
-	"path/filepath"
-
-	"fuchsia.googlesource.com/infra/infra/fuchsia"
-)
-
-// Environment describes the full environment a test requires.
-type Environment struct {
-	// Dimensions gives the Swarming dimensions a test wishes to target.
-	Dimensions DimensionSet `json:"dimensions"`
-
-	// Label is a label given to an environment on which the testsharder may filter.
-	Label string `json:"label,omitempty"`
-}
-
-// Name returns a name calculated from its specfied properties.
-func (env Environment) Name() string {
-	// For now, this just returns the device type or OS; later it will be more clever.
-	if env.Dimensions.DeviceType != "" {
-		return env.Dimensions.DeviceType
-	} else {
-		return env.Dimensions.OS
-	}
-}
-
-// DimensionSet encapsulate the Swarming dimensions a test wishes to target.
-type DimensionSet struct {
-	// DeviceType represents the class of device the test should run on.
-	// This is a required field.
-	DeviceType string `json:"device_type,omitempty"`
-
-	// The OS to run the test on (e.g., "Linux" or "Mac"). Used for host-side testing.
-	OS string `json:"os,omitempty"`
-}
-
-// ResolvesTo gives a partial ordering on DimensionSets in which one resolves to
-// another if the former's dimensions are given the latter.
-func (dims DimensionSet) resolvesTo(other DimensionSet) bool {
-	if dims.DeviceType != "" && dims.DeviceType != other.DeviceType {
-		return false
-	}
-	if dims.OS != "" && dims.OS != other.OS {
-		return false
-	}
-	return true
-}
-
-// LoadPlatforms loads the list of test platforms specified as a JSON list
-// produced by a build, given the root of the build directory.
-func LoadPlatforms(fuchsiaBuildDir string) ([]DimensionSet, error) {
-	platformManifestPath := filepath.Join(fuchsiaBuildDir, fuchsia.PlatformManifestName)
-	bytes, err := ioutil.ReadFile(platformManifestPath)
-	if err != nil {
-		return nil, err
-	}
-	var platforms []DimensionSet
-	if err = json.Unmarshal(bytes, &platforms); err != nil {
-		return nil, err
-	}
-	return platforms, err
-}
diff --git a/fuchsia/testexec/shard.go b/fuchsia/testexec/shard.go
deleted file mode 100644
index 54a8a51..0000000
--- a/fuchsia/testexec/shard.go
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-package testexec
-
-import (
-	"sort"
-)
-
-// Shard represents a set of tests with a common execution environment.
-type Shard struct {
-	// Name is the identifier for the shard.
-	Name string `json:"name"`
-
-	// Tests is the set of test to be executed in this shard.
-	Tests []Test `json:"tests"`
-
-	// Env is a generalized notion of the execution environment for the shard.
-	Env Environment `json:"environment"`
-
-	// HostDeps is a map which associates a host-side test to its runtime dependencies.
-	HostDeps map[string][]string `json:"host_deps,omitempty"`
-}
-
-// MakeShards is the core algorithm to this tool. It takes a set of test specs and produces
-// a set of shards which may then be converted into Swarming tasks. Environments with a
-// label different from the provided will be ignored.
-//
-// This is the most naive algorithm at the moment. It just merges all tests together which
-// have the same environment setting into the same shard.
-func MakeShards(specs []TestSpec, label string) []*Shard {
-	// Collect the order of the shards so our shard ordering is deterministic with
-	// respect to the input.
-	envToSuites := make(map[Environment][]TestSpec)
-	envs := []Environment{}
-	for _, spec := range specs {
-		for _, env := range spec.Envs {
-			if env.Label != label {
-				continue
-			}
-			if _, ok := envToSuites[env]; !ok {
-				envs = append(envs, env)
-			}
-			envToSuites[env] = append(envToSuites[env], spec)
-		}
-	}
-	shards := make([]*Shard, 0, len(envs))
-	for _, env := range envs {
-		specs := envToSuites[env]
-		sort.Slice(specs, func(i, j int) bool {
-			return specs[i].Test.Location < specs[i].Test.Location
-		})
-
-		shard := Shard{
-			Name:  env.Name(),
-			Tests: []Test{},
-			Env:   env,
-		}
-		hostDeps := make(map[string][]string)
-		for _, spec := range specs {
-			shard.Tests = append(shard.Tests, spec.Test)
-			if len(spec.HostDeps) > 0 {
-				hostDeps[spec.Test.Location] = spec.HostDeps
-			}
-		}
-		if len(hostDeps) > 0 {
-			shard.HostDeps = hostDeps
-		}
-		shards = append(shards, &shard)
-	}
-	return shards
-}
diff --git a/fuchsia/testexec/shard_test.go b/fuchsia/testexec/shard_test.go
deleted file mode 100644
index b5c0e30..0000000
--- a/fuchsia/testexec/shard_test.go
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-package testexec_test
-
-import (
-	"fmt"
-	"reflect"
-	"testing"
-
-	"fuchsia.googlesource.com/infra/infra/fuchsia/testexec"
-)
-
-// Note that just printing a list of shard pointers will print a list of memory addresses,
-// which would make for an unhelpful error message.
-func assertEqual(t *testing.T, expected, actual []*testexec.Shard) {
-	if !reflect.DeepEqual(expected, actual) {
-		errMsg := "expected:\n"
-		for _, shard := range expected {
-			errMsg += fmt.Sprintf("%+v,\n", shard)
-		}
-		errMsg += "actual:\n"
-		for _, shard := range actual {
-			errMsg += fmt.Sprintf("%+v,\n", shard)
-		}
-		t.Fatalf(errMsg)
-	}
-}
-
-func TestMakeShards(t *testing.T) {
-	test1 := testexec.Test{Location: "/path/to/binary"}
-	test2 := testexec.Test{Location: "/path/to/binary2"}
-	hostDeps1 := []string{"host/side/dep/1a", "host/side/dep/1b"}
-	hostDeps2 := []string{"host/side/dep/2a", "host/side/dep/2b"}
-	env1 := testexec.Environment{
-		Dimensions: testexec.DimensionSet{DeviceType: "QEMU"},
-	}
-	env2 := testexec.Environment{
-		Dimensions: testexec.DimensionSet{DeviceType: "NUC"},
-	}
-	env3 := testexec.Environment{
-		Dimensions: testexec.DimensionSet{DeviceType: "NUC"},
-		Label:      "LABEL",
-	}
-	spec1 := testexec.TestSpec{
-		Test: test1,
-		Envs: []testexec.Environment{env1},
-	}
-	spec2 := testexec.TestSpec{
-		Test: test1,
-		Envs: []testexec.Environment{env1},
-	}
-	spec3 := testexec.TestSpec{
-		Test: test2,
-		Envs: []testexec.Environment{env1, env2},
-	}
-	spec4 := testexec.TestSpec{
-		Test: test2,
-		Envs: []testexec.Environment{env1, env2, env3},
-	}
-	t.Run("Ensure that environments have names", func(t *testing.T) {
-		// This will in turn ensure that the associated shards too have
-		// names.
-		if env1.Name() == "" {
-			t.Fatalf("Environment\n%+v\n has an empty name", env1)
-		}
-		if env2.Name() == "" {
-			t.Fatalf("Environment\n%+v\n has an empty name", env2)
-		}
-	})
-
-	t.Run("Ensure env shared", func(t *testing.T) {
-		actual := testexec.MakeShards([]testexec.TestSpec{spec1, spec2, spec3}, "")
-		expected := []*testexec.Shard{
-			// Ensure that the order of the shards is the order in which their
-			// corresponding environments appear in the input. This is the simplest
-			// deterministic order we can produce for the shards.
-			{
-				Name: env1.Name(),
-				// Ensure that we actually specify the test _twice_, that is, don't
-				// necessarily deduplicate tests for a shared environment.
-				Tests: []testexec.Test{test1, test1, test2},
-				Env:   env1,
-			},
-			{
-				Name:  env2.Name(),
-				Tests: []testexec.Test{test2},
-				Env:   env2,
-			},
-		}
-		assertEqual(t, expected, actual)
-	})
-
-	t.Run("Ensure label respected", func(t *testing.T) {
-		actual := testexec.MakeShards([]testexec.TestSpec{spec1, spec2, spec3, spec4}, env3.Label)
-		expected := []*testexec.Shard{
-			{
-				Name:  env3.Name(),
-				Tests: []testexec.Test{test2},
-				Env:   env3,
-			},
-		}
-		assertEqual(t, expected, actual)
-	})
-
-	t.Run("Ensure host deps are aggregated", func(t *testing.T) {
-		linuxEnv := testexec.Environment{
-			Dimensions: testexec.DimensionSet{OS: "Linux"},
-		}
-		macEnv := testexec.Environment{
-			Dimensions: testexec.DimensionSet{OS: "Mac"},
-		}
-		actual := testexec.MakeShards([]testexec.TestSpec{
-			{
-				Test:     test1,
-				Envs:     []testexec.Environment{linuxEnv},
-				HostDeps: hostDeps1,
-			},
-			{
-				Test:     test2,
-				Envs:     []testexec.Environment{linuxEnv},
-				HostDeps: hostDeps2,
-			},
-			{
-				Test:     test1,
-				Envs:     []testexec.Environment{macEnv},
-				HostDeps: hostDeps1,
-			},
-		}, "")
-		expected := []*testexec.Shard{
-			{
-				Name:  linuxEnv.Name(),
-				Tests: []testexec.Test{test1, test2},
-				Env:   linuxEnv,
-				HostDeps: map[string][]string{
-					test1.Location: hostDeps1,
-					test2.Location: hostDeps2,
-				},
-			},
-			{
-				Name:  macEnv.Name(),
-				Tests: []testexec.Test{test1},
-				Env:   macEnv,
-				HostDeps: map[string][]string{
-					test1.Location: hostDeps1,
-				},
-			},
-		}
-		assertEqual(t, expected, actual)
-	})
-}
diff --git a/fuchsia/testexec/test_spec.go b/fuchsia/testexec/test_spec.go
deleted file mode 100644
index aeffb6f..0000000
--- a/fuchsia/testexec/test_spec.go
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-package testexec
-
-import (
-	"bufio"
-	"encoding/json"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"os"
-	"path/filepath"
-	"strings"
-
-	"fuchsia.googlesource.com/infra/infra/fuchsia"
-)
-
-const (
-	// TestSpecSuffix is the file suffix identifying a test spec.
-	TestSpecSuffix = ".spec.json"
-
-	// HostDepsSuffix is the file suffix identifying a file giving the host-side runtime
-	// depedencies of a test.
-	HostDepsSuffix = ".spec.data"
-)
-
-// TestSpec is the specification for a single test and the environments it
-// should be executed in.
-type TestSpec struct {
-	// Test is the test that this specification is for.
-	Test `json:"test"`
-
-	// Envs is a set of environments that the test should be executed in.
-	Envs []Environment `json:"environments"`
-
-	// HostDeps are the host-side runtime depedencies of the test.
-	HostDeps []string
-}
-
-// Test encapsulates details about a particular test.
-type Test struct {
-	// Name is the full, GN source-relative target name of the test
-	// (e.g., //garnet/bin/foo/tests:foo_tests).
-	Name string `json:"name"`
-
-	// Location is a unique reference to a test: for example, a filesystem
-	// path or a Fuchsia URI.
-	Location string `json:"location"`
-}
-
-func (spec TestSpec) validateAgainst(platforms []DimensionSet) error {
-	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")
-	}
-
-	resolvesToOneOf := func(env Environment, platforms []DimensionSet) bool {
-		for _, platform := range platforms {
-			if env.Dimensions.resolvesTo(platform) {
-				return true
-			}
-		}
-		return false
-	}
-
-	var badEnvs []Environment
-	for _, env := range spec.Envs {
-		if !resolvesToOneOf(env, platforms) {
-			badEnvs = append(badEnvs, env)
-		}
-	}
-	if len(badEnvs) > 0 {
-		return fmt.Errorf(
-			`the following environments of test\n%+v were malformed
-			or did not match any available test platforms:\n%+v`,
-			spec.Test, badEnvs)
-	}
-	return nil
-}
-
-// ValidateTestSpecs validates a list of test specs against a list of test
-// platform dimension sets.
-func ValidateTestSpecs(specs []TestSpec, platforms []DimensionSet) error {
-	errMsg := ""
-	for _, spec := range specs {
-		if err := spec.validateAgainst(platforms); err != nil {
-			errMsg += fmt.Sprintf("\n%v", err)
-		}
-	}
-	if errMsg != "" {
-		return fmt.Errorf(errMsg)
-	}
-	return nil
-}
-
-// PkgTestSpecDir returns the directory where associated test specs may be written,
-// given a package target.
-func PkgTestSpecDir(fuchsiaBuildDir string, pkg fuchsia.Target) string {
-	return filepath.Join(fuchsiaBuildDir, pkg.BuildDir, pkg.Name)
-}
-
-// HostTestSpecDir returns the directory where associated test specs may be written,
-// given a host test target.
-func HostTestSpecDir(fuchsiaBuildDir string, hostTest fuchsia.Target) string {
-	return filepath.Join(fuchsiaBuildDir, hostTest.BuildDir)
-}
-
-func readLinesFromFile(path string) ([]string, error) {
-	fd, err := os.Open(path)
-	defer fd.Close()
-	if err != nil {
-		return nil, fmt.Errorf("failed to open %s: %v", path, err)
-	}
-
-	reader := bufio.NewReader(fd)
-	lines := []string{}
-	for {
-		line, err := reader.ReadString('\n')
-		if err == io.EOF {
-			break
-		} else if err != nil {
-			return nil, fmt.Errorf("failed to read line from %s: %v", path, err)
-		}
-		line = strings.TrimRight(line, "\n")
-		lines = append(lines, line)
-	}
-	return lines, nil
-}
-
-// LoadTestSpecs loads a set of test specifications from a list of Fuchsia
-// package targets and a list of host test targets.
-func LoadTestSpecs(fuchsiaBuildDir string, pkgs, hostTests []fuchsia.Target) ([]TestSpec, error) {
-	// First, load the test specs associated to the given packages.
-	//
-	// It is guaranteed that a test spec will be written to the build directory of the
-	// corresponding package its test was defined in: specifically, it will be put in
-	// <target_out_dir of the test package>/<test package name>.
-	specs := []TestSpec{}
-
-	decodeTestSpecs := func(targets []fuchsia.Target, testSpecDir func(string, fuchsia.Target) string) error {
-		for _, target := range targets {
-			specDir := testSpecDir(fuchsiaBuildDir, target)
-			// If the associated test spec directory does not exist, the package specified no
-			// tests.
-			if _, err := os.Stat(specDir); os.IsNotExist(err) {
-				continue
-			}
-
-			// Non-recursively enumerate the files in this directory; it's guaranteed that
-			// the test specs will be found here if generated.
-			entries, err := ioutil.ReadDir(specDir)
-			if err != nil {
-				return err
-			}
-
-			for _, entry := range entries {
-				if entry.IsDir() {
-					continue
-				}
-
-				// Open, read, and parse any test spec found. Look for any associated host-side
-				// runtime depedencies.
-				path := filepath.Join(specDir, entry.Name())
-				if strings.HasSuffix(path, TestSpecSuffix) {
-					specFile, err := os.Open(path)
-					defer specFile.Close()
-					if err != nil {
-						return fmt.Errorf("failed to open %s: %v", path, err)
-					}
-
-					var spec TestSpec
-					if err := json.NewDecoder(specFile).Decode(&spec); err != nil {
-						return fmt.Errorf("failed to decode %s: %v", path, err)
-					}
-
-					// If there is not an associated host deps file, there are no host deps, which
-					// is okay and not a failure mode.
-					hostDepsPath := strings.Replace(path, TestSpecSuffix, HostDepsSuffix, 1)
-					_, err = os.Stat(hostDepsPath)
-					if err == nil {
-						deps, err := readLinesFromFile(hostDepsPath)
-						if err != nil {
-							return err
-						}
-						spec.HostDeps = deps
-					} else if !os.IsNotExist(err) {
-						return err
-					}
-					specs = append(specs, spec)
-				}
-			}
-		}
-		return nil
-	}
-
-	if err := decodeTestSpecs(pkgs, PkgTestSpecDir); err != nil {
-		return nil, err
-	}
-	if err := decodeTestSpecs(hostTests, HostTestSpecDir); err != nil {
-		return nil, err
-	}
-
-	return specs, nil
-}
diff --git a/fuchsia/testexec/test_spec_test.go b/fuchsia/testexec/test_spec_test.go
deleted file mode 100644
index 3ad8d9d..0000000
--- a/fuchsia/testexec/test_spec_test.go
+++ /dev/null
@@ -1,334 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-package testexec_test
-
-import (
-	"encoding/json"
-	"fmt"
-	"io/ioutil"
-	"os"
-	"path/filepath"
-	"reflect"
-	"sort"
-	"testing"
-
-	"fuchsia.googlesource.com/infra/infra/fuchsia"
-	"fuchsia.googlesource.com/infra/infra/fuchsia/testexec"
-)
-
-var qemuPlatform = testexec.DimensionSet{
-	DeviceType: "QEMU",
-}
-
-var nucPlatform = testexec.DimensionSet{
-	DeviceType: "NUC",
-}
-
-var linuxPlatform = testexec.DimensionSet{
-	OS: "Linux",
-}
-
-var macPlatform = testexec.DimensionSet{
-	OS: "Mac",
-}
-
-var qemuEnv = testexec.Environment{
-	Dimensions: qemuPlatform,
-}
-
-var nucEnv = testexec.Environment{
-	Dimensions: nucPlatform,
-}
-
-var linuxEnv = testexec.Environment{
-	Dimensions: linuxPlatform,
-}
-
-var macEnv = testexec.Environment{
-	Dimensions: macPlatform,
-}
-
-var specFoo1 = testexec.TestSpec{
-	Test: testexec.Test{
-		Name:     "//obsidian/bin/foo:foo_unittests",
-		Location: "/system/test/foo_unittests",
-	},
-	Envs: []testexec.Environment{qemuEnv},
-}
-
-var specFoo2 = testexec.TestSpec{
-	Test: testexec.Test{
-		Name:     "//obsidian/bin/foo:foo_integration_tests",
-		Location: "/system/test/foo_integration_tests",
-	},
-	Envs: []testexec.Environment{qemuEnv, nucEnv},
-}
-
-var specBar = testexec.TestSpec{
-	Test: testexec.Test{
-		Name:     "//obsidian/lib/bar:bar_tests",
-		Location: "/system/test/bar_tests",
-	},
-	Envs: []testexec.Environment{qemuEnv},
-}
-
-var specBaz = testexec.TestSpec{
-	Test: testexec.Test{
-		Name:     "//obsidian/public/lib/baz:baz_host_tests",
-		Location: "/$root_build_dir/baz_host_tests",
-	},
-	Envs: []testexec.Environment{linuxEnv, macEnv},
-}
-
-// FuchsiaBuildDir is a struct representing the root build directory of a fuchsia
-// checkout.
-type fuchsiaBuildDir struct {
-	root string
-	t    *testing.T
-}
-
-func newFuchsiaBuildDir(t *testing.T) *fuchsiaBuildDir {
-	root, err := ioutil.TempDir("", "fuchsia-build-dir")
-	if err != nil {
-		t.Fatalf("could not create fuchsia build directory: %v", err)
-	}
-	return &fuchsiaBuildDir{
-		root: root,
-		t:    t,
-	}
-}
-
-// CreateLayout takes a list of package and host test targets, and creates the associated
-// directory layout.
-func (bd fuchsiaBuildDir) createLayout(pkgs []fuchsia.Target, hostTests []fuchsia.Target) {
-	for _, pkg := range pkgs {
-		specDir := testexec.PkgTestSpecDir(bd.root, pkg)
-		if err := os.MkdirAll(specDir, os.ModePerm); err != nil {
-			bd.t.Fatalf("could not create test spec directory for package \"%s\": %v", pkg.Name, err)
-		}
-	}
-	for _, hostTest := range hostTests {
-		specDir := testexec.HostTestSpecDir(bd.root, hostTest)
-		if err := os.MkdirAll(specDir, os.ModePerm); err != nil {
-			bd.t.Fatalf("could not create test spec directory for host test \"%s\": %v", hostTest.Name, err)
-		}
-	}
-}
-
-func writeTestSpec(t *testing.T, spec testexec.TestSpec, path string) {
-	bytes, err := json.Marshal(&spec)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if err = ioutil.WriteFile(path, bytes, os.ModePerm); err != nil {
-		t.Fatalf("could not write test spec to %s: %v", path, err)
-	}
-}
-
-func testSpecFilename(basename string) string {
-	return basename + testexec.TestSpecSuffix
-}
-
-func TestLoadTestSpecs(t *testing.T) {
-	areEqual := func(a, b []testexec.TestSpec) bool {
-		stringify := func(spec testexec.TestSpec) string {
-			return fmt.Sprintf("%#v", spec)
-		}
-		sort := func(list []testexec.TestSpec) {
-			sort.Slice(list[:], func(i, j int) bool {
-				return stringify(list[i]) < stringify(list[j])
-			})
-		}
-		sort(a)
-		sort(b)
-		return reflect.DeepEqual(a, b)
-	}
-
-	pkgFoo := fuchsia.Target{
-		BuildDir: "obj/obsidian/bin/foo",
-		Name:     "foo",
-	}
-	pkgBar := fuchsia.Target{
-		BuildDir: "obj/obsidian/lib/bar",
-		Name:     "bar",
-	}
-	hostTestBaz := fuchsia.Target{
-		BuildDir: "host_x64/obj/obsidian/public/lib/baz",
-		Name:     "baz",
-	}
-	pkgs := []fuchsia.Target{pkgFoo, pkgBar}
-	hostTests := []fuchsia.Target{hostTestBaz}
-
-	correctSpecsLoad := func(t *testing.T, expected []testexec.TestSpec, fuchsiaBuildDir string) {
-		actual, err := testexec.LoadTestSpecs(fuchsiaBuildDir, pkgs, hostTests)
-		if err != nil {
-			t.Fatalf("error while loading test specs: %v", err)
-		}
-		if !areEqual(expected, actual) {
-			t.Fatalf("test specs not properly loaded:\nexpected:\n%+v\nactual:\n%+v", expected, actual)
-		}
-	}
-
-	t.Run("test specs are found", func(t *testing.T) {
-		bd := newFuchsiaBuildDir(t)
-		defer os.RemoveAll(bd.root)
-		bd.createLayout(pkgs, hostTests)
-
-		specDirFoo := testexec.PkgTestSpecDir(bd.root, pkgFoo)
-		specDirBar := testexec.PkgTestSpecDir(bd.root, pkgBar)
-		specDirBaz := testexec.HostTestSpecDir(bd.root, hostTestBaz)
-		writeTestSpec(t, specFoo1, filepath.Join(specDirFoo, testSpecFilename("foo_unittest")))
-		writeTestSpec(t, specFoo2, filepath.Join(specDirFoo, testSpecFilename("foo_integration_tests")))
-		writeTestSpec(t, specBar, filepath.Join(specDirBar, testSpecFilename("bar_tests")))
-		writeTestSpec(t, specBaz, filepath.Join(specDirBaz, testSpecFilename("baz_host_tests")))
-
-		expected := []testexec.TestSpec{specFoo1, specFoo2, specBar, specBaz}
-		correctSpecsLoad(t, expected, bd.root)
-	})
-
-	t.Run("test specs in wrong location are ignored", func(t *testing.T) {
-		bd := newFuchsiaBuildDir(t)
-		defer os.RemoveAll(bd.root)
-		bd.createLayout(pkgs, hostTests)
-
-		specDirFoo := testexec.PkgTestSpecDir(bd.root, pkgFoo)
-		specDirBar := testexec.PkgTestSpecDir(bd.root, pkgBar)
-		specDirBaz := testexec.HostTestSpecDir(bd.root, hostTestBaz)
-		nonSpecDir := filepath.Join(bd.root, "other-package")
-		if err := os.MkdirAll(nonSpecDir, os.ModePerm); err != nil {
-			t.Fatalf("failed to create a directory outside of the package manifest: %v", err)
-		}
-
-		writeTestSpec(t, specFoo1, filepath.Join(specDirFoo, testSpecFilename("foo_unittests")))
-		writeTestSpec(t, specFoo2, filepath.Join(nonSpecDir, testSpecFilename("other_tests")))
-		writeTestSpec(t, specBar, filepath.Join(specDirBar, testSpecFilename("bar_tests")))
-		writeTestSpec(t, specBaz, filepath.Join(specDirBaz, testSpecFilename("baz_host_tests")))
-
-		expected := []testexec.TestSpec{specFoo1, specBar, specBaz}
-		correctSpecsLoad(t, expected, bd.root)
-	})
-
-	t.Run("test specs with wrong extension are ignored", func(t *testing.T) {
-		bd := newFuchsiaBuildDir(t)
-		defer os.RemoveAll(bd.root)
-		bd.createLayout(pkgs, hostTests)
-
-		specDirFoo := testexec.PkgTestSpecDir(bd.root, pkgFoo)
-		specDirBar := testexec.PkgTestSpecDir(bd.root, pkgBar)
-		specDirBaz := testexec.HostTestSpecDir(bd.root, hostTestBaz)
-		writeTestSpec(t, specFoo1, filepath.Join(specDirFoo, "bad_extension1.json"))
-		writeTestSpec(t, specFoo2, filepath.Join(specDirFoo, testSpecFilename("good extension")))
-		writeTestSpec(t, specBar, filepath.Join(specDirBar, "bad_extension2.spec"))
-		writeTestSpec(t, specBaz, filepath.Join(specDirBaz, testSpecFilename("another_good_extension")))
-
-		expected := []testexec.TestSpec{specFoo2, specBaz}
-		correctSpecsLoad(t, expected, bd.root)
-	})
-
-	t.Run("malformed test specs raise error", func(t *testing.T) {
-		bd := newFuchsiaBuildDir(t)
-		defer os.RemoveAll(bd.root)
-		bd.createLayout(pkgs, hostTests)
-
-		specDirFoo := testexec.PkgTestSpecDir(bd.root, pkgFoo)
-		specDirBar := testexec.PkgTestSpecDir(bd.root, pkgBar)
-
-		writeTestSpec(t, specFoo1, filepath.Join(specDirFoo, testSpecFilename("foo_unittests")))
-		if err := ioutil.WriteFile(filepath.Join(specDirFoo, testSpecFilename("foo_integration_tests")),
-			[]byte("{I am not a test spec}"), os.ModePerm); err != nil {
-			t.Fatalf("could not write malformed test spec: %v", err)
-		}
-		writeTestSpec(t, specBar, filepath.Join(specDirBar, testSpecFilename("bar_tests")))
-
-		_, err := testexec.LoadTestSpecs(bd.root, pkgs, hostTests)
-		if err == nil {
-			t.Fatalf("malformed test spec did not raise an error")
-		}
-	})
-
-	t.Run("host-side deps are loaded", func(t *testing.T) {
-		bd := newFuchsiaBuildDir(t)
-		defer os.RemoveAll(bd.root)
-		bd.createLayout(pkgs, hostTests)
-
-		specDirBaz := testexec.HostTestSpecDir(bd.root, hostTestBaz)
-		writeTestSpec(t, specBaz, filepath.Join(specDirBaz, testSpecFilename("baz_host_tests")))
-
-		hostDeps := []string{"path/to/dep/1", "path/to/dep/2"}
-		hostDepsPath := filepath.Join(specDirBaz, "baz_host_tests" + testexec.HostDepsSuffix)
-		fd, err := os.Create(hostDepsPath)
-		defer fd.Close()
-		if err != nil {
-			t.Fatal(err)
-		}
-		for _, dep := range hostDeps {
-			_, err := fd.WriteString(dep + "\n")
-			if err != nil {
-				t.Fatal(err)
-			}
-		}
-		specBazWithDeps := specBaz
-		specBazWithDeps.HostDeps = hostDeps
-
-		expected := []testexec.TestSpec{specBazWithDeps}
-		correctSpecsLoad(t, expected, bd.root)
-	})
-
-}
-
-func TestValidateTestSpecs(t *testing.T) {
-	noTestNameSpec := testexec.TestSpec{
-		Test: testexec.Test{
-			Location: "/system/test/baz_tests",
-		},
-		Envs: []testexec.Environment{qemuEnv},
-	}
-	noTestLocationSpec := testexec.TestSpec{
-		Test: testexec.Test{
-			Name: "//obsidian/public/lib/baz:baz_tests",
-		},
-		Envs: []testexec.Environment{qemuEnv},
-	}
-	badEnvSpec := testexec.TestSpec{
-		Test: testexec.Test{
-			Name:     "//obsidian/public/lib/baz:baz_tests",
-			Location: "/system/test/baz_tests",
-		},
-		Envs: []testexec.Environment{
-			testexec.Environment{
-				Dimensions: testexec.DimensionSet{
-					DeviceType: "NON-EXISTENT-DEVICE",
-				},
-			},
-		},
-	}
-	platforms := []testexec.DimensionSet{qemuPlatform, nucPlatform}
-
-	t.Run("valid specs are validated", func(t *testing.T) {
-		validSpecLists := [][]testexec.TestSpec{
-			{specFoo1}, {specFoo2}, {specBar},
-			{specFoo1, specFoo2}, {specFoo1, specBar}, {specFoo2, specBar},
-			{specFoo1, specFoo2, specBar},
-		}
-		for _, list := range validSpecLists {
-			if err := testexec.ValidateTestSpecs(list, platforms); err != nil {
-				t.Fatalf("valid specs marked as invalid: %+v: %v", list, err)
-			}
-		}
-	})
-
-	t.Run("invalid specs are invalidated", func(t *testing.T) {
-		invalidSpecLists := [][]testexec.TestSpec{
-			{noTestNameSpec}, {noTestLocationSpec}, {badEnvSpec},
-			{noTestNameSpec, noTestLocationSpec}, {noTestNameSpec, badEnvSpec},
-			{noTestLocationSpec, badEnvSpec},
-			{noTestNameSpec, noTestLocationSpec, badEnvSpec},
-		}
-		for _, list := range invalidSpecLists {
-			if err := testexec.ValidateTestSpecs(list, platforms); err == nil {
-				t.Fatalf("invalid specs marked as valid: %+v", list)
-			}
-		}
-	})
-}
diff --git a/packages_to_publish.json b/packages_to_publish.json
index 18f8e03..d87efbd 100644
--- a/packages_to_publish.json
+++ b/packages_to_publish.json
@@ -2,6 +2,5 @@
   "fuchsia.googlesource.com/infra/infra/cmd/buildsetlookup",
   "fuchsia.googlesource.com/infra/infra/cmd/catapult",
   "fuchsia.googlesource.com/infra/infra/cmd/lkgs",
-  "fuchsia.googlesource.com/infra/infra/cmd/swarm_docker",
-  "fuchsia.googlesource.com/infra/infra/cmd/testsharder"
+  "fuchsia.googlesource.com/infra/infra/cmd/swarm_docker"
 ]