fix: critical bugs + 39 tests for comprehensive coverage#3
Merged
Conversation
Go's flag package stops parsing at the first non-flag argument, so `probe example.com --json` silently ignored --json. Pre-process args to separate flags from positional arguments before parsing. Also fix --help to not show "Error: flag: help requested". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Bugs fixed: - CRITICAL: --insecure now bypasses expired certs (warn instead of fail) - MEDIUM: --help output to stdout (not stderr) - LOW: --method "" validation - LOW: suppress Go flag double usage display Tests added (39 new): - 16 E2E tests (help, invalid target, JSON on error, table output, stdout/stderr separation, all flags, exit codes, flag ordering) - 5 CLI tests (invalid header, --, unknown flag, bad timeout, errors) - 5 target parser tests (port boundaries, fragment, bare host+port) - 4 contract tests (error structure, RFC3339, duration type, observations) - 3 runner tests (http scheme, empty layers, wall clock) - 6 layer tests (DNS multi-IP, TCP empty obs, HTTP 3xx/5xx, TLS generic) All tests pass (race detector + E2E). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix skipIfUnreachable to try both port 443 and 80 (was always 443) - Add stderr verification to TestStdoutStderrSeparation - Reject empty string target in CLI parser - Add stderr emptiness check to TestHelpFlag Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ユーザーが2分の手動検証で
probe url --jsonがJSON出力しないバグを発見。これを契機にテスト品質を根本から見直し、網羅的なテストを追加。振り返りメモ (Future Claude向け)
何が起きたか
flagパッケージはフラグが位置引数の前に来ないと無視される仕様で、probe url --jsonが機能しなかった--json URL(フラグ先) の順で書かれており、現実の使い方 (URL --json) をカバーしていなかった根本原因
教訓 (次回のClaude向け)
cmd args --flagとcmd --flag argsの両方を必ずテスト修正内容
バグ修正 (6件)
probe url --jsonでJSON出力しない--insecureが expired cert をバイパスしない--helpの出力が stderr--method ""がエラーにならないテスト追加 (39件)
--separator, unknown flag, invalid timeout, empty targetCodexレビュー結果
skipIfUnreachableが常にport 443のみチェック → 443/80両方にTestStdoutStderrSeparationが stderr を検証していない → 追加TestHelpFlagの stderr 空検証 → 追加Test plan
go vet— passmake test-race— all unit tests pass (race detector)make build— binary buildsmake e2e— 19 PASS, 1 SKIP (exit code warn)🤖 Generated with Claude Code