blob: 7affe876f62d5214e52a61d905c42ffe869d127d [file] [log] [blame]
# 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.
import("//build/go/go_binary.gni")
import("//build/go/go_library.gni")
import("//build/go/go_test.gni")
import("//build/testing/host_test_data.gni")
go_library("testsharder_lib") {
sources = [
"doc.go",
"durations.go",
"durations_test.go",
"ffx_deps.go",
"ffx_deps_test.go",
"images.go",
"images_test.go",
"postprocess.go",
"postprocess_test.go",
"preprocess.go",
"preprocess_test.go",
"shard.go",
"shard_test.go",
"test.go",
"test_modifier.go",
"test_modifier_test.go",
]
deps = [
"//src/sys/pkg/bin/pm/build",
"//third_party/golibs:golang.org/x/exp",
"//tools/build",
"//tools/lib/color",
"//tools/lib/ffxutil",
"//tools/lib/logger",
"//tools/testing/runtests",
]
}
go_library("main") {
source_dir = "cmd"
sources = [
"main.go",
"main_test.go",
]
deps = [
":testsharder_lib",
"//third_party/golibs:golang.org/x/exp",
"//tools/lib/flagmisc",
]
}
go_binary("testsharder") {
library = ":main"
}
if (is_host) {
go_test("testsharder_lib_tests") {
library = ":testsharder_lib"
deps = [ "//third_party/golibs:github.com/google/go-cmp" ]
}
# TODO(olivernewman): Consider running the test executable locally to generate
# a depfile so it's not necessary to copy-paste these names.
_golden_tests = [
"affected nonhermetic tests",
"affected tests",
"arbitrary dimensions",
"boot test with modifiers",
"hermetic deps",
"max shards per env",
"mixed device types",
"multiply",
"multiply affected test",
"multiply affected tests with large number of runs",
"multiply unaffected hermetic tests",
"no tests",
"run all tests if no affected tests",
"run all tests if empty affected tests",
"run all tests if no affected and affected only",
"sharding by time",
"skip unaffected tests",
"target test count",
"test list with tags",
"various modifiers",
]
_golden_dir = "${target_gen_dir}/goldens"
host_test_data("copy_golden_files") {
sources = []
foreach(test_name, _golden_tests) {
_file_name = string_replace(test_name, " ", "_")
sources += [ "cmd/testdata/${_file_name}.golden.json" ]
}
outputs = [ "${_golden_dir}/{{source_file_part}}" ]
}
go_test("testsharder_tests") {
library = ":main"
deps = [
"//third_party/golibs:github.com/google/go-cmp",
"//tools/lib/jsonutil",
]
non_go_deps = [ ":copy_golden_files" ]
args = [
"-goldens-dir",
rebase_path(_golden_dir, root_build_dir),
]
}
}
group("tests") {
testonly = true
deps = [
":testsharder_lib_tests($host_toolchain)",
":testsharder_tests($host_toolchain)",
]
}