# Copyright (c) 2020 Project CHIP Authors
#
# 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.

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")

import("$dir_pw_build/python_action.gni")

import("${chip_root}/build/chip/tests.gni")
import("${chip_root}/src/platform/device.gni")
import("${dir_pw_unit_test}/test.gni")

assert(chip_build_tests)

if (chip_link_tests) {
  template("chip_test") {
    _test_name = target_name

    _test_output_dir = "${root_out_dir}/tests"
    if (defined(invoker.output_dir)) {
      _test_output_dir = invoker.output_dir
    }

    executable(_test_name) {
      forward_variables_from(invoker, "*", [ "output_dir" ])
      output_dir = _test_output_dir
    }

    group(_test_name + "_lib") {
    }

    if (chip_pw_run_tests) {
      pw_python_action(_test_name + "_run") {
        deps = [ ":${_test_name}" ]
        inputs = [ pw_unit_test_AUTOMATIC_RUNNER ]
        module = "pw_unit_test.test_runner"
        python_deps = [
          "$dir_pw_cli/py",
          "$dir_pw_unit_test/py",
        ]
        args = [
          "--runner",
          rebase_path(pw_unit_test_AUTOMATIC_RUNNER, root_build_dir),
          "--test",
          rebase_path("$_test_output_dir/$_test_name", root_build_dir),
        ]
        stamp = true
      }
    }
  }
} else {
  template("chip_test") {
    group(target_name) {
    }
    group(target_name + "_lib") {
    }
    not_needed(invoker, "*")
  }
}
