Skip to content

Add foundational bits to enable dart_test-type rules in the engine #155769

@matanlurey

Description

@matanlurey
  • Write a tool_executable (name TBD) rule that generates a shell (and later, batch, for Windows) in out/
    - [ ] Write a dart_snapshot rule that generates a [kernel snapshot]1 and depfile for a given Dart entrypoint
  • Write a dart_test rule that generates a tool_executable and dart_snapshot, and uses dart test to run a file

Working on #147013 and wanted to write out some of my thoughts to explain what I think needs to get done, and why it will take a different path the @cbracken's original PR, flutter/engine#52241, and need (likely 1-2 PRs) foundational work as a starting step.

We'd like to get to a world where (something) like the following can be written:

# //flutter/tools/engine_tool/BUILD.gn

import("//flutter/build/dart/rules.gni")

dart_test_suite("tests") {
  sources = ["test/**/*_test.dart"],
}

But let's break that down a bit, and make it more verbose to make it more understandable:

# //flutter/tools/engine_tool/BUILD.gn

import("//flutter/build/dart/rules.gni")

dart_test("build_command_test") {
  script = "test/build_command_test.dart",
}

dart_test("utils_test") {
  script = "test/utils_test.dart",
}

dart_test("worker_pool_test") {
  script = "test/worker_pool_test.dart",
}

Ok, now one step further, what does/would et test //flutter/tools/engine_tool:build_command_test do?

  1. Generate a build_command_test.depfile (and as a side-effect, snapshot)

  2. Generate a build_command_test.sh file that has contents something like:

    #!/bin/bash
    set -e
    pushd {{WORKING_DIR}}
    {{DART_BINARY}} test test/build_command_test.dart
    popd
  3. Runs a ninja build that builds (1) and (2)

  4. Runs the executable output by (2), i.e. ../out/host_debug/build_command_test.sh (or whatever)


/cc @jonahwilliams @cbracken @jakemac53 @johnmccutchan

Footnotes

  1. Technically the snapshot is not needed, and we could work with the VM team to skip if it would improve build times.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.e: engine-toolEngine-specific tooling (i.e. `tools/engine_tool`).team-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions