# Copyright 2021 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/android_nocompile.gni")
import("missing_symbol_test.gni")
import("nocompile_gn/nocompile_sources.gni")

group("android_nocompile_tests") {
  testonly = true

  # No-compile tests use an output directory dedicated to no-compile tests.
  # All test suites use targets in nocompile_gn/BUILD.gn in order to share the
  # same target output directory and avoid running 'gn gen' for each
  # android_nocompile_test_suite().
  deps = [
    ":android_lint_tests",
    ":android_lookup_dep_tests",
  ]
}

android_nocompile_test_suite("android_lint_tests") {
  # Depend on lint script so that the action is re-run whenever the script is  modified.
  pydeps = [ "//build/android/gyp/lint.pydeps" ]

  tests = [
    {
      target = "nocompile_gn:default_locale_lint_test"
      nocompile_sources =
          rebase_path(default_locale_lint_test_nocompile_sources,
                      "",
                      "nocompile_gn")
      expected_compile_output_regex = "Warning:.*DefaultLocale"
    },
    {
      target = "nocompile_gn:new_api_lint_test"
      nocompile_sources =
          rebase_path(new_api_lint_test_nocompile_sources, "", "nocompile_gn")
      expected_compile_output_regex = "Error:.*NewApi"
    },
  ]
}

android_nocompile_test_suite("android_lookup_dep_tests") {
  sources =
      [ rebase_path(missing_symbol_generated_importer_template_nocompile_source,
                    "",
                    "nocompile_gn") ]

  tests = [
    {
      target = "nocompile_gn:import_child_missing_symbol_test_java"
      nocompile_sources =
          rebase_path(import_child_missing_symbol_test_nocompile_sources,
                      "",
                      "nocompile_gn")
      expected_compile_output_regex = "Hint: Try adding the following to //build/android/test/nocompile_gn:import_child_missing_symbol_test_java\n *\"//build/android/test/nocompile_gn:sub_b_java\""
    },
    {
      target = "nocompile_gn:import_parent_missing_symbol_test_java"
      nocompile_sources = []
      expected_compile_output_regex = "Hint: Try adding the following to //build/android/test/nocompile_gn:import_parent_missing_symbol_test_java\n *\"//build/android/test/nocompile_gn:b_java\""
    },
    {
      target = "nocompile_gn:import_turbine_missing_symbol_test_java"
      nocompile_sources =
          rebase_path(import_turbine_missing_symbol_test_nocompile_sources,
                      "",
                      "nocompile_gn")
      expected_compile_output_regex = "Hint: Try adding the following to //build/android/test/nocompile_gn:import_turbine_missing_symbol_test_java\n *\"//build/android/test/nocompile_gn:b_java\""
    },
    {
      target = "nocompile_gn:prebuilt_missing_symbol_test_java"
      nocompile_sources = []
      expected_compile_output_regex = "Hint: Try adding the following to //build/android/test/nocompile_gn:prebuilt_missing_symbol_test_java\n *\"//build/android/test/nocompile_gn:c_prebuilt_java\""
    },
    {
      target = "nocompile_gn:cpp_template_missing_symbol_test_java"
      nocompile_sources = []
      expected_compile_output_regex = "Hint: Try adding the following to //build/android/test/nocompile_gn:cpp_template_missing_symbol_test_java\n *\"//build/android/test/nocompile_gn:d_java\""
    },
  ]
}