testing.gni 2.1 KB
Newer Older
M
Michael Goderbauer 已提交
1
# Copyright 2013 The Flutter Authors. All rights reserved.
2 3 4
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

5 6 7 8 9 10
import("//third_party/dart/build/dart/dart_action.gni")

# Builds test fixtures for a unit test.
#
# Generates a directory structure containing an assets directory and the Dart
# code to execute compiled to kernel, emitted to assets/kernel_blob.bin.
11 12 13 14 15
template("test_fixtures") {
  testonly = true

  assert(defined(invoker.fixtures), "Test fixtures must be specified.")

16 17
  fixtures_location = "$target_gen_dir/$target_name/assets"
  fixtures_location_file = "$target_gen_dir/$target_name/test_fixtures_location.cc"
18

19
  fixtures_name_target_name = target_name + "_gen_fixtures_name"
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  action(fixtures_name_target_name) {
    script = "$flutter_root/testing/build/gen_fixtures_location_symbol.py"

    outputs = [
      fixtures_location_file,
    ]

    args = [
      "--fixtures_location_file",
      rebase_path(fixtures_location_file),
      "--fixtures_location",
      rebase_path(fixtures_location),
    ]
  }

35
  fixtures_source_set_target_name = target_name + "_gen_fixtures_source_set"
36
  source_set(fixtures_source_set_target_name) {
37
    testonly = true
38 39 40 41 42 43 44 45 46
    sources = [
      fixtures_location_file,
    ]

    deps = [
      ":$fixtures_name_target_name",
    ]
  }

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
  fixtures_kernel_target_name = target_name + "_kernel"
  prebuilt_dart_action(fixtures_kernel_target_name) {
    testonly = true
    script = "$root_out_dir/frontend_server.dart.snapshot"

    fixture_paths = []
    foreach(fixture, invoker.fixtures) {
      fixture_paths += [ rebase_path(fixture) ]
    }
    inputs = fixture_paths
    outputs = ["$fixtures_location/kernel_blob.bin"]

    args = [
      "--sdk-root", rebase_path("$root_out_dir/flutter_patched_sdk"),
      "--strong",
      "--target", "flutter",
      "--output-dill", rebase_path("$fixtures_location/kernel_blob.bin"),
    ] + fixture_paths
    deps = [
      "//third_party/dart/utils/kernel-service:frontend_server"
67 68 69 70
    ]
  }

  group(target_name) {
71
    testonly = true
72
    deps = [
73
      ":$fixtures_kernel_target_name",
74 75 76 77
      ":$fixtures_source_set_target_name",
    ]
  }
}