jlevy / jlevy/tryscript

Preserve named patterns when --update rewrites a failing block

オープン
#49 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
13
フォーク
1
平均マージ
3時間 38分
マージ済み PR(30日)
3

説明

## Summary

`tryscript run --update` replaces the entire expected-output section of each failing block with literal output. If that block contains named patterns for values such as a sandbox path, timestamp, PID, or allocated byte count, the update silently turns them into one run's concrete values. The next ordinary run then fails even when the intended stable-output update was correct.

This makes the documented update-and-compare workflow unsafe for realistic golden files that intentionally retain named patterns.

Observed with tryscript 0.1.7. The current `buildUpdatedBlock()` implementation writes `result.actualOutput` directly, so this appears to be current behavior rather than a platform-specific failure.

## Minimal Reproduction

```markdown
---
patterns:
PID: '\d+'
---

# Mixed Stable and Unstable Output

```console
$ node -e "console.log('status: new'); console.log('pid: ' + process.pid)"
status: old
pid: [PID]
? 0
```
```

Run:

```console
tryscript run --update example.tryscript.md
tryscript run example.tryscript.md
```

The first command rewrites the block to a literal PID. The second command fails when Node has a different PID.

A concrete downstream case changed fixture names and stable byte totals in CLI transcripts containing `[SCAN_PATH]`, `[MTIME_NS]`, and `[ALLOCATED]`. `--update` replaced all three pattern classes with literals across every changed block, and the mandatory comparison failed on the next sandbox.

## Desired Behavior

When updating a structurally corresponding block:

- update stable text that no longer matches
- preserve named patterns where the old expected output used them and the corresponding new value still matches that pattern
- make an immediate ordinary rerun pass
- warn clearly instead of silently literalizing a named pattern when correspondence is ambiguous
- retain an explicit opt-in such as `--expand-all` for users who do want named patterns replaced by concrete values

The active wildcard-expansion plan already notes possible integration where update mode prefers preservation when possible. A public issue would make that remaining workflow gap visible and testable.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

現在の buildUpdatedBlock() 実装から始め、update-mode 統合に向けたアクティブなワイルドカード展開計画を確認します。提供された markdown 例で失敗を再現し、その後、期待される出力と名前付きパターンがどのように対応するかを追跡します。名前付きパターンの一致を保持したまま安定したテキスト更新が行われ、曖昧なケースでは警告が出され、通常の再実行が成功すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
typescript
領域
cli, testing-qa
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
52/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。