Title: パッチをテストする
Author: Aki Hamano
Published: 2023年10月6日
Last modified: 2025年5月13日

---

# パッチをテストする

## この投稿内

 * [Playground で Core チケットをテストする](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#playground-%e3%81%a7-core-%e3%83%81%e3%82%b1%e3%83%83%e3%83%88%e3%82%92%e3%83%86%e3%82%b9%e3%83%88%e3%81%99%e3%82%8b)
 * [VVV を使用しない設定](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#vvv-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%aa%e3%81%84%e8%a8%ad%e5%ae%9a)
 * [VVV を使用した設定](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#vvv-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e8%a8%ad%e5%ae%9a)
 * [Grunt を使用したテスト](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#grunt-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%83%86%e3%82%b9%e3%83%88)
 * [Grunt を使用しないテスト](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#grunt-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%aa%e3%81%84%e3%83%86%e3%82%b9%e3%83%88)

[↑ ページの先頭へ戻る](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#wp--skip-link--target)

このページは作成中のため、不正確な情報が含まれている可能性があります。修正を手伝
ってみませんか ? WordPress Slack の [#docs](https://make.wordpress.org/core/tag/docs/)
チャンネルでお知らせください。

パッチのテストは、WordPress のリリースの品質を保証する重要なパートです。

## 󠀁[Playground で Core チケットをテストする](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#playground-%e3%81%a7-core-%e3%83%81%e3%82%b1%e3%83%83%e3%83%88%e3%82%92%e3%83%86%e3%82%b9%e3%83%88%e3%81%99%e3%82%8b)󠁿

一部のチケットは、[WordPress Playground](https://wordpress.github.io/wordpress-playground/)
を使用することで、独自のローカル環境を構築することなくテストできます。WordPress 
Playground は、実際の Web サイトに影響を与えることなく、WordPress を試したり学習
したりできるオンラインプラットフォームです。安全で管理された環境で、さまざまな機能、
デザイン、設定を試すことができる仮想サンドボックスです。[WordPress Playground の詳細についてはこちら](https://wordpress.github.io/wordpress-playground/)
をご覧ください。また、[Playground でコアパッチをテストする方法については、テストチームのハンドブック](https://make.wordpress.org/test/handbook/get-setup-for-testing/test-core-tickets-with-playground/)
をご覧ください。

## 󠀁[VVV を使用しない設定](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#vvv-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%aa%e3%81%84%e8%a8%ad%e5%ae%9a)󠁿

VVV を使用している場合は、以下のセクションはスキップしてください。

Grunt は、Trac にアップロードされたパッチをテストするためのコマンドランナーです。
Grunt を使うには以下のステップに従ってください:

 1. 開発環境に `nodejs` と `npm` をインストールします。
 2. https://develop.svn.wordpress.org/ にある _develop_ WordPress リポジトリをクローン
    します。
 3. `npm install` を実行して、すべての依存関係を取得します。
 4. `npm run grunt build` を実行して、完全にビルドされたバージョンを取得します。
 5. サーバーのルートとして `/build` を使うように設定します (開発環境の設定によって異
    なります)。
 6. `src` への変更を `/build` に反映させるために、作業中に `npm run grunt watch` を
    実行する。
 7. **別の方法として**、[/src をドキュメントルートとして使う](https://make.wordpress.org/core/2018/12/24/build-tools-weve-enabled-running-wordpress-from-src-again/)
    こともできます。これは、PHP を中心とした開発には便利です。`npm run grunt build ----
    dev` を一度実行する必要がありますが、その後は JavaScript/CSS を変更しない限り、`
    npm run grunt watch` はまったく必要ありません。その場合は、`npm run grunt watch`
    の代わりに `npm run grunt watch -- --dev` を使用してください。

## 󠀁[VVV を使用した設定](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#vvv-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e8%a8%ad%e5%ae%9a)󠁿

VVV は [WP コア開発](https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop/)
をサポートしており、[config.yml](https://github.com/Varying-Vagrant-Vagrants/VVV/blob/develop/config/default-config.yml)
ファイルに設定があります。

VVV を使用する場合、完全な [WP コア開発ビルド](https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop/)
を含むサイトを追加できます。`config/config.yml` を開くと、このためのサイトがあらかじめ
用意されていますが、そのままでは無効になっています。`wordpress-trunk` を探し、`skip_provisioning`
を `true` から `false` に変更すると、以下のようになります:

    ```notranslate
      wordpress-trunk:
        skip_provisioning: true
        description: "An git based WP Core trunk dev setup, useful for contributor days, Trac tickets, patches"
        repo: https://github.com/Varying-Vagrant-Vagrants/custom-site-template-develop.git
        hosts:
          - trunk.wordpress.test
        custom:
          vcs: git # using 'svn' will force this vcs
    ```

保存したら、`vagrant up --provision` で再プロビジョニングします。VVV は、コアでの
作業とテストのための開発環境をダウンロードして準備します。この新しいサイトは `www/
wordpress-trunk/public_html` フォルダーに配置されます。

サイト内には `src` と `build` の2つのフォルダーがあります。`src` フォルダーで行われ
た変更は `grunt` というツールで処理され、`build` フォルダーに格納されます。これは`
www/wordpress-trunk/public_html` フォルダーで `npm run grunt watch` コマンドを実行
することで自動的に行わます。例:

    ```notranslate
    vagrant ssh
    cd /srv/www/wordpress-trunk/public_html
    npm run grunt watch
    ```

## 󠀁[Grunt を使用したテスト](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#grunt-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%9f%e3%83%86%e3%82%b9%e3%83%88)󠁿

[Grunt](https://ja.wordpress.org/team/handbook/core/tutorials/working-with-patches/#creating-and-applying-patches-with-grunt)
のセットアップが完了したら、`npm run grunt patch:####` と入力し、`###` を Trac の
チケット番号かパッチの URL に置き換えてください。これでパッチがダウンロードされ、
開発環境に変更が適用されます。

注: `Cannot find module 'grunt-cli/bin/grunt'` エラーが表示された場合は、以下を実行
してから再度試してください:

`rm -rf node_modules && npm install`

環境をテストする準備はできましたか ? `npm run grunt test` を使って自動テストを実行
します。このステップでは、PHPUnit がインストールされている必要があることに注意し
てください。

もしあなたがコミッターなら、コードをコミットする前に必ず `npm run grunt precommit`
を実行してください。

コミッターの場合は、コード、**特に**フロントエンド (CSS/JS) に関わるコードをコミット
する前に、必ず `npm run grunt precommit` を実行してください。

## 󠀁[Grunt を使用しないテスト](https://ja.wordpress.org/team/handbook/core/testing/patch/?output_format=md#grunt-%e3%82%92%e4%bd%bf%e7%94%a8%e3%81%97%e3%81%aa%e3%81%84%e3%83%86%e3%82%b9%e3%83%88)󠁿

[https://ja.wordpress.org/team/handbook/core/tutorials/working-with-patches/#applying-a-patch-with-the-command-line](https://ja.wordpress.org/team/handbook/core/tutorials/working-with-patches/#applying-a-patch-with-the-command-line)
を参照してください

[原文](https://make.wordpress.org/core/handbook/testing/patch/) / [日本語訳](https://github.com/jawordpressorg/core-handbook/blob/main/core/testing/patch.md)

公開日

2023年10月6日

最終更新

2025年5月13日

[  前へ: バグガーデニング](https://ja.wordpress.org/team/handbook/core/testing/bug-gardening/)

[  次へ: テスト募集を書く](https://ja.wordpress.org/team/handbook/core/testing/write-a-call-for-testing/)