# Chromiumでtestをdisableする方法 今日はChromiumで働いている人にしか役に立たない話。 Buildbotでテストをdisableする手法をまとめる。 ## DISABLE annotation in gtest 以前[BrowserTestのマクロ](https://github.com/elkurin/elkurin-daily-notes/blob/main/docs/day56.md)というノートで確認したとおり、`DISABLED_TestName`みたいに先頭にDISABLEDをつけるとそのテストをtest suiteからビルド時に除外できる。 プラットフォームごとのenable/disableを切り替えたい場合は以下のように書く。 ```cpp= // TODO(crbug.com/xxxx): Re-enable when hogehoge #if BUILDFLAG(IS_CHROMEOS_ASH) #define MAYBE_TestSomething DISABLED_TestSomething #else #define MAYBE_TestSomething TestSomething #endif TEST_F(FooTest, MAYBE_TestSomehing) { ``` ここで`MAYBE_`をつけてるのは単に読みやすくするためで、macroとは関係ない。 このやり方だと、テストファイルを見るだけでそのテストが存在するかどうかが簡単に分かるという利点がある。 一方で、disableするためにいちいちビルドし直さないと行けないのが欠点。 ## filter `.filter`という拡張子のファイルでテストをdisableすることもできる。 例えば[linux-lacros.browser_tests.filter](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/filters/linux-lacros.browser_tests.filter) といったように、`ビルダーの名前.テストの名前.filter`のフォーマットで書ける。 ``` # crbug.com/1370019 -All/BrowserNonClientFrameViewChromeOSTest.TopViewInset* ``` こちらは、ビルドがすでに終わっているテストを走らせるときにfilterするので、ビルドし直す必要がないのが良い。 一方、テスト内ににはdisableしていることが書いてないので一見気づきにくいのが欠点。 filter自体は builders ✕ test suites の数だけできることになるので、なんかめっちゃいっぱいある。[リスト](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/filters/) このフィルターは以下のようにローカルでもかけることができる。 ``` ./out/dbg/content_browsertests \ --test-launcher-filter-file=testing/buildbot/filters/foo.content_browsertests.filter ``` filterはLacrosでは[test_runner.py](https://source.chromium.org/chromium/chromium/src/+/main:build/lacros/test_runner.py;l=125;drc=9fa0b46db22b8b6442f17aca7b4e937dee76f2af)スクリプトから参照される。 他のものでは[chrome.json](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/chrome.json;l=3013;drc=051072a669a09ac3bf979fb21c23cbb431f069a7)などのconfigファイルに直接`test-launcher-filter-file`オプションの値として渡される。 ## Test config file [test_suites.pyl](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl) 次に紹介するのはconfigファイルを書き換えるやつ。 filterを含む[chrome.json](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/chrome.json)などのconfigファイルは同じ[testing/buildbot](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/)ディレクトリにいる拡張子`.pyl`のファイルたちによってgenerateされる。 このconfigファイルの中では、buildbotsで走るテストグループを表現している。 例えば[chromeos_brya_skylab_tests](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suites.pyl;l=6820;drc=967429487762868b0cd61699c3d0566d636576d8)というテストグループは chromeos_chrome_all_tast_tests, chromeos_chrome_criticalstaging_tast_tests, ... chromeos_vaapi_gtests を含んでおり、それぞれvariantも指定されている。 このテストグループは[waterfalls.pyl](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/waterfalls.pyl)の中で[chromeos-brya-chrome-skylab](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/waterfalls.pyl;l=79;drc=f3d615bd61c78c10386ec1884f62ffaf656477a9)ボットのtest suitesに指定されている。 これらのファイルに書いてある内容は[generate_buildbot_json.py](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/generate_buildbot_json.py)によってjsonファイルが生成されchrome.jsonのような形になることで適応される。 つまりなんたら.jsonを書き換えない変更は意味がない。 ## 例外のconfigたち 上記の`test_suites.pyl`と似たものに[test_suite_expections.pyl](https://source.chromium.org/chromium/chromium/src/+/main:testing/buildbot/test_suite_exceptions.pyl) というものがある。 これはwaterfallやtest_suitesに記してあるルールに例外をプラスする際に使われる。 基本的にはすべてのボットやテストは同様に扱いたいが、そうも行かないときに例外を追加する用のファイルとしてデザインされており、test_suites.pylなどからごちゃごちゃしたものを取り除くためのもの。 例えば、今壊れているので一時的にdisableしたいときなどに使える。 注意点:このファイルの中ではvariantつきのテスト名を書かないといけない。例は以下。 ```py= 'net_unittests BRYA_RELEASE_LKGM': { # TODO(b/319364912): vpython cannot be delivered via CIPD on skylab builders 'remove_from': [ 'chromeos-brya-chrome-skylab', ], }, ``` ここでもし 'net_unittests' と書いていると、variantつきのテストとはマッチしない。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up