-
Notifications
You must be signed in to change notification settings - Fork 0
テストの前提: 監視の上限を環境変数で延ばしたシェルでは既定値を前提にするテストが落ち、収束ループの初期化が中断する → テストの実行中は監視の環境変数を共通の前提で外す(#678) #797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # テストの前提: 監視の上限を環境変数で延ばしたシェルでは既定値を前提にするテストが落ち、収束ループの初期化が中断する → テストの実行中は監視の環境変数を共通の前提で外す(#678) | ||
|
|
||
| ## 目的 | ||
|
|
||
| 無進捗の許容と打ち切りの上限は、環境変数で延ばせる。運用でこれを延ばしたシェルから全体の | ||
| テストを起動すると、既定値を前提にするテストが落ちる。落ちた原因はテストの実行環境にあり、 | ||
| 変更の中身にはない。 | ||
|
|
||
| 収束ループ(`cross-refactoring`)の初期化は着手前のテストの通過を条件にするため、上限を | ||
| 延ばしたシェルでは初期化がそこで止まる。 | ||
|
|
||
| **テストの実行中だけ、監視の環境変数を利用者の環境から切り離す。** 切り離しの置き場所は | ||
| リポジトリ直下の共通の前提(`conftest.py`)とし、テストごとに散った除去をそこへ寄せる。 | ||
|
|
||
| ## 対象範囲 | ||
|
|
||
| **含む** | ||
|
|
||
| - リポジトリ直下の共通の前提へ、監視の環境変数(接頭辞 `MONITOR_`)を外す仕組みを足す | ||
| - テストごとに散った同じ除去を取り除く(1 変数ずつ外す箇所と、接頭辞でまとめて外す箇所) | ||
| - 共通の前提が働いていることを確かめるテストを足す | ||
|
|
||
| **含まない** | ||
|
|
||
| - 上限の解決順(担当ごとの指定 → 共通の指定 → 表の既定)の変更 | ||
| - 上限の表の値の変更 | ||
| - 監視の本体・起動スクリプト・Skill 本文の変更 | ||
|
|
||
| ## 前提 | ||
|
|
||
| - 本番の振る舞いも本番コードの構造も変えない。変えるのはテストの前提だけである | ||
| - 子プロセスは実行中の環境変数を受け継ぐため、共通の前提で外せば、テストが起動する | ||
| 別プロセスにも同じ切り離しが効く | ||
| - テストの中で監視の環境変数を設定する箇所(`monkeypatch.setenv`・別プロセスへ渡す | ||
| 上書き)は、共通の前提より後に効くため、そのまま働く | ||
|
|
||
| ## 着手前の実測(2026-09-21) | ||
|
|
||
| 同じコマンドを、監視の環境変数を設定したシェルと、していないシェルで実行した。 | ||
|
|
||
| ```console | ||
| $ MONITOR_TIMEOUT_AGY=1800 MONITOR_STALL_AGY=1800 uv run --with pytest pytest scripts/tests plugins/ndf -q | ||
| FAILED plugins/ndf/skills/cross-review/tests/test_launch_agy.py::test_the_print_timeout_defaults_to_the_longest_phase | ||
| FAILED plugins/ndf/skills/cross-review/tests/test_monitor_agy.py::test_the_new_name_has_a_stall_default | ||
| FAILED plugins/ndf/skills/cross-review/tests/test_monitor_import_safety.py::test_import_succeeds_with_non_numeric_monitor_stall | ||
| 3 failed, 4600 passed in 182.10s | ||
|
|
||
| $ uv run --with pytest pytest scripts/tests plugins/ndf -q | ||
| 4603 passed in 179.67s | ||
| ``` | ||
|
|
||
| | 観測 | 値 | | ||
| | --- | --- | | ||
| | 収集した件数 | 4603(どちらのシェルでも同じ) | | ||
| | 設定したシェルで落ちる件数 | 3 | | ||
| | 設定していないシェルで落ちる件数 | 0 | | ||
|
|
||
| 課題の本文が記録した 2026-09-15 の観測では落ちるのが 2 件、その後の追記で 3 件だった。 | ||
| 件数は着手時点の実測で 3 件のまま変わらない。 | ||
|
|
||
| ## 受け入れ条件 | ||
|
|
||
| - [x] 受け入れ条件 1: 監視の環境変数(`MONITOR_TIMEOUT_AGY` と `MONITOR_STALL_AGY`)を設定した | ||
| シェルで全体のテストを実行すると、失敗が 0 件になる | ||
| - [x] 受け入れ条件 2: 設定したシェルと設定していないシェルで、通過した件数と失敗した件数が | ||
| 一致する | ||
| - [x] 受け入れ条件 3: 共通の前提が接頭辞 `MONITOR_` の環境変数を外していることを、テストが | ||
| 直接確かめる(実行中に該当する環境変数が 1 つも残らない) | ||
| - [x] 受け入れ条件 4: テストの中で監視の環境変数を設定する箇所は、共通の前提を足した後も | ||
| 同じ値を観測できる(共通の前提が個別の設定を打ち消さない) | ||
| - [x] 受け入れ条件 5: 接頭辞でまとめて外していた箇所と、1 変数ずつ外していた箇所が、 | ||
| 共通の前提へ寄る(対象のファイルに同じ除去が残らない) | ||
| - [x] 受け入れ条件 6: 共通の前提は、テストの実行が終わった後に元の環境変数を戻す | ||
|
|
||
| ## 検証手段 | ||
|
|
||
| | 条件 | 確かめ方 | | ||
| | --- | --- | | ||
| | 1 / 2 | `MONITOR_TIMEOUT_AGY=1800 MONITOR_STALL_AGY=1800 uv run --with pytest pytest scripts/tests plugins/ndf -q` と、設定しない同じコマンドの 2 回を実行し、件数を突き合わせる | | ||
| | 3 / 4 / 6 | 共通の前提を確かめるテスト(`scripts/tests/test_root_conftest.py`)を実行する | | ||
| | 5 | `grep -rn "MONITOR_" --include="*.py" <テストのディレクトリ>` の結果に、接頭辞での除去と 1 変数ずつの除去が残らないことを確かめる | | ||
|
|
||
| ## 境界 | ||
|
|
||
| ```text | ||
| 常に行う … 共通の前提の追加、散った除去の削除、両方のシェルでの全体テスト | ||
| 確認してから行う … 上限の解決順・表の既定値に触れる変更(この変更では行わない) | ||
| 行わない … 監視の本体・起動スクリプト・Skill 本文の変更、依頼範囲外の整形 | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # 起点のディレクトリに関わらず、テストの基準のディレクトリ(rootdir)をリポジトリの根へ | ||
| # 解決させるために置く。pytest は起点から上へ設定ファイルを探し、見つかったところで止まる。 | ||
| # 根に設定ファイルが 1 つも無いと、テストの束のディレクトリを起点にした実行では基準が | ||
| # そこで止まり、根の共通の前提(`conftest.py`)が読み込まれない。監視の上限を指す環境変数 | ||
| # (接頭辞 `MONITOR_`)の除去のように、どの起点でも効かなければならない前提がここに載る。 | ||
| # | ||
| # **設定値は足さない。** `testpaths` などを書くと、既存の実行が対象にする範囲が変わる。 | ||
| [pytest] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.