[samples] Remove host test infrastructure.

Remove the scripts infrastructure used to run some sample tests on a
host workstation. All tests have been migrated to Fuchsia components.

Test: scripts/setup-and-test.sh
Change-Id: I344c8e9985c8e6996ec92cadb882043c7803477d
Reviewed-on: https://fuchsia-review.googlesource.com/c/samples/+/647654
Reviewed-by: Wayne Piekarski <waynepie@google.com>
Reviewed-by: Clayton Wilkinson <wilkinsonclay@google.com>
Commit-Queue: Dave Smith <smithdave@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index f41c941..b8f084b 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -3,66 +3,43 @@
 # found in the LICENSE file.
 
 # Top level BUILD file for gn samples
+assert(is_fuchsia)
 
-if (is_fuchsia) {
-  # When building Fuchsia packages, copy all the .far files to the root_out_dir
-  copy("default") {
-    deps = [
-      "//cipd",
-      "//src/bouncing_ball",
-      "//src/calculator",
-      "//src/hello_world",
-      "//src/rot13",
-    ]
-    sources = [
-      "${target_gen_dir}/src/bouncing_ball/bouncing_ball/bouncing_ball.far",
-      "${target_gen_dir}/src/calculator/calculator-example/calculator-example.far",
-      "${target_gen_dir}/src/hello_world/hello_world/hello_world.far",
-      "${target_gen_dir}/src/rot13/rot13-example/rot13-example.far",
-    ]
-    outputs = [ "${root_out_dir}/{{source_file_part}}" ]
-  }
+import("//third_party/fuchsia-sdk/build/test_targets.gni")
 
-  copy("tests") {
-    testonly = true
-    deps = [
-      "//src/calculator:tests",
-      "//src/hello_world:tests",
-      "//src/rot13:tests",
-    ]
-    sources = [
-      "${target_gen_dir}/src/hello_world/hello_world_test/hello_world_test.far",
-      "${target_gen_dir}/src/calculator/engine/engine_unittest/engine_unittest.far",
-      "${target_gen_dir}/src/rot13/server/rot13_unittests/rot13_unittests.far",
-    ]
-    outputs = [ "${root_out_dir}/{{source_file_part}}" ]
-  }
-} else {
-  group("default") {
-    deps = [ "//src/hello_world" ]
-  }
-
-  group("tests") {
-    testonly = true
-    deps = [ "//src/hello_world:tests" ]
-  } 
+# Simplify deployment to a package server by building and copying the sample
+# `.far` packages to the top-level build directory.
+copy("default") {
+  deps = [
+    "//cipd",
+    "//src/bouncing_ball",
+    "//src/calculator",
+    "//src/hello_world",
+    "//src/rot13",
+  ]
+  sources = [
+    "${target_gen_dir}/src/bouncing_ball/bouncing_ball/bouncing_ball.far",
+    "${target_gen_dir}/src/calculator/calculator-example/calculator-example.far",
+    "${target_gen_dir}/src/hello_world/hello_world/hello_world.far",
+    "${target_gen_dir}/src/rot13/rot13-example/rot13-example.far",
+  ]
+  outputs = [ "${root_out_dir}/{{source_file_part}}" ]
 }
 
-# build all the targets exposed by the Fuchsia sdk.
-if (is_fuchsia) {
-  import("//third_party/fuchsia-sdk/build/test_targets.gni")
-  fuchsia_sdk_test_targets("all_sdk_targets") {
-  }
-}
-
-# A generated file that lists all of the test files.
-generated_file("all_host_tests") {
+copy("tests") {
   testonly = true
   deps = [
-    "//:default",
-    "//:tests",
+    "//src/calculator:tests",
+    "//src/hello_world:tests",
+    "//src/rot13:tests",
   ]
-
-  outputs = [ "$root_build_dir/all_host_tests.txt" ]
-  data_keys = [ "host_test_name" ]
+  sources = [
+    "${target_gen_dir}/src/hello_world/hello_world_test/hello_world_test.far",
+    "${target_gen_dir}/src/calculator/engine/engine_unittest/engine_unittest.far",
+    "${target_gen_dir}/src/rot13/server/rot13_unittests/rot13_unittests.far",
+  ]
+  outputs = [ "${root_out_dir}/{{source_file_part}}" ]
 }
+
+# Build all the targets exposed by the Fuchsia SDK.
+fuchsia_sdk_test_targets("all_sdk_targets") { }
diff --git a/build/testing.gni b/build/testing.gni
deleted file mode 100644
index 0937415..0000000
--- a/build/testing.gni
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2019 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 SETUP
-# ==============================================================================
-
-# Define a test as an executable with the "testonly" flag
-# set.
-# Variable:
-template("test") {
-  executable(target_name + "_exe") {
-    forward_variables_from(invoker, "*")
-    if (!defined(deps)) {
-      deps = []
-    }
-
-    testonly = true
-    metadata = {
-      if (current_toolchain == default_toolchain) {
-        host_test_name = [ "./" + target_name + "_exe" ]
-      } else {
-        host_test_name = [ get_label_info(current_toolchain, "name") + "/" +
-                           target_name + "_exe" ]
-      }
-    }
-  }
-  group(target_name) {
-    testonly = true
-    deps = [
-      ":" + target_name + "_exe($host_toolchain)",
-    ]
-  }
-}
-
-# Test defaults.
-set_defaults("test") {
-  configs = default_executable_configs
-}
diff --git a/scripts/build.sh b/scripts/build.sh
index e46a15b..3056655 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -73,35 +73,16 @@
   cleanup
 fi
 
-# Detect if we have a valid C++11 compiler installed, this is needed to run the local tests on this build host
 # The Fuchsia binaries are built by the locally downloaded clang toolchain which includes libc++ support
-if /bin/echo -e '#include <string>\n#include <iostream>\nint main(int argc, char *argv[]) { std::string hello = "world"; std::cout << hello; }' | c++ -std=c++11 -x c++ - -o /dev/null >/dev/null 2>&1; then
-  LOCAL_TESTS=true
-else
-  echo "**** Failed to find local C++ compiler, will not compile the local non-Fuchsia tests ****"
-  LOCAL_TESTS=false
-fi
-
 echo "Building for Fuchsia on arm64..."
 "${DEPOT_TOOLS_DIR}/gn" gen "${OUT_DIR}/arm64" "--args=target_os=\"fuchsia\" target_cpu=\"arm64\" is_debug=$DEBUG_FLAG"
 "${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/arm64" default
-if "${LOCAL_TESTS}"; then
-  "${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/arm64" tests
-fi
+"${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/arm64" tests
 
 echo "Building for Fuchsia on x64..."
 "${DEPOT_TOOLS_DIR}/gn" gen "${OUT_DIR}/x64"   "--args=target_os=\"fuchsia\" target_cpu=\"x64\" is_debug=$DEBUG_FLAG"
 "${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/x64" default
-if "${LOCAL_TESTS}"; then
-  "${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/x64" tests
-fi
-
-echo "Building for linux on x64..."
-"${DEPOT_TOOLS_DIR}/gn" gen "${OUT_DIR}/linux" "--args=target_os=\"linux\" target_cpu=\"x64\" is_debug=$DEBUG_FLAG"
-if "${LOCAL_TESTS}"; then
-  "${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/linux" default
-  "${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/linux" tests
-fi
+"${DEPOT_TOOLS_DIR}/ninja" -C "${OUT_DIR}/x64" tests
 
 echo
 echo "Samples built successfully!"
diff --git a/scripts/setup-and-test.sh b/scripts/setup-and-test.sh
index 391ad1d..a34fdbc 100755
--- a/scripts/setup-and-test.sh
+++ b/scripts/setup-and-test.sh
@@ -23,10 +23,8 @@
 "${REPO_ROOT}/scripts/build.sh"
 "${REPO_ROOT}/tests/build-all-sdk-targets.sh"
 "${REPO_ROOT}/tests/run-far-tests.sh"
-"${REPO_ROOT}/tests/run-host-tests.sh"
 
 # Build again in release mode.
 "${REPO_ROOT}/scripts/build.sh" --release
 "${REPO_ROOT}/tests/build-all-sdk-targets.sh" --release
 "${REPO_ROOT}/tests/run-far-tests.sh" --release
-"${REPO_ROOT}/tests/run-host-tests.sh" --release
diff --git a/src/hello_world/BUILD.gn b/src/hello_world/BUILD.gn
index d46ceee..7c7ea8c 100644
--- a/src/hello_world/BUILD.gn
+++ b/src/hello_world/BUILD.gn
@@ -2,25 +2,24 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//third_party/fuchsia-sdk/build/component.gni")
+import("//third_party/fuchsia-sdk/build/package.gni")
+import("//third_party/fuchsia-sdk/build/test.gni")
+
 # default group
 group("hello_world") {
-  deps = [ ":hello_bin" ]
-  if (is_fuchsia) {
-    public_deps = [
-      ":hello_world_package",
-    ]
-  }
+  public_deps = [
+    ":hello_world_package",
+  ]
 }
 
 # tests group
 group("tests") {
   testonly = true
-  if (is_fuchsia) {
-    public_deps = [
-      ":hello_world_test",
-      ":hello_world_test_package",
-    ]
-  }
+  public_deps = [
+    ":hello_world_test",
+    ":hello_world_test_package",
+  ]
 }
 
 # Executable using both a static and shared lib.
@@ -48,29 +47,24 @@
   ]
 }
 
-if (is_fuchsia) {
-  import("//third_party/fuchsia-sdk/build/component.gni")
-  import("//third_party/fuchsia-sdk/build/package.gni")
-  import("//third_party/fuchsia-sdk/build/test.gni")
+# Fuchsia components and packages
+fuchsia_component("component") {
+  manifest_output_name = "hello_world"
+  manifest = "meta/hello_world.cml"
+  data_deps = [ ":hello_bin" ]
+}
 
-  fuchsia_component("component") {
-    manifest_output_name = "hello_world"
-    manifest = "meta/hello_world.cml"
-    data_deps = [ ":hello_bin" ]
-  }
+fuchsia_package("hello_world_package") {
+  package_name = "hello_world"
+  deps = [ ":component" ]
+}
 
-  fuchsia_package("hello_world_package") {
-    package_name = "hello_world"
-    deps = [ ":component" ]
-  }
+fuchsia_test("hello_world_test") {
+  manifest = "meta/hello_world_test.cml"
 
-  fuchsia_test("hello_world_test") {
-    manifest = "meta/hello_world_test.cml"
-
-    sources = [ "test/hello_test.cc" ]
-    deps = [
-      "//third_party/googletest:gtest",
-      "//third_party/googletest:gtest_main",
-    ]
-  }
+  sources = [ "test/hello_test.cc" ]
+  deps = [
+    "//third_party/googletest:gtest",
+    "//third_party/googletest:gtest_main",
+  ]
 }
diff --git a/src/rot13/server/BUILD.gn b/src/rot13/server/BUILD.gn
index 6180991..b12a61c 100644
--- a/src/rot13/server/BUILD.gn
+++ b/src/rot13/server/BUILD.gn
@@ -2,15 +2,17 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//third_party/fuchsia-sdk/build/component.gni")
+import("//third_party/fuchsia-sdk/build/package.gni")
+import("//third_party/fuchsia-sdk/build/test.gni")
+
 #tests group
 group("tests") {
   testonly = true
-  if (is_fuchsia) {
-    public_deps = [
-      ":rot13_unittests",
-      ":rot13_unittests_package",
-    ]
-  }
+  public_deps = [
+    ":rot13_unittests",
+    ":rot13_unittests_package",
+  ]
 }
 
 # Keep the app in a lib component so it can be reused by tests
@@ -48,33 +50,28 @@
   ]
 }
 
-if (is_fuchsia) {
-  import("//third_party/fuchsia-sdk/build/component.gni")
-  import("//third_party/fuchsia-sdk/build/package.gni")
-  import("//third_party/fuchsia-sdk/build/test.gni")
+# Fuchsia components and packages
+fuchsia_component("server_component") {
+  manifest = "meta/rot13_server.cml"
+  data_deps = [
+    ":rot13_server_bin",
+  ]
+}
 
-  fuchsia_component("server_component") {
-    manifest = "meta/rot13_server.cml"
-    data_deps = [
-      ":rot13_server_bin",
-    ]
-  }
+fuchsia_package("rot13_server") {
+  deps = [
+    ":server_component",
+  ]
+}
 
-  fuchsia_package("rot13_server") {
-    deps = [
-      ":server_component",
-    ]
-  }
-
-  fuchsia_test("rot13_unittests") {
-    manifest = "meta/rot13_unittests.cml"
-    sources = [
-      "rot13_unittests.cc",
-    ]
-    deps = [
-      ":impl_lib",
-      "//third_party/googletest:gtest",
-      "//third_party/googletest:gtest_main",
-    ]
-  }
+fuchsia_test("rot13_unittests") {
+  manifest = "meta/rot13_unittests.cml"
+  sources = [
+    "rot13_unittests.cc",
+  ]
+  deps = [
+    ":impl_lib",
+    "//third_party/googletest:gtest",
+    "//third_party/googletest:gtest_main",
+  ]
 }
diff --git a/tests/run-host-tests.sh b/tests/run-host-tests.sh
deleted file mode 100755
index 48ed526..0000000
--- a/tests/run-host-tests.sh
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/bash
-# Copyright 2019 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.
-
-set -eu # Error checking
-err_print() {
-  echo "Error on line $1"
-}
-trap 'err_print $LINENO' ERR
-DEBUG_LINE() {
-    "$@"
-}
-
-TEST_SRC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-
-# Common functions.
-# shellcheck disable=SC1090
-source "${TEST_SRC_DIR}/../scripts/common.sh" || exit $?
-REPO_ROOT=$(get_gn_root) # finds path to REPO_ROOT
-
-ROOT_OUT_DIR="out"
-
-function usage {
-  echo "Usage: $0"
-  echo "  [--release]"
-  echo "    Uses the out-release/ directory to run tests."
-}
-
-# Parse command line
-for i in "$@"
-do
-case $i in
-    --release)
-    ROOT_OUT_DIR="${ROOT_OUT_DIR}-release"
-    ;;
-    *)
-    # unknown option
-    usage
-    exit 1
-    ;;
-esac
-done
-
-echo
-echo "==== Run host tests ===="
-for dir in "${REPO_ROOT}/${ROOT_OUT_DIR}"/*; do
-  [[ -e "$dir" ]] || break # Handle case with empty out directory
-
-  while IFS= read -r testname
-  do
-    "$dir/$testname"
-  done < "$dir/all_host_tests.txt"
-done
-
-echo
-echo "Success!"