Agent Skillsgoogle/skia › skia-add-test

skia-add-test

GitHub

指导在Skia仓库tests/目录添加新C++测试,包括创建文件、更新gn构建配置、编译dm工具并运行特定测试。

agents/skills/skia-add-test/SKILL.md google/skia

Trigger Scenarios

需要为Skia项目编写新的单元测试或集成测试 需要将新测试添加到Skia的构建系统中

Install

npx skills add google/skia --skill skia-add-test -g -y
More Options

Non-standard path

npx skills add https://github.com/google/skia/tree/main/agents/skills/skia-add-test -g -y

Use without installing

npx skills use google/skia@skia-add-test

指定 Agent (Claude Code)

npx skills add google/skia --skill skia-add-test -a claude-code -g -y

安装 repo 全部 skill

npx skills add google/skia --all -g -y

预览 repo 内 skill

npx skills add google/skia --list

SKILL.md

Frontmatter
{
    "name": "skia-add-test",
    "description": "Add a new test to the Skia repository. Use this skill when you need to create a new unit or integration test in the tests\/ directory and ensure it's part of the build system."
}

Skia Add Test Skill

This skill guides you through adding a new test to Skia. Tests are primarily written in C++ and located in the tests/ directory.

Workflow

1. Create the Test File

Create a new .cpp file in the tests/ directory. Use the provided template as a starting point.

  • Template Location: assets/test_template.cpp

2. Update the Build System

Add the path to your new test file to the tests_sources list in gn/tests.gni.

  • Paths in gn/tests.gni should be relative to the directory or use the $_tests variable.

3. Build the Test

Compile the dm tool, which runs the tests.

ninja --quiet -C out/Debug dm

4. Run the Test

Use dm with the --match flag to run your specific test.

out/Debug/dm --match [test_name]

Note: Replace [test_name] with the name provided to the DEF_TEST (or similar) macro.

Key Concepts

Macros for Defining Tests

  • DEF_TEST(name, reporter): Standard CPU test.
  • DEF_GANESH_TEST(name, reporter, options, ctsEnforcement): Ganesh GPU test.
  • DEF_GRAPHITE_TEST_FOR_ALL_CONTEXTS(name, reporter, context, ctsEnforcement): Graphite GPU test.

CtsEnforcement

CtsEnforcement is used to track tests that should be run as part of Android's Conformance Test Suite (CTS) for a specific milestone (e.g., kApiLevel_T) or later.

  • CtsEnforcement::kNever: The test is not part of CTS.
  • CtsEnforcement::kApiLevel_U: The test is required for Android U and later.

Reporter and Assertions

  • REPORTER_ASSERT(reporter, condition, ...): Standard assertion.
  • ERRORF(reporter, ...): Report a failure with a formatted message.
  • skiatest::ReporterContext: Use this stack-allocated object to provide additional context (like subtest names) for failure reports.

Example of ReporterContext:

{
    skiatest::ReporterContext subtest(reporter, SkString("My Subtest"));
    REPORTER_ASSERT(reporter, condition);
}

If condition fails, the error will include "My Subtest".

Version History

  • 8a831d8 Current 2026-07-24 12:29

Metadata

Files
0
Version
8a831d8
Hash
c60c6bf3
Indexed
2026-07-24 12:29

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-07 17:16
浙ICP备14020137号-1 $Carte des visiteurs$