# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Unit tests for subpackages.bzl."""

load("//lib:subpackages.bzl", "subpackages")
load("//lib:unittest.bzl", "loadingtest")

def _all_test(env):
    """Unit tests for subpackages.all."""

    all_pkgs = [
        "copy_directory",
        "copy_file",
        "diff_test",
        "expand_template",
        "select_file",
        "write_file",
    ]

    # Not all pkgs exist in all test environments.
    if subpackages.exists("run_binary"):
        all_pkgs.append("run_binary")

    if subpackages.exists("native_binary"):
        all_pkgs.append("native_binary")

    # These exist in all cases
    filtered_pkgs = [
        "copy_directory",
        "copy_file",
        "expand_template",
        "select_file",
        "write_file",
    ]

    # subpackages is always in sorted order:
    all_pkgs = sorted(all_pkgs)

    # test defaults
    loadingtest.equals(
        env,
        "all",
        ["//tests/" + pkg for pkg in all_pkgs],
        subpackages.all(),
    )

    # test non-fully-qualified output
    loadingtest.equals(
        env,
        "all_not_fully_qualified",
        all_pkgs,
        subpackages.all(fully_qualified = False),
    )

    # test exclusion
    loadingtest.equals(
        env,
        "all_w_exclude",
        filtered_pkgs,
        subpackages.all(exclude = ["diff_test", "run_binary", "native_binary"], fully_qualified = False),
    )

def _exists_test(env):
    """Unit tests for subpackages.exists."""
    loadingtest.equals(env, "exists_yes", True, subpackages.exists("copy_file"))
    loadingtest.equals(env, "exists_no", False, subpackages.exists("never_existed"))

def subpackages_test_suite():
    """Creates the test targets and test suite for subpackages.bzl tests."""

    if subpackages.supported():
        env = loadingtest.make("subpackages")
        _all_test(env)
        _exists_test(env)
