tests: make analysis tests support --incompatible_enable_cc_toolchain_resolution (#1281)

The analysis tests transition to different platforms to test some
platform-specific logic.

When cc toolchain registration is enabled, this also requires that a
more complete
toolchain be defined and available.
diff --git a/tools/build_defs/python/tests/BUILD.bazel b/tools/build_defs/python/tests/BUILD.bazel
index 92bdc5c..b5694e2 100644
--- a/tools/build_defs/python/tests/BUILD.bazel
+++ b/tools/build_defs/python/tests/BUILD.bazel
@@ -53,6 +53,13 @@
     toolchain_identifier = "mac-toolchain",
 )
 
+toolchain(
+    name = "mac_toolchain_definition",
+    target_compatible_with = ["@platforms//os:macos"],
+    toolchain = ":mac_toolchain",
+    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
 fake_cc_toolchain_config(
     name = "mac_toolchain_config",
     target_cpu = "darwin_x86_64",
@@ -72,6 +79,13 @@
     toolchain_identifier = "linux-toolchain",
 )
 
+toolchain(
+    name = "linux_toolchain_definition",
+    target_compatible_with = ["@platforms//os:linux"],
+    toolchain = ":linux_toolchain",
+    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
+)
+
 fake_cc_toolchain_config(
     name = "linux_toolchain_config",
     target_cpu = "k8",
diff --git a/tools/build_defs/python/tests/py_test/py_test_tests.bzl b/tools/build_defs/python/tests/py_test/py_test_tests.bzl
index 8bb2fc2..5983581 100644
--- a/tools/build_defs/python/tests/py_test/py_test_tests.bzl
+++ b/tools/build_defs/python/tests/py_test/py_test_tests.bzl
@@ -25,6 +25,7 @@
 # Explicit Label() calls are required so that it resolves in @rules_python context instead of
 # @rules_testing context.
 _FAKE_CC_TOOLCHAIN = Label("//tools/build_defs/python/tests:cc_toolchain_suite")
+_FAKE_CC_TOOLCHAINS = [str(Label("//tools/build_defs/python/tests:all"))]
 _PLATFORM_MAC = Label("//tools/build_defs/python/tests:mac")
 _PLATFORM_LINUX = Label("//tools/build_defs/python/tests:linux")
 
@@ -51,6 +52,7 @@
         config_settings = {
             "//command_line_option:cpu": "darwin_x86_64",
             "//command_line_option:crosstool_top": _FAKE_CC_TOOLCHAIN,
+            "//command_line_option:extra_toolchains": _FAKE_CC_TOOLCHAINS,
             "//command_line_option:platforms": [_PLATFORM_MAC],
         },
     )
@@ -82,6 +84,7 @@
         config_settings = {
             "//command_line_option:cpu": "k8",
             "//command_line_option:crosstool_top": _FAKE_CC_TOOLCHAIN,
+            "//command_line_option:extra_toolchains": _FAKE_CC_TOOLCHAINS,
             "//command_line_option:platforms": [_PLATFORM_LINUX],
         },
     )