[tint][build] Fix GN tint_build_unittests=false

Make sure all test targets are conditioned.

Change-Id: Ibb9108990afcad8d5dd74a19e9f2eea511bcddf1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/147503
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index 66d6fc4..15788a4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 import("scripts/dawn_overrides_with_defaults.gni")
+import("tint_overrides_with_defaults.gni")
 
 group("all") {
   testonly = true
@@ -21,9 +22,11 @@
     "src/dawn/native:webgpu_dawn",
     "src/dawn/tests",
     "src/tint/api",
-    "src/tint/cmd/test",
     "src/tint/fuzzers",
   ]
+  if (tint_build_unittests) {
+    deps += [ "src/tint/cmd/test" ]
+  }
   if (dawn_standalone) {
     deps += [
       "src/dawn/samples",
diff --git a/src/tint/cmd/common/BUILD.gn b/src/tint/cmd/common/BUILD.gn
index a46bbba..d6b738d 100644
--- a/src/tint/cmd/common/BUILD.gn
+++ b/src/tint/cmd/common/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("common") {
   sources = [
     "generate_external_texture_bindings.cc",
@@ -70,34 +74,35 @@
     ]
   }
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "generate_external_texture_bindings_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/api/options",
-    "${tint_src_dir}/cmd/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "generate_external_texture_bindings_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/api/options",
+      "${tint_src_dir}/cmd/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/cmd/test/BUILD.gn b/src/tint/cmd/test/BUILD.gn
index be97e62..a1be8db 100644
--- a/src/tint/cmd/test/BUILD.gn
+++ b/src/tint/cmd/test/BUILD.gn
@@ -27,96 +27,97 @@
 if (tint_build_unittests) {
   import("//testing/test.gni")
 }
-
-test("test") {
-  output_name = "tint_unittests"
-  sources = [ "main_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api",
-    "${tint_src_dir}/cmd/common:unittests",
-    "${tint_src_dir}/lang/core:unittests",
-    "${tint_src_dir}/lang/core/constant:unittests",
-    "${tint_src_dir}/lang/core/intrinsic:unittests",
-    "${tint_src_dir}/lang/core/type:unittests",
-    "${tint_src_dir}/lang/wgsl:unittests",
-    "${tint_src_dir}/lang/wgsl/ast:unittests",
-    "${tint_src_dir}/lang/wgsl/ast/transform:unittests",
-    "${tint_src_dir}/lang/wgsl/helpers:unittests",
-    "${tint_src_dir}/lang/wgsl/inspector:unittests",
-    "${tint_src_dir}/lang/wgsl/program:unittests",
-    "${tint_src_dir}/lang/wgsl/reader/parser:unittests",
-    "${tint_src_dir}/lang/wgsl/resolver:unittests",
-    "${tint_src_dir}/lang/wgsl/sem:unittests",
-    "${tint_src_dir}/lang/wgsl/writer/ast_printer:unittests",
-    "${tint_src_dir}/utils/cli:unittests",
-    "${tint_src_dir}/utils/command:unittests",
-    "${tint_src_dir}/utils/containers:unittests",
-    "${tint_src_dir}/utils/diagnostic:unittests",
-    "${tint_src_dir}/utils/file:unittests",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/ice:unittests",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/macros:unittests",
-    "${tint_src_dir}/utils/math:unittests",
-    "${tint_src_dir}/utils/memory:unittests",
-    "${tint_src_dir}/utils/reflection:unittests",
-    "${tint_src_dir}/utils/result:unittests",
-    "${tint_src_dir}/utils/rtti:unittests",
-    "${tint_src_dir}/utils/strconv:unittests",
-    "${tint_src_dir}/utils/symbol:unittests",
-    "${tint_src_dir}/utils/text:unittests",
-    "${tint_src_dir}/utils/traits:unittests",
-  ]
-
-  if (tint_build_glsl_writer) {
-    deps += [ "${tint_src_dir}/lang/glsl/writer/ast_printer:unittests" ]
-  }
-
-  if (tint_build_hlsl_writer) {
-    deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_printer:unittests" ]
-  }
-
-  if (tint_build_ir) {
-    deps += [
-      "${tint_src_dir}/lang/core/ir:unittests",
-      "${tint_src_dir}/lang/core/ir/transform:unittests",
-      "${tint_src_dir}/lang/wgsl/reader/program_to_ir:unittests",
-      "${tint_src_dir}/lang/wgsl/writer/ir_to_program:unittests",
+if (tint_build_unittests) {
+  test("test") {
+    output_name = "tint_unittests"
+    sources = [ "main_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api",
+      "${tint_src_dir}/cmd/common:unittests",
+      "${tint_src_dir}/lang/core:unittests",
+      "${tint_src_dir}/lang/core/constant:unittests",
+      "${tint_src_dir}/lang/core/intrinsic:unittests",
+      "${tint_src_dir}/lang/core/type:unittests",
+      "${tint_src_dir}/lang/wgsl:unittests",
+      "${tint_src_dir}/lang/wgsl/ast:unittests",
+      "${tint_src_dir}/lang/wgsl/ast/transform:unittests",
+      "${tint_src_dir}/lang/wgsl/helpers:unittests",
+      "${tint_src_dir}/lang/wgsl/inspector:unittests",
+      "${tint_src_dir}/lang/wgsl/program:unittests",
+      "${tint_src_dir}/lang/wgsl/reader/parser:unittests",
+      "${tint_src_dir}/lang/wgsl/resolver:unittests",
+      "${tint_src_dir}/lang/wgsl/sem:unittests",
+      "${tint_src_dir}/lang/wgsl/writer/ast_printer:unittests",
+      "${tint_src_dir}/utils/cli:unittests",
+      "${tint_src_dir}/utils/command:unittests",
+      "${tint_src_dir}/utils/containers:unittests",
+      "${tint_src_dir}/utils/diagnostic:unittests",
+      "${tint_src_dir}/utils/file:unittests",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/ice:unittests",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/macros:unittests",
+      "${tint_src_dir}/utils/math:unittests",
+      "${tint_src_dir}/utils/memory:unittests",
+      "${tint_src_dir}/utils/reflection:unittests",
+      "${tint_src_dir}/utils/result:unittests",
+      "${tint_src_dir}/utils/rtti:unittests",
+      "${tint_src_dir}/utils/strconv:unittests",
+      "${tint_src_dir}/utils/symbol:unittests",
+      "${tint_src_dir}/utils/text:unittests",
+      "${tint_src_dir}/utils/traits:unittests",
     ]
-  }
 
-  if (tint_build_msl_writer) {
-    deps += [
-      "${tint_src_dir}/lang/msl/writer/ast_printer:unittests",
-      "${tint_src_dir}/lang/msl/writer/common:unittests",
-    ]
-  }
+    if (tint_build_glsl_writer) {
+      deps += [ "${tint_src_dir}/lang/glsl/writer/ast_printer:unittests" ]
+    }
 
-  if (tint_build_msl_writer && tint_build_ir) {
-    deps += [ "${tint_src_dir}/lang/msl/writer/printer:unittests" ]
-  }
+    if (tint_build_hlsl_writer) {
+      deps += [ "${tint_src_dir}/lang/hlsl/writer/ast_printer:unittests" ]
+    }
 
-  if (tint_build_spv_reader) {
-    deps += [ "${tint_src_dir}/lang/spirv/reader/ast_parser:unittests" ]
-  }
+    if (tint_build_ir) {
+      deps += [
+        "${tint_src_dir}/lang/core/ir:unittests",
+        "${tint_src_dir}/lang/core/ir/transform:unittests",
+        "${tint_src_dir}/lang/wgsl/reader/program_to_ir:unittests",
+        "${tint_src_dir}/lang/wgsl/writer/ir_to_program:unittests",
+      ]
+    }
 
-  if (tint_build_spv_writer) {
-    deps += [
-      "${tint_src_dir}/lang/spirv/writer:unittests",
-      "${tint_src_dir}/lang/spirv/writer/ast_printer:unittests",
-      "${tint_src_dir}/lang/spirv/writer/common:unittests",
-    ]
-  }
+    if (tint_build_msl_writer) {
+      deps += [
+        "${tint_src_dir}/lang/msl/writer/ast_printer:unittests",
+        "${tint_src_dir}/lang/msl/writer/common:unittests",
+      ]
+    }
 
-  if (tint_build_spv_writer && tint_build_ir) {
-    deps += [ "${tint_src_dir}/lang/spirv/writer/raise:unittests" ]
-  }
-  testonly = true
-  configs += [ "${tint_src_dir}:tint_unittests_config" ]
+    if (tint_build_msl_writer && tint_build_ir) {
+      deps += [ "${tint_src_dir}/lang/msl/writer/printer:unittests" ]
+    }
 
-  if (build_with_chromium) {
-    configs -= [ "//build/config/compiler:chromium_code" ]
-    configs += [ "//build/config/compiler:no_chromium_code" ]
+    if (tint_build_spv_reader) {
+      deps += [ "${tint_src_dir}/lang/spirv/reader/ast_parser:unittests" ]
+    }
+
+    if (tint_build_spv_writer) {
+      deps += [
+        "${tint_src_dir}/lang/spirv/writer:unittests",
+        "${tint_src_dir}/lang/spirv/writer/ast_printer:unittests",
+        "${tint_src_dir}/lang/spirv/writer/common:unittests",
+      ]
+    }
+
+    if (tint_build_spv_writer && tint_build_ir) {
+      deps += [ "${tint_src_dir}/lang/spirv/writer/raise:unittests" ]
+    }
+    testonly = true
+    configs += [ "${tint_src_dir}:tint_unittests_config" ]
+
+    if (build_with_chromium) {
+      configs -= [ "//build/config/compiler:chromium_code" ]
+      configs += [ "//build/config/compiler:no_chromium_code" ]
+    }
   }
 }
diff --git a/src/tint/lang/core/BUILD.gn b/src/tint/lang/core/BUILD.gn
index 7d228a9..1bc1f65 100644
--- a/src/tint/lang/core/BUILD.gn
+++ b/src/tint/lang/core/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("core") {
   sources = [
     "access.cc",
@@ -75,44 +79,45 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "access_test.cc",
-    "address_space_test.cc",
-    "attribute_test.cc",
-    "builtin_test.cc",
-    "builtin_value_test.cc",
-    "diagnostic_rule_test.cc",
-    "diagnostic_severity_test.cc",
-    "extension_test.cc",
-    "interpolation_sampling_test.cc",
-    "interpolation_type_test.cc",
-    "number_test.cc",
-    "texel_format_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "access_test.cc",
+      "address_space_test.cc",
+      "attribute_test.cc",
+      "builtin_test.cc",
+      "builtin_value_test.cc",
+      "diagnostic_rule_test.cc",
+      "diagnostic_severity_test.cc",
+      "extension_test.cc",
+      "interpolation_sampling_test.cc",
+      "interpolation_type_test.cc",
+      "number_test.cc",
+      "texel_format_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/core/constant/BUILD.gn b/src/tint/lang/core/constant/BUILD.gn
index ad95da9..4bd0e7b 100644
--- a/src/tint/lang/core/constant/BUILD.gn
+++ b/src/tint/lang/core/constant/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("constant") {
   sources = [
     "clone_context.h",
@@ -59,53 +63,54 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "composite_test.cc",
-    "eval_binary_op_test.cc",
-    "eval_bitcast_test.cc",
-    "eval_builtin_test.cc",
-    "eval_construction_test.cc",
-    "eval_conversion_test.cc",
-    "eval_indexing_test.cc",
-    "eval_member_access_test.cc",
-    "eval_runtime_semantics_test.cc",
-    "eval_test.h",
-    "eval_unary_op_test.cc",
-    "helper_test.h",
-    "manager_test.cc",
-    "scalar_test.cc",
-    "splat_test.cc",
-    "value_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/intrinsic",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/core/type:unittests",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/resolver:unittests",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "composite_test.cc",
+      "eval_binary_op_test.cc",
+      "eval_bitcast_test.cc",
+      "eval_builtin_test.cc",
+      "eval_construction_test.cc",
+      "eval_conversion_test.cc",
+      "eval_indexing_test.cc",
+      "eval_member_access_test.cc",
+      "eval_runtime_semantics_test.cc",
+      "eval_test.h",
+      "eval_unary_op_test.cc",
+      "helper_test.h",
+      "manager_test.cc",
+      "scalar_test.cc",
+      "splat_test.cc",
+      "value_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/intrinsic",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/core/type:unittests",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/resolver:unittests",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/core/intrinsic/BUILD.gn b/src/tint/lang/core/intrinsic/BUILD.gn
index e1f9321..9887ec7 100644
--- a/src/tint/lang/core/intrinsic/BUILD.gn
+++ b/src/tint/lang/core/intrinsic/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("intrinsic") {
   sources = [
     "ctor_conv.cc",
@@ -50,36 +54,37 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "table_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/intrinsic",
-    "${tint_src_dir}/lang/core/intrinsic/data",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/core/type:unittests",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/resolver:unittests",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "table_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/intrinsic",
+      "${tint_src_dir}/lang/core/intrinsic/data",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/core/type:unittests",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/resolver:unittests",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/core/ir/BUILD.gn b/src/tint/lang/core/ir/BUILD.gn
index b5ae990..ae23d54 100644
--- a/src/tint/lang/core/ir/BUILD.gn
+++ b/src/tint/lang/core/ir/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_ir) {
   libtint_source_set("ir") {
     sources = [
@@ -145,74 +149,76 @@
     ]
   }
 }
-if (tint_build_ir) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "access_test.cc",
-      "binary_test.cc",
-      "bitcast_test.cc",
-      "block_param_test.cc",
-      "block_test.cc",
-      "break_if_test.cc",
-      "constant_test.cc",
-      "construct_test.cc",
-      "continue_test.cc",
-      "convert_test.cc",
-      "core_builtin_call_test.cc",
-      "discard_test.cc",
-      "exit_if_test.cc",
-      "exit_loop_test.cc",
-      "exit_switch_test.cc",
-      "function_param_test.cc",
-      "function_test.cc",
-      "if_test.cc",
-      "instruction_result_test.cc",
-      "instruction_test.cc",
-      "intrinsic_call_test.cc",
-      "ir_helper_test.h",
-      "let_test.cc",
-      "load_test.cc",
-      "load_vector_element_test.cc",
-      "loop_test.cc",
-      "module_test.cc",
-      "multi_in_block_test.cc",
-      "next_iteration_test.cc",
-      "operand_instruction_test.cc",
-      "return_test.cc",
-      "store_test.cc",
-      "store_vector_element_test.cc",
-      "switch_test.cc",
-      "swizzle_test.cc",
-      "unary_test.cc",
-      "user_call_test.cc",
-      "validator_test.cc",
-      "value_test.cc",
-      "var_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
+if (tint_build_unittests) {
+  if (tint_build_ir) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "access_test.cc",
+        "binary_test.cc",
+        "bitcast_test.cc",
+        "block_param_test.cc",
+        "block_test.cc",
+        "break_if_test.cc",
+        "constant_test.cc",
+        "construct_test.cc",
+        "continue_test.cc",
+        "convert_test.cc",
+        "core_builtin_call_test.cc",
+        "discard_test.cc",
+        "exit_if_test.cc",
+        "exit_loop_test.cc",
+        "exit_switch_test.cc",
+        "function_param_test.cc",
+        "function_test.cc",
+        "if_test.cc",
+        "instruction_result_test.cc",
+        "instruction_test.cc",
+        "intrinsic_call_test.cc",
+        "ir_helper_test.h",
+        "let_test.cc",
+        "load_test.cc",
+        "load_vector_element_test.cc",
+        "loop_test.cc",
+        "module_test.cc",
+        "multi_in_block_test.cc",
+        "next_iteration_test.cc",
+        "operand_instruction_test.cc",
+        "return_test.cc",
+        "store_test.cc",
+        "store_vector_element_test.cc",
+        "switch_test.cc",
+        "swizzle_test.cc",
+        "unary_test.cc",
+        "user_call_test.cc",
+        "validator_test.cc",
+        "value_test.cc",
+        "var_test.cc",
+      ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
 
-    if (tint_build_ir) {
-      deps += [ "${tint_src_dir}/lang/core/ir" ]
+      if (tint_build_ir) {
+        deps += [ "${tint_src_dir}/lang/core/ir" ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/core/ir/transform/BUILD.gn b/src/tint/lang/core/ir/transform/BUILD.gn
index ad8e700..bac2a9d 100644
--- a/src/tint/lang/core/ir/transform/BUILD.gn
+++ b/src/tint/lang/core/ir/transform/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_ir) {
   libtint_source_set("transform") {
     sources = [
@@ -73,48 +77,50 @@
     }
   }
 }
-if (tint_build_ir) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "add_empty_entry_point_test.cc",
-      "bgra8unorm_polyfill_test.cc",
-      "binary_polyfill_test.cc",
-      "binding_remapper_test.cc",
-      "block_decorated_structs_test.cc",
-      "builtin_polyfill_test.cc",
-      "demote_to_helper_test.cc",
-      "helper_test.h",
-      "multiplanar_external_texture_test.cc",
-      "std140_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_ir) {
-      deps += [
-        "${tint_src_dir}/lang/core/ir",
-        "${tint_src_dir}/lang/core/ir/transform",
+if (tint_build_unittests) {
+  if (tint_build_ir) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "add_empty_entry_point_test.cc",
+        "bgra8unorm_polyfill_test.cc",
+        "binary_polyfill_test.cc",
+        "binding_remapper_test.cc",
+        "block_decorated_structs_test.cc",
+        "builtin_polyfill_test.cc",
+        "demote_to_helper_test.cc",
+        "helper_test.h",
+        "multiplanar_external_texture_test.cc",
+        "std140_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_ir) {
+        deps += [
+          "${tint_src_dir}/lang/core/ir",
+          "${tint_src_dir}/lang/core/ir/transform",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/core/type/BUILD.gn b/src/tint/lang/core/type/BUILD.gn
index 87229e2..1951a45 100644
--- a/src/tint/lang/core/type/BUILD.gn
+++ b/src/tint/lang/core/type/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("type") {
   sources = [
     "abstract_float.cc",
@@ -112,57 +116,58 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "array_test.cc",
-    "atomic_test.cc",
-    "bool_test.cc",
-    "builtin_structs_test.cc",
-    "depth_multisampled_texture_test.cc",
-    "depth_texture_test.cc",
-    "external_texture_test.cc",
-    "f16_test.cc",
-    "f32_test.cc",
-    "helper_test.h",
-    "i32_test.cc",
-    "manager_test.cc",
-    "matrix_test.cc",
-    "multisampled_texture_test.cc",
-    "pointer_test.cc",
-    "reference_test.cc",
-    "sampled_texture_test.cc",
-    "sampler_test.cc",
-    "storage_texture_test.cc",
-    "struct_test.cc",
-    "texture_test.cc",
-    "type_test.cc",
-    "u32_test.cc",
-    "vector_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "array_test.cc",
+      "atomic_test.cc",
+      "bool_test.cc",
+      "builtin_structs_test.cc",
+      "depth_multisampled_texture_test.cc",
+      "depth_texture_test.cc",
+      "external_texture_test.cc",
+      "f16_test.cc",
+      "f32_test.cc",
+      "helper_test.h",
+      "i32_test.cc",
+      "manager_test.cc",
+      "matrix_test.cc",
+      "multisampled_texture_test.cc",
+      "pointer_test.cc",
+      "reference_test.cc",
+      "sampled_texture_test.cc",
+      "sampler_test.cc",
+      "storage_texture_test.cc",
+      "struct_test.cc",
+      "texture_test.cc",
+      "type_test.cc",
+      "u32_test.cc",
+      "vector_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/glsl/writer/ast_printer/BUILD.gn b/src/tint/lang/glsl/writer/ast_printer/BUILD.gn
index 345f0ef..dc04db6 100644
--- a/src/tint/lang/glsl/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/glsl/writer/ast_printer/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_glsl_writer) {
   libtint_source_set("ast_printer") {
     sources = [
@@ -62,78 +66,80 @@
     }
   }
 }
-if (tint_build_glsl_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "array_accessor_test.cc",
-      "assign_test.cc",
-      "ast_printer_test.cc",
-      "binary_test.cc",
-      "bitcast_test.cc",
-      "block_test.cc",
-      "break_test.cc",
-      "builtin_test.cc",
-      "builtin_texture_test.cc",
-      "call_test.cc",
-      "case_test.cc",
-      "cast_test.cc",
-      "constructor_test.cc",
-      "continue_test.cc",
-      "discard_test.cc",
-      "function_test.cc",
-      "helper_test.h",
-      "identifier_test.cc",
-      "if_test.cc",
-      "import_test.cc",
-      "loop_test.cc",
-      "member_accessor_test.cc",
-      "module_constant_test.cc",
-      "return_test.cc",
-      "sanitizer_test.cc",
-      "storage_buffer_test.cc",
-      "switch_test.cc",
-      "type_test.cc",
-      "unary_op_test.cc",
-      "uniform_buffer_test.cc",
-      "variable_decl_statement_test.cc",
-      "workgroup_var_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/ast:unittests",
-      "${tint_src_dir}/lang/wgsl/ast/transform",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/resolver",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/generator",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_glsl_writer) {
-      deps += [
-        "${tint_src_dir}/lang/glsl/writer",
-        "${tint_src_dir}/lang/glsl/writer/ast_printer",
-        "${tint_src_dir}/lang/glsl/writer/common",
+if (tint_build_unittests) {
+  if (tint_build_glsl_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "array_accessor_test.cc",
+        "assign_test.cc",
+        "ast_printer_test.cc",
+        "binary_test.cc",
+        "bitcast_test.cc",
+        "block_test.cc",
+        "break_test.cc",
+        "builtin_test.cc",
+        "builtin_texture_test.cc",
+        "call_test.cc",
+        "case_test.cc",
+        "cast_test.cc",
+        "constructor_test.cc",
+        "continue_test.cc",
+        "discard_test.cc",
+        "function_test.cc",
+        "helper_test.h",
+        "identifier_test.cc",
+        "if_test.cc",
+        "import_test.cc",
+        "loop_test.cc",
+        "member_accessor_test.cc",
+        "module_constant_test.cc",
+        "return_test.cc",
+        "sanitizer_test.cc",
+        "storage_buffer_test.cc",
+        "switch_test.cc",
+        "type_test.cc",
+        "unary_op_test.cc",
+        "uniform_buffer_test.cc",
+        "variable_decl_statement_test.cc",
+        "workgroup_var_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/ast:unittests",
+        "${tint_src_dir}/lang/wgsl/ast/transform",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/resolver",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/generator",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_glsl_writer) {
+        deps += [
+          "${tint_src_dir}/lang/glsl/writer",
+          "${tint_src_dir}/lang/glsl/writer/ast_printer",
+          "${tint_src_dir}/lang/glsl/writer/common",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn b/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn
index 4d45aea..5cd3ffe 100644
--- a/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/hlsl/writer/ast_printer/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_hlsl_writer) {
   libtint_source_set("ast_printer") {
     sources = [
@@ -59,77 +63,79 @@
     ]
   }
 }
-if (tint_build_hlsl_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "array_accessor_test.cc",
-      "assign_test.cc",
-      "ast_printer_test.cc",
-      "binary_test.cc",
-      "bitcast_test.cc",
-      "block_test.cc",
-      "break_test.cc",
-      "builtin_test.cc",
-      "builtin_texture_test.cc",
-      "call_test.cc",
-      "case_test.cc",
-      "cast_test.cc",
-      "const_assert_test.cc",
-      "constructor_test.cc",
-      "continue_test.cc",
-      "discard_test.cc",
-      "function_test.cc",
-      "helper_test.h",
-      "identifier_test.cc",
-      "if_test.cc",
-      "import_test.cc",
-      "loop_test.cc",
-      "member_accessor_test.cc",
-      "module_constant_test.cc",
-      "return_test.cc",
-      "sanitizer_test.cc",
-      "switch_test.cc",
-      "type_test.cc",
-      "unary_op_test.cc",
-      "variable_decl_statement_test.cc",
-      "workgroup_var_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/hlsl/writer/common",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/ast:unittests",
-      "${tint_src_dir}/lang/wgsl/ast/transform",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/resolver",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/generator",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_hlsl_writer) {
-      deps += [
-        "${tint_src_dir}/lang/hlsl/writer",
-        "${tint_src_dir}/lang/hlsl/writer/ast_printer",
+if (tint_build_unittests) {
+  if (tint_build_hlsl_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "array_accessor_test.cc",
+        "assign_test.cc",
+        "ast_printer_test.cc",
+        "binary_test.cc",
+        "bitcast_test.cc",
+        "block_test.cc",
+        "break_test.cc",
+        "builtin_test.cc",
+        "builtin_texture_test.cc",
+        "call_test.cc",
+        "case_test.cc",
+        "cast_test.cc",
+        "const_assert_test.cc",
+        "constructor_test.cc",
+        "continue_test.cc",
+        "discard_test.cc",
+        "function_test.cc",
+        "helper_test.h",
+        "identifier_test.cc",
+        "if_test.cc",
+        "import_test.cc",
+        "loop_test.cc",
+        "member_accessor_test.cc",
+        "module_constant_test.cc",
+        "return_test.cc",
+        "sanitizer_test.cc",
+        "switch_test.cc",
+        "type_test.cc",
+        "unary_op_test.cc",
+        "variable_decl_statement_test.cc",
+        "workgroup_var_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/hlsl/writer/common",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/ast:unittests",
+        "${tint_src_dir}/lang/wgsl/ast/transform",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/resolver",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/generator",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_hlsl_writer) {
+        deps += [
+          "${tint_src_dir}/lang/hlsl/writer",
+          "${tint_src_dir}/lang/hlsl/writer/ast_printer",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/msl/writer/ast_printer/BUILD.gn b/src/tint/lang/msl/writer/ast_printer/BUILD.gn
index 24219fc..e7af3d1 100644
--- a/src/tint/lang/msl/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/msl/writer/ast_printer/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_msl_writer) {
   libtint_source_set("ast_printer") {
     sources = [
@@ -61,75 +65,77 @@
     }
   }
 }
-if (tint_build_msl_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "array_accessor_test.cc",
-      "assign_test.cc",
-      "ast_function_test.cc",
-      "ast_printer_test.cc",
-      "ast_type_test.cc",
-      "binary_test.cc",
-      "bitcast_test.cc",
-      "block_test.cc",
-      "break_test.cc",
-      "builtin_test.cc",
-      "builtin_texture_test.cc",
-      "call_test.cc",
-      "case_test.cc",
-      "cast_test.cc",
-      "const_assert_test.cc",
-      "constructor_test.cc",
-      "continue_test.cc",
-      "discard_test.cc",
-      "helper_test.h",
-      "identifier_test.cc",
-      "if_test.cc",
-      "import_test.cc",
-      "loop_test.cc",
-      "member_accessor_test.cc",
-      "module_constant_test.cc",
-      "return_test.cc",
-      "sanitizer_test.cc",
-      "switch_test.cc",
-      "unary_op_test.cc",
-      "variable_decl_statement_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/ast:unittests",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/resolver",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/generator",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_msl_writer) {
-      deps += [
-        "${tint_src_dir}/lang/msl/writer",
-        "${tint_src_dir}/lang/msl/writer/ast_printer",
-        "${tint_src_dir}/lang/msl/writer/common",
+if (tint_build_unittests) {
+  if (tint_build_msl_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "array_accessor_test.cc",
+        "assign_test.cc",
+        "ast_function_test.cc",
+        "ast_printer_test.cc",
+        "ast_type_test.cc",
+        "binary_test.cc",
+        "bitcast_test.cc",
+        "block_test.cc",
+        "break_test.cc",
+        "builtin_test.cc",
+        "builtin_texture_test.cc",
+        "call_test.cc",
+        "case_test.cc",
+        "cast_test.cc",
+        "const_assert_test.cc",
+        "constructor_test.cc",
+        "continue_test.cc",
+        "discard_test.cc",
+        "helper_test.h",
+        "identifier_test.cc",
+        "if_test.cc",
+        "import_test.cc",
+        "loop_test.cc",
+        "member_accessor_test.cc",
+        "module_constant_test.cc",
+        "return_test.cc",
+        "sanitizer_test.cc",
+        "switch_test.cc",
+        "unary_op_test.cc",
+        "variable_decl_statement_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/ast:unittests",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/resolver",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/generator",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_msl_writer) {
+        deps += [
+          "${tint_src_dir}/lang/msl/writer",
+          "${tint_src_dir}/lang/msl/writer/ast_printer",
+          "${tint_src_dir}/lang/msl/writer/common",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/msl/writer/common/BUILD.gn b/src/tint/lang/msl/writer/common/BUILD.gn
index b7ba3c6..19adb54 100644
--- a/src/tint/lang/msl/writer/common/BUILD.gn
+++ b/src/tint/lang/msl/writer/common/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_msl_writer) {
   libtint_source_set("common") {
     sources = [
@@ -51,26 +55,28 @@
     ]
   }
 }
-if (tint_build_msl_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [ "printer_support_test.cc" ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
+if (tint_build_unittests) {
+  if (tint_build_msl_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [ "printer_support_test.cc" ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
 
-    if (tint_build_msl_writer) {
-      deps += [ "${tint_src_dir}/lang/msl/writer/common" ]
+      if (tint_build_msl_writer) {
+        deps += [ "${tint_src_dir}/lang/msl/writer/common" ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/msl/writer/printer/BUILD.gn b/src/tint/lang/msl/writer/printer/BUILD.gn
index 782c776..e6db342 100644
--- a/src/tint/lang/msl/writer/printer/BUILD.gn
+++ b/src/tint/lang/msl/writer/printer/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_msl_writer && tint_build_ir) {
   libtint_source_set("printer") {
     sources = [
@@ -59,49 +63,51 @@
     }
   }
 }
-if (tint_build_msl_writer && tint_build_ir) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "binary_test.cc",
-      "constant_test.cc",
-      "function_test.cc",
-      "helper_test.h",
-      "if_test.cc",
-      "let_test.cc",
-      "return_test.cc",
-      "type_test.cc",
-      "var_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/msl/writer/raise",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/generator",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
+if (tint_build_unittests) {
+  if (tint_build_msl_writer && tint_build_ir) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "binary_test.cc",
+        "constant_test.cc",
+        "function_test.cc",
+        "helper_test.h",
+        "if_test.cc",
+        "let_test.cc",
+        "return_test.cc",
+        "type_test.cc",
+        "var_test.cc",
+      ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/msl/writer/raise",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/generator",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
 
-    if (tint_build_ir) {
-      deps += [ "${tint_src_dir}/lang/core/ir" ]
-    }
+      if (tint_build_ir) {
+        deps += [ "${tint_src_dir}/lang/core/ir" ]
+      }
 
-    if (tint_build_msl_writer && tint_build_ir) {
-      deps += [ "${tint_src_dir}/lang/msl/writer/printer" ]
+      if (tint_build_msl_writer && tint_build_ir) {
+        deps += [ "${tint_src_dir}/lang/msl/writer/printer" ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/spirv/reader/ast_parser/BUILD.gn b/src/tint/lang/spirv/reader/ast_parser/BUILD.gn
index c665c28..c747a30 100644
--- a/src/tint/lang/spirv/reader/ast_parser/BUILD.gn
+++ b/src/tint/lang/spirv/reader/ast_parser/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_spv_reader) {
   libtint_source_set("ast_parser") {
     sources = [
@@ -83,85 +87,87 @@
     public_configs = [ "${tint_spirv_tools_dir}/:spvtools_internal_config" ]
   }
 }
-if (tint_build_spv_reader) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "ast_parser_test.cc",
-      "barrier_test.cc",
-      "constant_test.cc",
-      "convert_member_decoration_test.cc",
-      "convert_type_test.cc",
-      "enum_converter_test.cc",
-      "fail_stream_test.cc",
-      "function_arithmetic_test.cc",
-      "function_bit_test.cc",
-      "function_call_test.cc",
-      "function_cfg_test.cc",
-      "function_composite_test.cc",
-      "function_conversion_test.cc",
-      "function_decl_test.cc",
-      "function_glsl_std_450_test.cc",
-      "function_logical_test.cc",
-      "function_memory_test.cc",
-      "function_misc_test.cc",
-      "function_var_test.cc",
-      "get_decorations_test.cc",
-      "handle_test.cc",
-      "helper_test.cc",
-      "helper_test.h",
-      "import_test.cc",
-      "module_function_decl_test.cc",
-      "module_var_test.cc",
-      "named_types_test.cc",
-      "namer_test.cc",
-      "parser_test.cc",
-      "spirv_tools_helpers_test.cc",
-      "spirv_tools_helpers_test.h",
-      "type_test.cc",
-      "usage_test.cc",
-      "user_name_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/spirv/reader/common",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/lang/wgsl/writer/ast_printer",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/generator",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_spv_reader) {
-      deps += [ "${tint_src_dir}/lang/spirv/reader/ast_parser" ]
-    }
-
-    if (tint_build_spv_reader || tint_build_spv_writer) {
-      deps += [
-        "${tint_spirv_headers_dir}:spv_headers",
-        "${tint_spirv_tools_dir}:spvtools",
-        "${tint_spirv_tools_dir}:spvtools_headers",
-        "${tint_spirv_tools_dir}:spvtools_opt",
-        "${tint_spirv_tools_dir}:spvtools_val",
+if (tint_build_unittests) {
+  if (tint_build_spv_reader) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "ast_parser_test.cc",
+        "barrier_test.cc",
+        "constant_test.cc",
+        "convert_member_decoration_test.cc",
+        "convert_type_test.cc",
+        "enum_converter_test.cc",
+        "fail_stream_test.cc",
+        "function_arithmetic_test.cc",
+        "function_bit_test.cc",
+        "function_call_test.cc",
+        "function_cfg_test.cc",
+        "function_composite_test.cc",
+        "function_conversion_test.cc",
+        "function_decl_test.cc",
+        "function_glsl_std_450_test.cc",
+        "function_logical_test.cc",
+        "function_memory_test.cc",
+        "function_misc_test.cc",
+        "function_var_test.cc",
+        "get_decorations_test.cc",
+        "handle_test.cc",
+        "helper_test.cc",
+        "helper_test.h",
+        "import_test.cc",
+        "module_function_decl_test.cc",
+        "module_var_test.cc",
+        "named_types_test.cc",
+        "namer_test.cc",
+        "parser_test.cc",
+        "spirv_tools_helpers_test.cc",
+        "spirv_tools_helpers_test.h",
+        "type_test.cc",
+        "usage_test.cc",
+        "user_name_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/spirv/reader/common",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/lang/wgsl/writer/ast_printer",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/generator",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_spv_reader) {
+        deps += [ "${tint_src_dir}/lang/spirv/reader/ast_parser" ]
+      }
+
+      if (tint_build_spv_reader || tint_build_spv_writer) {
+        deps += [
+          "${tint_spirv_headers_dir}:spv_headers",
+          "${tint_spirv_tools_dir}:spvtools",
+          "${tint_spirv_tools_dir}:spvtools_headers",
+          "${tint_spirv_tools_dir}:spvtools_opt",
+          "${tint_spirv_tools_dir}:spvtools_val",
+        ]
+      }
+      public_configs = [ "${tint_spirv_tools_dir}/:spvtools_internal_config" ]
     }
-    public_configs = [ "${tint_spirv_tools_dir}/:spvtools_internal_config" ]
   }
 }
diff --git a/src/tint/lang/spirv/writer/BUILD.gn b/src/tint/lang/spirv/writer/BUILD.gn
index afa994c..266f2c9 100644
--- a/src/tint/lang/spirv/writer/BUILD.gn
+++ b/src/tint/lang/spirv/writer/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_spv_writer) {
   libtint_source_set("writer") {
     sources = [
@@ -81,78 +85,80 @@
     }
   }
 }
-if (tint_build_spv_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = []
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_ir) {
-      sources += [
-        "access_test.cc",
-        "atomic_builtin_test.cc",
-        "binary_test.cc",
-        "bitcast_test.cc",
-        "builtin_test.cc",
-        "constant_test.cc",
-        "construct_test.cc",
-        "convert_test.cc",
-        "discard_test.cc",
-        "function_test.cc",
-        "if_test.cc",
-        "let_test.cc",
-        "loop_test.cc",
-        "switch_test.cc",
-        "swizzle_test.cc",
-        "texture_builtin_test.cc",
-        "type_test.cc",
-        "unary_test.cc",
-        "var_test.cc",
-        "writer_test.cc",
+if (tint_build_unittests) {
+  if (tint_build_spv_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = []
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
       ]
-      deps += [ "${tint_src_dir}/lang/core/ir" ]
-    }
 
-    if (tint_build_spv_reader || tint_build_spv_writer) {
-      deps += [
-        "${tint_spirv_headers_dir}:spv_headers",
-        "${tint_spirv_tools_dir}:spvtools_headers",
-        "${tint_spirv_tools_dir}:spvtools_val",
-      ]
-    }
+      if (tint_build_ir) {
+        sources += [
+          "access_test.cc",
+          "atomic_builtin_test.cc",
+          "binary_test.cc",
+          "bitcast_test.cc",
+          "builtin_test.cc",
+          "constant_test.cc",
+          "construct_test.cc",
+          "convert_test.cc",
+          "discard_test.cc",
+          "function_test.cc",
+          "if_test.cc",
+          "let_test.cc",
+          "loop_test.cc",
+          "switch_test.cc",
+          "swizzle_test.cc",
+          "texture_builtin_test.cc",
+          "type_test.cc",
+          "unary_test.cc",
+          "var_test.cc",
+          "writer_test.cc",
+        ]
+        deps += [ "${tint_src_dir}/lang/core/ir" ]
+      }
 
-    if (tint_build_spv_writer) {
-      deps += [
-        "${tint_src_dir}/lang/spirv/writer/common",
-        "${tint_src_dir}/lang/spirv/writer/common:unittests",
-      ]
-    }
+      if (tint_build_spv_reader || tint_build_spv_writer) {
+        deps += [
+          "${tint_spirv_headers_dir}:spv_headers",
+          "${tint_spirv_tools_dir}:spvtools_headers",
+          "${tint_spirv_tools_dir}:spvtools_val",
+        ]
+      }
 
-    if (tint_build_spv_writer && tint_build_ir) {
-      deps += [
-        "${tint_src_dir}/lang/spirv/writer/printer",
-        "${tint_src_dir}/lang/spirv/writer/raise",
-      ]
+      if (tint_build_spv_writer) {
+        deps += [
+          "${tint_src_dir}/lang/spirv/writer/common",
+          "${tint_src_dir}/lang/spirv/writer/common:unittests",
+        ]
+      }
+
+      if (tint_build_spv_writer && tint_build_ir) {
+        deps += [
+          "${tint_src_dir}/lang/spirv/writer/printer",
+          "${tint_src_dir}/lang/spirv/writer/raise",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/spirv/writer/ast_printer/BUILD.gn b/src/tint/lang/spirv/writer/ast_printer/BUILD.gn
index 3ceeaa6..dd6b36c 100644
--- a/src/tint/lang/spirv/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/spirv/writer/ast_printer/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_spv_writer) {
   libtint_source_set("ast_printer") {
     sources = [
@@ -67,81 +71,83 @@
     }
   }
 }
-if (tint_build_spv_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "accessor_expression_test.cc",
-      "assign_test.cc",
-      "ast_builtin_test.cc",
-      "ast_discard_test.cc",
-      "ast_function_test.cc",
-      "ast_if_test.cc",
-      "ast_loop_test.cc",
-      "ast_printer_test.cc",
-      "ast_switch_test.cc",
-      "ast_type_test.cc",
-      "binary_expression_test.cc",
-      "bitcast_expression_test.cc",
-      "block_test.cc",
-      "builtin_texture_test.cc",
-      "call_test.cc",
-      "const_assert_test.cc",
-      "constructor_expression_test.cc",
-      "entry_point_test.cc",
-      "format_conversion_test.cc",
-      "function_attribute_test.cc",
-      "function_variable_test.cc",
-      "global_variable_test.cc",
-      "helper_test.h",
-      "ident_expression_test.cc",
-      "literal_test.cc",
-      "return_test.cc",
-      "scalar_constant_test.cc",
-      "unary_op_expression_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/ast:unittests",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/resolver",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_spv_reader || tint_build_spv_writer) {
-      deps += [
-        "${tint_spirv_headers_dir}:spv_headers",
-        "${tint_spirv_tools_dir}:spvtools_headers",
-        "${tint_spirv_tools_dir}:spvtools_val",
+if (tint_build_unittests) {
+  if (tint_build_spv_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "accessor_expression_test.cc",
+        "assign_test.cc",
+        "ast_builtin_test.cc",
+        "ast_discard_test.cc",
+        "ast_function_test.cc",
+        "ast_if_test.cc",
+        "ast_loop_test.cc",
+        "ast_printer_test.cc",
+        "ast_switch_test.cc",
+        "ast_type_test.cc",
+        "binary_expression_test.cc",
+        "bitcast_expression_test.cc",
+        "block_test.cc",
+        "builtin_texture_test.cc",
+        "call_test.cc",
+        "const_assert_test.cc",
+        "constructor_expression_test.cc",
+        "entry_point_test.cc",
+        "format_conversion_test.cc",
+        "function_attribute_test.cc",
+        "function_variable_test.cc",
+        "global_variable_test.cc",
+        "helper_test.h",
+        "ident_expression_test.cc",
+        "literal_test.cc",
+        "return_test.cc",
+        "scalar_constant_test.cc",
+        "unary_op_expression_test.cc",
       ]
-    }
-
-    if (tint_build_spv_writer) {
-      deps += [
-        "${tint_src_dir}/lang/spirv/writer",
-        "${tint_src_dir}/lang/spirv/writer/ast_printer",
-        "${tint_src_dir}/lang/spirv/writer/common",
-        "${tint_src_dir}/lang/spirv/writer/common:unittests",
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/ast:unittests",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/resolver",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
       ]
+
+      if (tint_build_spv_reader || tint_build_spv_writer) {
+        deps += [
+          "${tint_spirv_headers_dir}:spv_headers",
+          "${tint_spirv_tools_dir}:spvtools_headers",
+          "${tint_spirv_tools_dir}:spvtools_val",
+        ]
+      }
+
+      if (tint_build_spv_writer) {
+        deps += [
+          "${tint_src_dir}/lang/spirv/writer",
+          "${tint_src_dir}/lang/spirv/writer/ast_printer",
+          "${tint_src_dir}/lang/spirv/writer/common",
+          "${tint_src_dir}/lang/spirv/writer/common:unittests",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/spirv/writer/common/BUILD.gn b/src/tint/lang/spirv/writer/common/BUILD.gn
index 4130027..fc9f6b8 100644
--- a/src/tint/lang/spirv/writer/common/BUILD.gn
+++ b/src/tint/lang/spirv/writer/common/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_spv_writer) {
   libtint_source_set("common") {
     sources = [
@@ -54,61 +58,63 @@
     }
   }
 }
-if (tint_build_spv_writer) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "binary_writer_test.cc",
-      "instruction_test.cc",
-      "module_test.cc",
-      "operand_test.cc",
-      "spv_dump_test.cc",
-      "spv_dump_test.h",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/api/options",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_ir) {
-      sources += [ "helper_test.h" ]
-      deps += [ "${tint_src_dir}/lang/core/ir" ]
-    }
-
-    if (tint_build_spv_reader || tint_build_spv_writer) {
-      deps += [
-        "${tint_spirv_headers_dir}:spv_headers",
-        "${tint_spirv_tools_dir}:spvtools_headers",
-        "${tint_spirv_tools_dir}:spvtools_val",
+if (tint_build_unittests) {
+  if (tint_build_spv_writer) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "binary_writer_test.cc",
+        "instruction_test.cc",
+        "module_test.cc",
+        "operand_test.cc",
+        "spv_dump_test.cc",
+        "spv_dump_test.h",
       ]
-    }
-
-    if (tint_build_spv_writer) {
-      deps += [ "${tint_src_dir}/lang/spirv/writer/common" ]
-    }
-
-    if (tint_build_spv_writer && tint_build_ir) {
-      deps += [
-        "${tint_src_dir}/lang/spirv/writer/printer",
-        "${tint_src_dir}/lang/spirv/writer/raise",
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/api/options",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
       ]
+
+      if (tint_build_ir) {
+        sources += [ "helper_test.h" ]
+        deps += [ "${tint_src_dir}/lang/core/ir" ]
+      }
+
+      if (tint_build_spv_reader || tint_build_spv_writer) {
+        deps += [
+          "${tint_spirv_headers_dir}:spv_headers",
+          "${tint_spirv_tools_dir}:spvtools_headers",
+          "${tint_spirv_tools_dir}:spvtools_val",
+        ]
+      }
+
+      if (tint_build_spv_writer) {
+        deps += [ "${tint_src_dir}/lang/spirv/writer/common" ]
+      }
+
+      if (tint_build_spv_writer && tint_build_ir) {
+        deps += [
+          "${tint_src_dir}/lang/spirv/writer/printer",
+          "${tint_src_dir}/lang/spirv/writer/raise",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/spirv/writer/raise/BUILD.gn b/src/tint/lang/spirv/writer/raise/BUILD.gn
index c876062..9048926 100644
--- a/src/tint/lang/spirv/writer/raise/BUILD.gn
+++ b/src/tint/lang/spirv/writer/raise/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_spv_writer && tint_build_ir) {
   libtint_source_set("raise") {
     sources = [
@@ -78,47 +82,49 @@
     }
   }
 }
-if (tint_build_spv_writer && tint_build_ir) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "builtin_polyfill_test.cc",
-      "expand_implicit_splats_test.cc",
-      "handle_matrix_arithmetic_test.cc",
-      "merge_return_test.cc",
-      "shader_io_test.cc",
-      "var_for_dynamic_index_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_ir) {
-      deps += [
-        "${tint_src_dir}/lang/core/ir",
-        "${tint_src_dir}/lang/core/ir/transform:unittests",
+if (tint_build_unittests) {
+  if (tint_build_spv_writer && tint_build_ir) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "builtin_polyfill_test.cc",
+        "expand_implicit_splats_test.cc",
+        "handle_matrix_arithmetic_test.cc",
+        "merge_return_test.cc",
+        "shader_io_test.cc",
+        "var_for_dynamic_index_test.cc",
       ]
-    }
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
 
-    if (tint_build_spv_writer && tint_build_ir) {
-      deps += [ "${tint_src_dir}/lang/spirv/writer/raise" ]
+      if (tint_build_ir) {
+        deps += [
+          "${tint_src_dir}/lang/core/ir",
+          "${tint_src_dir}/lang/core/ir/transform:unittests",
+        ]
+      }
+
+      if (tint_build_spv_writer && tint_build_ir) {
+        deps += [ "${tint_src_dir}/lang/spirv/writer/raise" ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/wgsl/BUILD.gn b/src/tint/lang/wgsl/BUILD.gn
index a067696..d01952a 100644
--- a/src/tint/lang/wgsl/BUILD.gn
+++ b/src/tint/lang/wgsl/BUILD.gn
@@ -24,46 +24,51 @@
 
 import("${tint_src_dir}/tint.gni")
 
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "wgsl_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/helpers:unittests",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/lang/wgsl/writer",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
-
-  if (tint_build_ir) {
-    deps += [
-      "${tint_src_dir}/lang/core/ir",
-      "${tint_src_dir}/lang/wgsl/reader/program_to_ir",
-      "${tint_src_dir}/lang/wgsl/writer/ir_to_program",
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "wgsl_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/helpers:unittests",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/lang/wgsl/writer",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
     ]
-  }
 
-  if (tint_build_wgsl_reader && tint_build_wgsl_writer && tint_build_ir) {
-    sources += [ "ir_roundtrip_test.cc" ]
+    if (tint_build_ir) {
+      deps += [
+        "${tint_src_dir}/lang/core/ir",
+        "${tint_src_dir}/lang/wgsl/reader/program_to_ir",
+        "${tint_src_dir}/lang/wgsl/writer/ir_to_program",
+      ]
+    }
+
+    if (tint_build_wgsl_reader && tint_build_wgsl_writer && tint_build_ir) {
+      sources += [ "ir_roundtrip_test.cc" ]
+    }
   }
 }
diff --git a/src/tint/lang/wgsl/ast/BUILD.gn b/src/tint/lang/wgsl/ast/BUILD.gn
index c2504ff..0b2f961 100644
--- a/src/tint/lang/wgsl/ast/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("ast") {
   sources = [
     "accessor_expression.cc",
@@ -203,99 +207,100 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "alias_test.cc",
-    "assignment_statement_test.cc",
-    "binary_expression_test.cc",
-    "binding_attribute_test.cc",
-    "bitcast_expression_test.cc",
-    "block_statement_test.cc",
-    "bool_literal_expression_test.cc",
-    "break_if_statement_test.cc",
-    "break_statement_test.cc",
-    "builtin_attribute_test.cc",
-    "builtin_texture_helper_test.cc",
-    "builtin_texture_helper_test.h",
-    "call_expression_test.cc",
-    "call_statement_test.cc",
-    "case_selector_test.cc",
-    "case_statement_test.cc",
-    "clone_context_test.cc",
-    "compound_assignment_statement_test.cc",
-    "const_assert_test.cc",
-    "continue_statement_test.cc",
-    "diagnostic_attribute_test.cc",
-    "diagnostic_control_test.cc",
-    "diagnostic_directive_test.cc",
-    "diagnostic_rule_name_test.cc",
-    "discard_statement_test.cc",
-    "enable_test.cc",
-    "float_literal_expression_test.cc",
-    "for_loop_statement_test.cc",
-    "function_test.cc",
-    "group_attribute_test.cc",
-    "helper_test.cc",
-    "helper_test.h",
-    "id_attribute_test.cc",
-    "identifier_expression_test.cc",
-    "identifier_test.cc",
-    "if_statement_test.cc",
-    "increment_decrement_statement_test.cc",
-    "index_accessor_expression_test.cc",
-    "index_attribute_test.cc",
-    "int_literal_expression_test.cc",
-    "interpolate_attribute_test.cc",
-    "location_attribute_test.cc",
-    "loop_statement_test.cc",
-    "member_accessor_expression_test.cc",
-    "module_clone_test.cc",
-    "module_test.cc",
-    "phony_expression_test.cc",
-    "return_statement_test.cc",
-    "stage_attribute_test.cc",
-    "stride_attribute_test.cc",
-    "struct_member_align_attribute_test.cc",
-    "struct_member_offset_attribute_test.cc",
-    "struct_member_size_attribute_test.cc",
-    "struct_member_test.cc",
-    "struct_test.cc",
-    "switch_statement_test.cc",
-    "templated_identifier_test.cc",
-    "traverse_expressions_test.cc",
-    "unary_op_expression_test.cc",
-    "variable_decl_statement_test.cc",
-    "variable_test.cc",
-    "while_statement_test.cc",
-    "workgroup_attribute_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/ast/transform",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/lang/wgsl/writer",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "alias_test.cc",
+      "assignment_statement_test.cc",
+      "binary_expression_test.cc",
+      "binding_attribute_test.cc",
+      "bitcast_expression_test.cc",
+      "block_statement_test.cc",
+      "bool_literal_expression_test.cc",
+      "break_if_statement_test.cc",
+      "break_statement_test.cc",
+      "builtin_attribute_test.cc",
+      "builtin_texture_helper_test.cc",
+      "builtin_texture_helper_test.h",
+      "call_expression_test.cc",
+      "call_statement_test.cc",
+      "case_selector_test.cc",
+      "case_statement_test.cc",
+      "clone_context_test.cc",
+      "compound_assignment_statement_test.cc",
+      "const_assert_test.cc",
+      "continue_statement_test.cc",
+      "diagnostic_attribute_test.cc",
+      "diagnostic_control_test.cc",
+      "diagnostic_directive_test.cc",
+      "diagnostic_rule_name_test.cc",
+      "discard_statement_test.cc",
+      "enable_test.cc",
+      "float_literal_expression_test.cc",
+      "for_loop_statement_test.cc",
+      "function_test.cc",
+      "group_attribute_test.cc",
+      "helper_test.cc",
+      "helper_test.h",
+      "id_attribute_test.cc",
+      "identifier_expression_test.cc",
+      "identifier_test.cc",
+      "if_statement_test.cc",
+      "increment_decrement_statement_test.cc",
+      "index_accessor_expression_test.cc",
+      "index_attribute_test.cc",
+      "int_literal_expression_test.cc",
+      "interpolate_attribute_test.cc",
+      "location_attribute_test.cc",
+      "loop_statement_test.cc",
+      "member_accessor_expression_test.cc",
+      "module_clone_test.cc",
+      "module_test.cc",
+      "phony_expression_test.cc",
+      "return_statement_test.cc",
+      "stage_attribute_test.cc",
+      "stride_attribute_test.cc",
+      "struct_member_align_attribute_test.cc",
+      "struct_member_offset_attribute_test.cc",
+      "struct_member_size_attribute_test.cc",
+      "struct_member_test.cc",
+      "struct_test.cc",
+      "switch_statement_test.cc",
+      "templated_identifier_test.cc",
+      "traverse_expressions_test.cc",
+      "unary_op_expression_test.cc",
+      "variable_decl_statement_test.cc",
+      "variable_test.cc",
+      "while_statement_test.cc",
+      "workgroup_attribute_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/ast/transform",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/lang/wgsl/writer",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.gn b/src/tint/lang/wgsl/ast/transform/BUILD.gn
index 5c1fa11..9967047 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("transform") {
   sources = [
     "add_block_attribute.cc",
@@ -160,96 +164,97 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "add_block_attribute_test.cc",
-    "add_empty_entry_point_test.cc",
-    "array_length_from_uniform_test.cc",
-    "binding_remapper_test.cc",
-    "builtin_polyfill_test.cc",
-    "calculate_array_length_test.cc",
-    "canonicalize_entry_point_io_test.cc",
-    "clamp_frag_depth_test.cc",
-    "combine_samplers_test.cc",
-    "decompose_memory_access_test.cc",
-    "decompose_strided_array_test.cc",
-    "decompose_strided_matrix_test.cc",
-    "demote_to_helper_test.cc",
-    "direct_variable_access_test.cc",
-    "disable_uniformity_analysis_test.cc",
-    "expand_compound_assignment_test.cc",
-    "first_index_offset_test.cc",
-    "fold_trivial_lets_test.cc",
-    "for_loop_to_loop_test.cc",
-    "get_insertion_point_test.cc",
-    "helper_test.h",
-    "hoist_to_decl_before_test.cc",
-    "localize_struct_array_assignment_test.cc",
-    "manager_test.cc",
-    "merge_return_test.cc",
-    "module_scope_var_to_entry_point_param_test.cc",
-    "msl_subgroup_ballot_test.cc",
-    "multiplanar_external_texture_test.cc",
-    "num_workgroups_from_uniform_test.cc",
-    "packed_vec3_test.cc",
-    "pad_structs_test.cc",
-    "preserve_padding_test.cc",
-    "promote_initializers_to_let_test.cc",
-    "promote_side_effects_to_decl_test.cc",
-    "remove_continue_in_switch_test.cc",
-    "remove_phonies_test.cc",
-    "remove_unreachable_statements_test.cc",
-    "renamer_test.cc",
-    "robustness_test.cc",
-    "simplify_pointers_test.cc",
-    "single_entry_point_test.cc",
-    "spirv_atomic_test.cc",
-    "std140_exhaustive_test.cc",
-    "std140_f16_test.cc",
-    "std140_f32_test.cc",
-    "std140_test.cc",
-    "substitute_override_test.cc",
-    "texture_1d_to_2d_test.cc",
-    "transform_test.cc",
-    "truncate_interstage_variables_test.cc",
-    "unshadow_test.cc",
-    "var_for_dynamic_index_test.cc",
-    "vectorize_matrix_conversions_test.cc",
-    "vectorize_scalar_matrix_initializers_test.cc",
-    "vertex_pulling_test.cc",
-    "while_to_loop_test.cc",
-    "zero_init_workgroup_memory_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/api/options",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/ast:unittests",
-    "${tint_src_dir}/lang/wgsl/ast/transform",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/reader/parser",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/lang/wgsl/writer",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "add_block_attribute_test.cc",
+      "add_empty_entry_point_test.cc",
+      "array_length_from_uniform_test.cc",
+      "binding_remapper_test.cc",
+      "builtin_polyfill_test.cc",
+      "calculate_array_length_test.cc",
+      "canonicalize_entry_point_io_test.cc",
+      "clamp_frag_depth_test.cc",
+      "combine_samplers_test.cc",
+      "decompose_memory_access_test.cc",
+      "decompose_strided_array_test.cc",
+      "decompose_strided_matrix_test.cc",
+      "demote_to_helper_test.cc",
+      "direct_variable_access_test.cc",
+      "disable_uniformity_analysis_test.cc",
+      "expand_compound_assignment_test.cc",
+      "first_index_offset_test.cc",
+      "fold_trivial_lets_test.cc",
+      "for_loop_to_loop_test.cc",
+      "get_insertion_point_test.cc",
+      "helper_test.h",
+      "hoist_to_decl_before_test.cc",
+      "localize_struct_array_assignment_test.cc",
+      "manager_test.cc",
+      "merge_return_test.cc",
+      "module_scope_var_to_entry_point_param_test.cc",
+      "msl_subgroup_ballot_test.cc",
+      "multiplanar_external_texture_test.cc",
+      "num_workgroups_from_uniform_test.cc",
+      "packed_vec3_test.cc",
+      "pad_structs_test.cc",
+      "preserve_padding_test.cc",
+      "promote_initializers_to_let_test.cc",
+      "promote_side_effects_to_decl_test.cc",
+      "remove_continue_in_switch_test.cc",
+      "remove_phonies_test.cc",
+      "remove_unreachable_statements_test.cc",
+      "renamer_test.cc",
+      "robustness_test.cc",
+      "simplify_pointers_test.cc",
+      "single_entry_point_test.cc",
+      "spirv_atomic_test.cc",
+      "std140_exhaustive_test.cc",
+      "std140_f16_test.cc",
+      "std140_f32_test.cc",
+      "std140_test.cc",
+      "substitute_override_test.cc",
+      "texture_1d_to_2d_test.cc",
+      "transform_test.cc",
+      "truncate_interstage_variables_test.cc",
+      "unshadow_test.cc",
+      "var_for_dynamic_index_test.cc",
+      "vectorize_matrix_conversions_test.cc",
+      "vectorize_scalar_matrix_initializers_test.cc",
+      "vertex_pulling_test.cc",
+      "while_to_loop_test.cc",
+      "zero_init_workgroup_memory_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/api/options",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/ast:unittests",
+      "${tint_src_dir}/lang/wgsl/ast/transform",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/reader/parser",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/lang/wgsl/writer",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/helpers/BUILD.gn b/src/tint/lang/wgsl/helpers/BUILD.gn
index 292f781..edd2d78 100644
--- a/src/tint/lang/wgsl/helpers/BUILD.gn
+++ b/src/tint/lang/wgsl/helpers/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("helpers") {
   sources = [
     "append_vector.cc",
@@ -58,48 +62,49 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "append_vector_test.cc",
-    "check_supported_extensions_test.cc",
-    "flatten_bindings_test.cc",
-    "ir_program_test.h",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/intrinsic",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/ast:unittests",
-    "${tint_src_dir}/lang/wgsl/helpers",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
-
-  if (tint_build_ir) {
-    deps += [
-      "${tint_src_dir}/lang/core/ir",
-      "${tint_src_dir}/lang/wgsl/reader/program_to_ir",
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "append_vector_test.cc",
+      "check_supported_extensions_test.cc",
+      "flatten_bindings_test.cc",
+      "ir_program_test.h",
     ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/intrinsic",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/ast:unittests",
+      "${tint_src_dir}/lang/wgsl/helpers",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+
+    if (tint_build_ir) {
+      deps += [
+        "${tint_src_dir}/lang/core/ir",
+        "${tint_src_dir}/lang/wgsl/reader/program_to_ir",
+      ]
+    }
   }
 }
diff --git a/src/tint/lang/wgsl/inspector/BUILD.gn b/src/tint/lang/wgsl/inspector/BUILD.gn
index 6e491c8..2bbc41a 100644
--- a/src/tint/lang/wgsl/inspector/BUILD.gn
+++ b/src/tint/lang/wgsl/inspector/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("inspector") {
   sources = [
     "entry_point.cc",
@@ -58,40 +62,41 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "inspector_builder_test.cc",
-    "inspector_builder_test.h",
-    "inspector_runner_test.cc",
-    "inspector_runner_test.h",
-    "inspector_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/inspector",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "inspector_builder_test.cc",
+      "inspector_builder_test.h",
+      "inspector_runner_test.cc",
+      "inspector_runner_test.h",
+      "inspector_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/inspector",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/program/BUILD.gn b/src/tint/lang/wgsl/program/BUILD.gn
index 667a55e..2696ac4 100644
--- a/src/tint/lang/wgsl/program/BUILD.gn
+++ b/src/tint/lang/wgsl/program/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("program") {
   sources = [
     "clone_context.cc",
@@ -55,37 +59,38 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "clone_context_test.cc",
-    "program_builder_test.cc",
-    "program_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/ast:unittests",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "clone_context_test.cc",
+      "program_builder_test.cc",
+      "program_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/ast:unittests",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/reader/parser/BUILD.gn b/src/tint/lang/wgsl/reader/parser/BUILD.gn
index 646668d..1f8d1f0 100644
--- a/src/tint/lang/wgsl/reader/parser/BUILD.gn
+++ b/src/tint/lang/wgsl/reader/parser/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("parser") {
   sources = [
     "classify_template_args.cc",
@@ -61,102 +65,103 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "additive_expression_test.cc",
-    "argument_expression_list_test.cc",
-    "assignment_stmt_test.cc",
-    "bitwise_expression_test.cc",
-    "break_stmt_test.cc",
-    "bug_cases_test.cc",
-    "call_stmt_test.cc",
-    "classify_template_args_test.cc",
-    "compound_stmt_test.cc",
-    "const_literal_test.cc",
-    "continue_stmt_test.cc",
-    "continuing_stmt_test.cc",
-    "core_lhs_expression_test.cc",
-    "diagnostic_attribute_test.cc",
-    "diagnostic_control_test.cc",
-    "diagnostic_directive_test.cc",
-    "enable_directive_test.cc",
-    "error_msg_test.cc",
-    "error_resync_test.cc",
-    "expression_test.cc",
-    "for_stmt_test.cc",
-    "function_attribute_list_test.cc",
-    "function_attribute_test.cc",
-    "function_decl_test.cc",
-    "function_header_test.cc",
-    "global_constant_decl_test.cc",
-    "global_decl_test.cc",
-    "global_variable_decl_test.cc",
-    "helper_test.cc",
-    "helper_test.h",
-    "if_stmt_test.cc",
-    "increment_decrement_stmt_test.cc",
-    "lexer_test.cc",
-    "lhs_expression_test.cc",
-    "loop_stmt_test.cc",
-    "math_expression_test.cc",
-    "multiplicative_expression_test.cc",
-    "param_list_test.cc",
-    "paren_expression_test.cc",
-    "parser_test.cc",
-    "primary_expression_test.cc",
-    "relational_expression_test.cc",
-    "require_directive_test.cc",
-    "reserved_keyword_test.cc",
-    "shift_expression_test.cc",
-    "singular_expression_test.cc",
-    "statement_test.cc",
-    "statements_test.cc",
-    "struct_attribute_decl_test.cc",
-    "struct_body_decl_test.cc",
-    "struct_decl_test.cc",
-    "struct_member_attribute_decl_test.cc",
-    "struct_member_attribute_test.cc",
-    "struct_member_test.cc",
-    "switch_body_test.cc",
-    "switch_stmt_test.cc",
-    "token_test.cc",
-    "type_alias_test.cc",
-    "type_decl_test.cc",
-    "unary_expression_test.cc",
-    "variable_attribute_list_test.cc",
-    "variable_attribute_test.cc",
-    "variable_decl_test.cc",
-    "variable_ident_decl_test.cc",
-    "variable_qualifier_test.cc",
-    "variable_stmt_test.cc",
-    "while_stmt_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/ast:unittests",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader/parser",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "additive_expression_test.cc",
+      "argument_expression_list_test.cc",
+      "assignment_stmt_test.cc",
+      "bitwise_expression_test.cc",
+      "break_stmt_test.cc",
+      "bug_cases_test.cc",
+      "call_stmt_test.cc",
+      "classify_template_args_test.cc",
+      "compound_stmt_test.cc",
+      "const_literal_test.cc",
+      "continue_stmt_test.cc",
+      "continuing_stmt_test.cc",
+      "core_lhs_expression_test.cc",
+      "diagnostic_attribute_test.cc",
+      "diagnostic_control_test.cc",
+      "diagnostic_directive_test.cc",
+      "enable_directive_test.cc",
+      "error_msg_test.cc",
+      "error_resync_test.cc",
+      "expression_test.cc",
+      "for_stmt_test.cc",
+      "function_attribute_list_test.cc",
+      "function_attribute_test.cc",
+      "function_decl_test.cc",
+      "function_header_test.cc",
+      "global_constant_decl_test.cc",
+      "global_decl_test.cc",
+      "global_variable_decl_test.cc",
+      "helper_test.cc",
+      "helper_test.h",
+      "if_stmt_test.cc",
+      "increment_decrement_stmt_test.cc",
+      "lexer_test.cc",
+      "lhs_expression_test.cc",
+      "loop_stmt_test.cc",
+      "math_expression_test.cc",
+      "multiplicative_expression_test.cc",
+      "param_list_test.cc",
+      "paren_expression_test.cc",
+      "parser_test.cc",
+      "primary_expression_test.cc",
+      "relational_expression_test.cc",
+      "require_directive_test.cc",
+      "reserved_keyword_test.cc",
+      "shift_expression_test.cc",
+      "singular_expression_test.cc",
+      "statement_test.cc",
+      "statements_test.cc",
+      "struct_attribute_decl_test.cc",
+      "struct_body_decl_test.cc",
+      "struct_decl_test.cc",
+      "struct_member_attribute_decl_test.cc",
+      "struct_member_attribute_test.cc",
+      "struct_member_test.cc",
+      "switch_body_test.cc",
+      "switch_stmt_test.cc",
+      "token_test.cc",
+      "type_alias_test.cc",
+      "type_decl_test.cc",
+      "unary_expression_test.cc",
+      "variable_attribute_list_test.cc",
+      "variable_attribute_test.cc",
+      "variable_decl_test.cc",
+      "variable_ident_decl_test.cc",
+      "variable_qualifier_test.cc",
+      "variable_stmt_test.cc",
+      "while_stmt_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/ast:unittests",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader/parser",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/reader/program_to_ir/BUILD.gn b/src/tint/lang/wgsl/reader/program_to_ir/BUILD.gn
index a4c527f..8c9eb93 100644
--- a/src/tint/lang/wgsl/reader/program_to_ir/BUILD.gn
+++ b/src/tint/lang/wgsl/reader/program_to_ir/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_ir) {
   libtint_source_set("program_to_ir") {
     sources = [
@@ -57,56 +61,58 @@
     }
   }
 }
-if (tint_build_ir) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "accessor_test.cc",
-      "binary_test.cc",
-      "builtin_test.cc",
-      "call_test.cc",
-      "function_test.cc",
-      "let_test.cc",
-      "literal_test.cc",
-      "materialize_test.cc",
-      "program_to_ir_test.cc",
-      "shadowing_test.cc",
-      "store_test.cc",
-      "unary_test.cc",
-      "var_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/helpers:unittests",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/reader",
-      "${tint_src_dir}/lang/wgsl/resolver",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_ir) {
-      deps += [
-        "${tint_src_dir}/lang/core/ir",
-        "${tint_src_dir}/lang/wgsl/reader/program_to_ir",
+if (tint_build_unittests) {
+  if (tint_build_ir) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "accessor_test.cc",
+        "binary_test.cc",
+        "builtin_test.cc",
+        "call_test.cc",
+        "function_test.cc",
+        "let_test.cc",
+        "literal_test.cc",
+        "materialize_test.cc",
+        "program_to_ir_test.cc",
+        "shadowing_test.cc",
+        "store_test.cc",
+        "unary_test.cc",
+        "var_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/helpers:unittests",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/reader",
+        "${tint_src_dir}/lang/wgsl/resolver",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_ir) {
+        deps += [
+          "${tint_src_dir}/lang/core/ir",
+          "${tint_src_dir}/lang/wgsl/reader/program_to_ir",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/lang/wgsl/resolver/BUILD.gn b/src/tint/lang/wgsl/resolver/BUILD.gn
index 8d726f5..17f3e73 100644
--- a/src/tint/lang/wgsl/resolver/BUILD.gn
+++ b/src/tint/lang/wgsl/resolver/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("resolver") {
   sources = [
     "dependency_graph.cc",
@@ -64,95 +68,96 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "address_space_layout_validation_test.cc",
-    "address_space_validation_test.cc",
-    "alias_analysis_test.cc",
-    "array_accessor_test.cc",
-    "assignment_validation_test.cc",
-    "atomics_test.cc",
-    "atomics_validation_test.cc",
-    "attribute_validation_test.cc",
-    "bitcast_validation_test.cc",
-    "builtin_enum_test.cc",
-    "builtin_structs_test.cc",
-    "builtin_test.cc",
-    "builtin_validation_test.cc",
-    "builtins_validation_test.cc",
-    "call_test.cc",
-    "call_validation_test.cc",
-    "compound_assignment_validation_test.cc",
-    "compound_statement_test.cc",
-    "const_assert_test.cc",
-    "control_block_validation_test.cc",
-    "dependency_graph_test.cc",
-    "diagnostic_control_test.cc",
-    "dual_source_blending_extension_test.cc",
-    "entry_point_validation_test.cc",
-    "evaluation_stage_test.cc",
-    "expression_kind_test.cc",
-    "f16_extension_test.cc",
-    "function_validation_test.cc",
-    "host_shareable_validation_test.cc",
-    "increment_decrement_validation_test.cc",
-    "inferred_type_test.cc",
-    "is_host_shareable_test.cc",
-    "is_storeable_test.cc",
-    "load_test.cc",
-    "materialize_test.cc",
-    "override_test.cc",
-    "ptr_ref_test.cc",
-    "ptr_ref_validation_test.cc",
-    "resolver_behavior_test.cc",
-    "resolver_helper_test.cc",
-    "resolver_helper_test.h",
-    "resolver_test.cc",
-    "root_identifier_test.cc",
-    "side_effects_test.cc",
-    "struct_address_space_use_test.cc",
-    "struct_layout_test.cc",
-    "struct_pipeline_stage_use_test.cc",
-    "subgroups_extension_test.cc",
-    "type_validation_test.cc",
-    "uniformity_test.cc",
-    "unresolved_identifier_test.cc",
-    "validation_test.cc",
-    "validator_is_storeable_test.cc",
-    "value_constructor_validation_test.cc",
-    "variable_test.cc",
-    "variable_validation_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/intrinsic",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/core/type:unittests",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/ast:unittests",
-    "${tint_src_dir}/lang/wgsl/ast/transform",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/reader",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/lang/wgsl/sem:unittests",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "address_space_layout_validation_test.cc",
+      "address_space_validation_test.cc",
+      "alias_analysis_test.cc",
+      "array_accessor_test.cc",
+      "assignment_validation_test.cc",
+      "atomics_test.cc",
+      "atomics_validation_test.cc",
+      "attribute_validation_test.cc",
+      "bitcast_validation_test.cc",
+      "builtin_enum_test.cc",
+      "builtin_structs_test.cc",
+      "builtin_test.cc",
+      "builtin_validation_test.cc",
+      "builtins_validation_test.cc",
+      "call_test.cc",
+      "call_validation_test.cc",
+      "compound_assignment_validation_test.cc",
+      "compound_statement_test.cc",
+      "const_assert_test.cc",
+      "control_block_validation_test.cc",
+      "dependency_graph_test.cc",
+      "diagnostic_control_test.cc",
+      "dual_source_blending_extension_test.cc",
+      "entry_point_validation_test.cc",
+      "evaluation_stage_test.cc",
+      "expression_kind_test.cc",
+      "f16_extension_test.cc",
+      "function_validation_test.cc",
+      "host_shareable_validation_test.cc",
+      "increment_decrement_validation_test.cc",
+      "inferred_type_test.cc",
+      "is_host_shareable_test.cc",
+      "is_storeable_test.cc",
+      "load_test.cc",
+      "materialize_test.cc",
+      "override_test.cc",
+      "ptr_ref_test.cc",
+      "ptr_ref_validation_test.cc",
+      "resolver_behavior_test.cc",
+      "resolver_helper_test.cc",
+      "resolver_helper_test.h",
+      "resolver_test.cc",
+      "root_identifier_test.cc",
+      "side_effects_test.cc",
+      "struct_address_space_use_test.cc",
+      "struct_layout_test.cc",
+      "struct_pipeline_stage_use_test.cc",
+      "subgroups_extension_test.cc",
+      "type_validation_test.cc",
+      "uniformity_test.cc",
+      "unresolved_identifier_test.cc",
+      "validation_test.cc",
+      "validator_is_storeable_test.cc",
+      "value_constructor_validation_test.cc",
+      "variable_test.cc",
+      "variable_validation_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/intrinsic",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/core/type:unittests",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/ast:unittests",
+      "${tint_src_dir}/lang/wgsl/ast/transform",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/reader",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/lang/wgsl/sem:unittests",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/sem/BUILD.gn b/src/tint/lang/wgsl/sem/BUILD.gn
index fcc7662..7e23a83 100644
--- a/src/tint/lang/wgsl/sem/BUILD.gn
+++ b/src/tint/lang/wgsl/sem/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("sem") {
   sources = [
     "accessor_expression.cc",
@@ -113,38 +117,39 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "builtin_test.cc",
-    "diagnostic_severity_test.cc",
-    "helper_test.h",
-    "struct_test.cc",
-    "value_expression_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "builtin_test.cc",
+      "diagnostic_severity_test.cc",
+      "helper_test.h",
+      "struct_test.cc",
+      "value_expression_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/writer/ast_printer/BUILD.gn b/src/tint/lang/wgsl/writer/ast_printer/BUILD.gn
index 21247b7..337df64 100644
--- a/src/tint/lang/wgsl/writer/ast_printer/BUILD.gn
+++ b/src/tint/lang/wgsl/writer/ast_printer/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("ast_printer") {
   sources = [
     "ast_printer.cc",
@@ -52,66 +56,67 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "alias_type_test.cc",
-    "array_accessor_test.cc",
-    "assign_test.cc",
-    "ast_printer_test.cc",
-    "binary_test.cc",
-    "bitcast_test.cc",
-    "block_test.cc",
-    "break_test.cc",
-    "call_test.cc",
-    "case_test.cc",
-    "cast_test.cc",
-    "const_assert_test.cc",
-    "constructor_test.cc",
-    "continue_test.cc",
-    "diagnostic_test.cc",
-    "discard_test.cc",
-    "enable_test.cc",
-    "function_test.cc",
-    "global_decl_test.cc",
-    "helper_test.h",
-    "identifier_test.cc",
-    "if_test.cc",
-    "literal_test.cc",
-    "loop_test.cc",
-    "member_accessor_test.cc",
-    "return_test.cc",
-    "switch_test.cc",
-    "type_test.cc",
-    "unary_op_test.cc",
-    "variable_decl_statement_test.cc",
-    "variable_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/resolver",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/lang/wgsl/writer/ast_printer",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/generator",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "alias_type_test.cc",
+      "array_accessor_test.cc",
+      "assign_test.cc",
+      "ast_printer_test.cc",
+      "binary_test.cc",
+      "bitcast_test.cc",
+      "block_test.cc",
+      "break_test.cc",
+      "call_test.cc",
+      "case_test.cc",
+      "cast_test.cc",
+      "const_assert_test.cc",
+      "constructor_test.cc",
+      "continue_test.cc",
+      "diagnostic_test.cc",
+      "discard_test.cc",
+      "enable_test.cc",
+      "function_test.cc",
+      "global_decl_test.cc",
+      "helper_test.h",
+      "identifier_test.cc",
+      "if_test.cc",
+      "literal_test.cc",
+      "loop_test.cc",
+      "member_accessor_test.cc",
+      "return_test.cc",
+      "switch_test.cc",
+      "type_test.cc",
+      "unary_op_test.cc",
+      "variable_decl_statement_test.cc",
+      "variable_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/resolver",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/lang/wgsl/writer/ast_printer",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/generator",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/BUILD.gn b/src/tint/lang/wgsl/writer/ir_to_program/BUILD.gn
index c5f2bfa..ae42670 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/BUILD.gn
+++ b/src/tint/lang/wgsl/writer/ir_to_program/BUILD.gn
@@ -23,6 +23,10 @@
 import("../../../../../../tint_overrides_with_defaults.gni")
 
 import("${tint_src_dir}/tint.gni")
+
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
 if (tint_build_ir) {
   libtint_source_set("ir_to_program") {
     sources = [
@@ -60,46 +64,48 @@
     }
   }
 }
-if (tint_build_ir) {
-  tint_unittests_source_set("unittests") {
-    testonly = true
-    sources = [
-      "inlining_test.cc",
-      "ir_to_program_test.cc",
-      "ir_to_program_test.h",
-      "rename_conflicts_test.cc",
-    ]
-    deps = [
-      "${tint_src_dir}:gmock_and_gtest",
-      "${tint_src_dir}/api/common",
-      "${tint_src_dir}/lang/core",
-      "${tint_src_dir}/lang/core/constant",
-      "${tint_src_dir}/lang/core/type",
-      "${tint_src_dir}/lang/wgsl/ast",
-      "${tint_src_dir}/lang/wgsl/program",
-      "${tint_src_dir}/lang/wgsl/sem",
-      "${tint_src_dir}/lang/wgsl/writer",
-      "${tint_src_dir}/utils/containers",
-      "${tint_src_dir}/utils/diagnostic",
-      "${tint_src_dir}/utils/ice",
-      "${tint_src_dir}/utils/id",
-      "${tint_src_dir}/utils/macros",
-      "${tint_src_dir}/utils/math",
-      "${tint_src_dir}/utils/memory",
-      "${tint_src_dir}/utils/reflection",
-      "${tint_src_dir}/utils/result",
-      "${tint_src_dir}/utils/rtti",
-      "${tint_src_dir}/utils/symbol",
-      "${tint_src_dir}/utils/text",
-      "${tint_src_dir}/utils/traits",
-    ]
-
-    if (tint_build_ir) {
-      deps += [
-        "${tint_src_dir}/lang/core/ir",
-        "${tint_src_dir}/lang/core/ir:unittests",
-        "${tint_src_dir}/lang/wgsl/writer/ir_to_program",
+if (tint_build_unittests) {
+  if (tint_build_ir) {
+    tint_unittests_source_set("unittests") {
+      testonly = true
+      sources = [
+        "inlining_test.cc",
+        "ir_to_program_test.cc",
+        "ir_to_program_test.h",
+        "rename_conflicts_test.cc",
       ]
+      deps = [
+        "${tint_src_dir}:gmock_and_gtest",
+        "${tint_src_dir}/api/common",
+        "${tint_src_dir}/lang/core",
+        "${tint_src_dir}/lang/core/constant",
+        "${tint_src_dir}/lang/core/type",
+        "${tint_src_dir}/lang/wgsl/ast",
+        "${tint_src_dir}/lang/wgsl/program",
+        "${tint_src_dir}/lang/wgsl/sem",
+        "${tint_src_dir}/lang/wgsl/writer",
+        "${tint_src_dir}/utils/containers",
+        "${tint_src_dir}/utils/diagnostic",
+        "${tint_src_dir}/utils/ice",
+        "${tint_src_dir}/utils/id",
+        "${tint_src_dir}/utils/macros",
+        "${tint_src_dir}/utils/math",
+        "${tint_src_dir}/utils/memory",
+        "${tint_src_dir}/utils/reflection",
+        "${tint_src_dir}/utils/result",
+        "${tint_src_dir}/utils/rtti",
+        "${tint_src_dir}/utils/symbol",
+        "${tint_src_dir}/utils/text",
+        "${tint_src_dir}/utils/traits",
+      ]
+
+      if (tint_build_ir) {
+        deps += [
+          "${tint_src_dir}/lang/core/ir",
+          "${tint_src_dir}/lang/core/ir:unittests",
+          "${tint_src_dir}/lang/wgsl/writer/ir_to_program",
+        ]
+      }
     }
   }
 }
diff --git a/src/tint/utils/cli/BUILD.gn b/src/tint/utils/cli/BUILD.gn
index b31b71a..bff6ce2 100644
--- a/src/tint/utils/cli/BUILD.gn
+++ b/src/tint/utils/cli/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("cli") {
   sources = [
     "cli.cc",
@@ -42,22 +46,23 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "cli_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/cli",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/strconv",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "cli_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/cli",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/strconv",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/command/BUILD.gn b/src/tint/utils/command/BUILD.gn
index 12dacb6..50b6665 100644
--- a/src/tint/utils/command/BUILD.gn
+++ b/src/tint/utils/command/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("command") {
   sources = [ "command.h" ]
   deps = [
@@ -43,12 +47,13 @@
     sources += [ "command_windows.cc" ]
   }
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "command_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/command",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "command_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/command",
+    ]
+  }
 }
diff --git a/src/tint/utils/containers/BUILD.gn b/src/tint/utils/containers/BUILD.gn
index 600b18f..e39039b 100644
--- a/src/tint/utils/containers/BUILD.gn
+++ b/src/tint/utils/containers/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("containers") {
   sources = [
     "bitset.h",
@@ -51,45 +55,46 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "bitset_test.cc",
-    "enum_set_test.cc",
-    "hashmap_test.cc",
-    "hashset_test.cc",
-    "map_test.cc",
-    "predicates_test.cc",
-    "reverse_test.cc",
-    "scope_stack_test.cc",
-    "slice_test.cc",
-    "transform_test.cc",
-    "unique_allocator_test.cc",
-    "unique_vector_test.cc",
-    "vector_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/api/common",
-    "${tint_src_dir}/lang/core",
-    "${tint_src_dir}/lang/core/constant",
-    "${tint_src_dir}/lang/core/type",
-    "${tint_src_dir}/lang/wgsl/ast",
-    "${tint_src_dir}/lang/wgsl/program",
-    "${tint_src_dir}/lang/wgsl/sem",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/reflection",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "bitset_test.cc",
+      "enum_set_test.cc",
+      "hashmap_test.cc",
+      "hashset_test.cc",
+      "map_test.cc",
+      "predicates_test.cc",
+      "reverse_test.cc",
+      "scope_stack_test.cc",
+      "slice_test.cc",
+      "transform_test.cc",
+      "unique_allocator_test.cc",
+      "unique_vector_test.cc",
+      "vector_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/api/common",
+      "${tint_src_dir}/lang/core",
+      "${tint_src_dir}/lang/core/constant",
+      "${tint_src_dir}/lang/core/type",
+      "${tint_src_dir}/lang/wgsl/ast",
+      "${tint_src_dir}/lang/wgsl/program",
+      "${tint_src_dir}/lang/wgsl/sem",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/reflection",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/diagnostic/BUILD.gn b/src/tint/utils/diagnostic/BUILD.gn
index 34622b8..b3c8c28 100644
--- a/src/tint/utils/diagnostic/BUILD.gn
+++ b/src/tint/utils/diagnostic/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("diagnostic") {
   sources = [
     "diagnostic.cc",
@@ -52,19 +56,20 @@
     sources += [ "printer_windows.cc" ]
   }
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "diagnostic_test.cc",
-    "formatter_test.cc",
-    "printer_test.cc",
-    "source_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/diagnostic",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "diagnostic_test.cc",
+      "formatter_test.cc",
+      "printer_test.cc",
+      "source_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/diagnostic",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/file/BUILD.gn b/src/tint/utils/file/BUILD.gn
index 2eb27ac..c53ec89 100644
--- a/src/tint/utils/file/BUILD.gn
+++ b/src/tint/utils/file/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("file") {
   sources = [ "tmpfile.h" ]
   deps = [
@@ -44,13 +48,14 @@
     sources += [ "tmpfile_windows.cc" ]
   }
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "tmpfile_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/file",
-    "${tint_src_dir}/utils/text",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "tmpfile_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/file",
+      "${tint_src_dir}/utils/text",
+    ]
+  }
 }
diff --git a/src/tint/utils/ice/BUILD.gn b/src/tint/utils/ice/BUILD.gn
index 54a056d..2564bb5 100644
--- a/src/tint/utils/ice/BUILD.gn
+++ b/src/tint/utils/ice/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("ice") {
   sources = [
     "ice.cc",
@@ -34,13 +38,14 @@
     "${tint_src_dir}/utils/macros",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "ice_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/macros",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "ice_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/macros",
+    ]
+  }
 }
diff --git a/src/tint/utils/macros/BUILD.gn b/src/tint/utils/macros/BUILD.gn
index 282b06b..bba6052 100644
--- a/src/tint/utils/macros/BUILD.gn
+++ b/src/tint/utils/macros/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("macros") {
   sources = [
     "compiler.h",
@@ -35,15 +39,16 @@
   ]
   deps = []
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "defer_test.cc",
-    "scoped_assignment_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/macros",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "defer_test.cc",
+      "scoped_assignment_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/macros",
+    ]
+  }
 }
diff --git a/src/tint/utils/math/BUILD.gn b/src/tint/utils/math/BUILD.gn
index 010229d..0473ace 100644
--- a/src/tint/utils/math/BUILD.gn
+++ b/src/tint/utils/math/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("math") {
   sources = [
     "crc32.h",
@@ -33,22 +37,23 @@
   ]
   deps = []
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "crc32_test.cc",
-    "hash_test.cc",
-    "math_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "crc32_test.cc",
+      "hash_test.cc",
+      "math_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/memory/BUILD.gn b/src/tint/utils/memory/BUILD.gn
index 33fa383..26a27e6 100644
--- a/src/tint/utils/memory/BUILD.gn
+++ b/src/tint/utils/memory/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("memory") {
   sources = [
     "bitcast.h",
@@ -33,17 +37,18 @@
   ]
   deps = [ "${tint_src_dir}/utils/math" ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "bitcast_test.cc",
-    "block_allocator_test.cc",
-    "bump_allocator_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "bitcast_test.cc",
+      "block_allocator_test.cc",
+      "bump_allocator_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+    ]
+  }
 }
diff --git a/src/tint/utils/reflection/BUILD.gn b/src/tint/utils/reflection/BUILD.gn
index f10ebcf..c87e03a 100644
--- a/src/tint/utils/reflection/BUILD.gn
+++ b/src/tint/utils/reflection/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("reflection") {
   sources = [
     "reflection.cc",
@@ -31,13 +35,14 @@
   ]
   deps = [ "${tint_src_dir}/utils/macros" ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "reflection_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/reflection",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "reflection_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/reflection",
+    ]
+  }
 }
diff --git a/src/tint/utils/result/BUILD.gn b/src/tint/utils/result/BUILD.gn
index bf2150a..281030c 100644
--- a/src/tint/utils/result/BUILD.gn
+++ b/src/tint/utils/result/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("result") {
   sources = [
     "result.cc",
@@ -36,16 +40,17 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "result_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/result",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "result_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/result",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/rtti/BUILD.gn b/src/tint/utils/rtti/BUILD.gn
index 08cf999..3a2d575 100644
--- a/src/tint/utils/rtti/BUILD.gn
+++ b/src/tint/utils/rtti/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("rtti") {
   sources = [
     "castable.cc",
@@ -37,19 +41,20 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "castable_test.cc",
-    "switch_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "castable_test.cc",
+      "switch_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/strconv/BUILD.gn b/src/tint/utils/strconv/BUILD.gn
index 1e1a5cb..7a1b26b 100644
--- a/src/tint/utils/strconv/BUILD.gn
+++ b/src/tint/utils/strconv/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("strconv") {
   sources = [
     "float_to_string.cc",
@@ -40,13 +44,14 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "float_to_string_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/strconv",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "float_to_string_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/strconv",
+    ]
+  }
 }
diff --git a/src/tint/utils/symbol/BUILD.gn b/src/tint/utils/symbol/BUILD.gn
index 647f20a..d598534 100644
--- a/src/tint/utils/symbol/BUILD.gn
+++ b/src/tint/utils/symbol/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("symbol") {
   sources = [
     "symbol.cc",
@@ -43,24 +47,25 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "symbol_table_test.cc",
-    "symbol_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/id",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/symbol",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "symbol_table_test.cc",
+      "symbol_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/id",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/symbol",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/text/BUILD.gn b/src/tint/utils/text/BUILD.gn
index 4021158..a346d64 100644
--- a/src/tint/utils/text/BUILD.gn
+++ b/src/tint/utils/text/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("text") {
   sources = [
     "string.cc",
@@ -43,23 +47,24 @@
     "${tint_src_dir}/utils/traits",
   ]
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [
-    "string_stream_test.cc",
-    "string_test.cc",
-    "unicode_test.cc",
-  ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/containers",
-    "${tint_src_dir}/utils/ice",
-    "${tint_src_dir}/utils/macros",
-    "${tint_src_dir}/utils/math",
-    "${tint_src_dir}/utils/memory",
-    "${tint_src_dir}/utils/rtti",
-    "${tint_src_dir}/utils/text",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [
+      "string_stream_test.cc",
+      "string_test.cc",
+      "unicode_test.cc",
+    ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/containers",
+      "${tint_src_dir}/utils/ice",
+      "${tint_src_dir}/utils/macros",
+      "${tint_src_dir}/utils/math",
+      "${tint_src_dir}/utils/memory",
+      "${tint_src_dir}/utils/rtti",
+      "${tint_src_dir}/utils/text",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/src/tint/utils/traits/BUILD.gn b/src/tint/utils/traits/BUILD.gn
index 67b4700..2ba2b22 100644
--- a/src/tint/utils/traits/BUILD.gn
+++ b/src/tint/utils/traits/BUILD.gn
@@ -24,6 +24,10 @@
 
 import("${tint_src_dir}/tint.gni")
 
+if (tint_build_unittests) {
+  import("//testing/test.gni")
+}
+
 libtint_source_set("traits") {
   sources = [
     "traits.cc",
@@ -31,12 +35,13 @@
   ]
   deps = []
 }
-
-tint_unittests_source_set("unittests") {
-  testonly = true
-  sources = [ "traits_test.cc" ]
-  deps = [
-    "${tint_src_dir}:gmock_and_gtest",
-    "${tint_src_dir}/utils/traits",
-  ]
+if (tint_build_unittests) {
+  tint_unittests_source_set("unittests") {
+    testonly = true
+    sources = [ "traits_test.cc" ]
+    deps = [
+      "${tint_src_dir}:gmock_and_gtest",
+      "${tint_src_dir}/utils/traits",
+    ]
+  }
 }
diff --git a/tools/src/cmd/gen/build/BUILD.gn.tmpl b/tools/src/cmd/gen/build/BUILD.gn.tmpl
index 1d23559..f228a42 100644
--- a/tools/src/cmd/gen/build/BUILD.gn.tmpl
+++ b/tools/src/cmd/gen/build/BUILD.gn.tmpl
@@ -3,17 +3,17 @@
 
 import("${tint_src_dir}/tint.gni")
 
-{{- if $.Project.Target $ "test_cmd"}}
+{{- if or ($.Project.Target $ "test") ($.Project.Target $ "test_cmd")}}
 {{/*   newline */}}
 if (tint_build_unittests) {
   import("//testing/test.gni")
 }
 {{- end}}
 
-{{- Eval "SourceSetIfNotEmpty" ($.Project.Target $ "lib")}}
-{{- Eval "SourceSetIfNotEmpty" ($.Project.Target $ "cmd")}}
-{{- Eval "SourceSetIfNotEmpty" ($.Project.Target $ "test")}}
-{{- Eval "SourceSetIfNotEmpty" ($.Project.Target $ "test_cmd")}}
+{{- Eval "TargetIfNotEmpty" ($.Project.Target $ "lib")}}
+{{- Eval "TargetIfNotEmpty" ($.Project.Target $ "cmd")}}
+{{- Eval "TargetIfNotEmpty" ($.Project.Target $ "test")}}
+{{- Eval "TargetIfNotEmpty" ($.Project.Target $ "test_cmd")}}
 
 
 {{- /*
@@ -21,9 +21,9 @@
 -- Emits a GN source set if it contains any files
 --------------------------------------------------------------------------------
 */ -}}
-{{- define "SourceSetIfNotEmpty"}}
+{{- define "TargetIfNotEmpty"}}
 {{-   if $}}
-{{-     if len $.SourceFiles}}{{Eval "SourceSet" $}}{{end}}
+{{-     if len $.SourceFiles}}{{Eval "Target" $}}{{end}}
 {{-   end}}
 {{- end}}
 
@@ -33,21 +33,25 @@
 -- Emits a GN source set
 --------------------------------------------------------------------------------
 */ -}}
-{{- define "SourceSet"}}
+{{- define "Target"}}
+
+{{-   if Contains (print $.Kind) "test"}}
+if (tint_build_unittests) {
+{{-   end}}
 
 {{- /* Target condition */}}
 {{-   if $.Condition}}
 if({{$.Condition}}) {
 {{-   end}}
 
-{{  if      eq $.Kind "lib" -}}
+{{  if      $.Kind.IsLib -}}
 libtint_source_set("{{$.Directory.Name}}") {
-{{- else if eq $.Kind "cmd" -}}
+{{- else if $.Kind.IsCmd -}}
 executable("{{$.Directory.Name}}") {
-{{- else if eq $.Kind "test" -}}
+{{- else if $.Kind.IsTest -}}
 tint_unittests_source_set("unittests") {
   testonly = true
-{{- else if eq $.Kind "test_cmd" -}}
+{{- else if $.Kind.IsTestCmd -}}
 test("{{$.Directory.Name}}") {
 {{- else }}{{Error $.Kind}}
 {{- end  }}
@@ -100,7 +104,7 @@
   public_configs = [ "${tint_spirv_tools_dir}/:spvtools_internal_config" ]
 {{- end}}
 
-{{- if eq $.Kind "test_cmd" }}
+{{- if $.Kind.IsTestCmd }}
   testonly = true
   configs += [ "${tint_src_dir}:tint_unittests_config" ]
 
@@ -112,9 +116,11 @@
 }
 
 {{- /* Target condition */}}
-{{-   if $.Condition}}}{{-   end}}
-{{- end}}
+{{-   if $.Condition}}}{{end}}
+{{- /* if(tint_build_unittests) */}}
+{{-   if $.Kind.IsTestOrTestCmd}}}{{end}}
 
+{{- end}}
 
 {{- /*
 --------------------------------------------------------------------------------
@@ -123,9 +129,9 @@
 */ -}}
 {{- define "Dependency"}}
 {{-   $Path := printf "${tint_src_dir}/%v" $.Directory.Path}}
-{{-   if      eq $.Kind "lib"  }}{{$Path}}
-{{-   else if eq $.Kind "test" }}{{$Path}}:unittests
-{{-   else                     }}{{$Path}}:{{$.Kind}}
+{{-   if      $.Kind.IsLib  }}{{$Path}}
+{{-   else if $.Kind.IsTest }}{{$Path}}:unittests
+{{-   else                  }}{{$Path}}:{{$.Kind}}
 {{-   end}}
 {{- end}}
 
diff --git a/tools/src/cmd/gen/build/target_kind.go b/tools/src/cmd/gen/build/target_kind.go
index 8a55eb5..4e2e456 100644
--- a/tools/src/cmd/gen/build/target_kind.go
+++ b/tools/src/cmd/gen/build/target_kind.go
@@ -36,6 +36,27 @@
 	targetInvalid TargetKind = "<invalid>"
 )
 
+// IsLib returns true if the TargetKind is 'lib'
+func (k TargetKind) IsLib() bool { return k == targetLib }
+
+// IsTest returns true if the TargetKind is 'test'
+func (k TargetKind) IsTest() bool { return k == targetTest }
+
+// IsBench returns true if the TargetKind is 'bench'
+func (k TargetKind) IsBench() bool { return k == targetBench }
+
+// IsCmd returns true if the TargetKind is 'cmd'
+func (k TargetKind) IsCmd() bool { return k == targetCmd }
+
+// IsTestCmd returns true if the TargetKind is 'test_cmd'
+func (k TargetKind) IsTestCmd() bool { return k == targetTestCmd }
+
+// IsBenchCmd returns true if the TargetKind is 'bench_cmd'
+func (k TargetKind) IsBenchCmd() bool { return k == targetBenchCmd }
+
+// IsTestOrTestCmd returns true if the TargetKind is 'test' or 'test_cmd'
+func (k TargetKind) IsTestOrTestCmd() bool { return k.IsTest() || k.IsTestCmd() }
+
 // All the target kinds
 var AllTargetKinds = []TargetKind{
 	targetLib,