mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-09-14 19:59:52 +08:00
516e7d1fd0
* feat(session): compare findings across two review sessions (#922) After a fix-and-rerun cycle there is no way to see what changed between two saved sessions short of diffing two comment lists by hand. Adds `ocr session compare <before> <after>`, with `--json`, grouping findings into new, persisting, resolved and not-reviewed. Matching is on path, category and snippet rather than line numbers, so a finding that only drifted down the file still counts as persisting. * fix(session): pass os.Stdout to renderComment after main's signature change renderComment gained an io.Writer parameter on main after this branch was cut, so the merge left the compare printer calling it with one argument and the package failing to build. The rest of session_cmd.go already passes os.Stdout; this matches it, and the stale comment explaining why the printer avoided an io.Writer no longer applies. Claude-Session: https://claude.ai/code/session_01FoMHZQ3qqdt98LHTwSJuTG --------- Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com>
39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
// SPDX-License-Identifier: Apache-2.0
|
|
// Copyright 2026 alibaba/open-code-review Contributors
|
|
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestCLIReferenceDocumentsSessionCompare pins that every locale of the CLI
|
|
// reference documents `ocr session compare`. The four files are hand-synced
|
|
// (see PR #920), so the usual failure is a new command landing in `en` only.
|
|
// ponytail: substring checks, not a markdown parse - the whole point is to
|
|
// catch a missing file, and a parser would not catch it any better.
|
|
func TestCLIReferenceDocumentsSessionCompare(t *testing.T) {
|
|
for _, locale := range []string{"en", "zh", "ja", "ru"} {
|
|
t.Run(locale, func(t *testing.T) {
|
|
path := filepath.Join("..", "..", "pages", "src", "content", "docs", locale, "cli-reference.md")
|
|
body, err := os.ReadFile(path)
|
|
if err != nil {
|
|
t.Fatalf("read %s: %v", path, err)
|
|
}
|
|
for _, want := range []string{
|
|
"`ocr session compare <before> <after>`", // command-summary table row
|
|
"### `ocr session compare`", // reference section
|
|
"`ocr session diff <before> <after>`", // alias
|
|
"not_reviewed", // the JSON bucket that is easy to forget
|
|
} {
|
|
if !strings.Contains(string(body), want) {
|
|
t.Errorf("%s: missing %q", path, want)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|