Skip to content

Unstable output #33

@Hoblovski

Description

@Hoblovski

Describe the bug

parser 运行不稳定,同样输入输出 json 有实质性不同

To Reproduce

从一个 clean-slate 仓库开始

go build
./abcoder parse rust testdata/rust2 -o before-1.json
./abcoder parse rust testdata/rust2 -o before-2.json
python diffjson.py  before1.json before2.json

其中 diffjson.py 内容如下(这个 diff 智能忽略了 dict/list 的 key 顺序)

#!/usr/bin/env python3
import argparse
import json
from deepdiff import DeepDiff
from pprint import pprint


def main():
    parser = argparse.ArgumentParser(
        description="Compare two JSON files using the DeepDiff library."
    )
    parser.add_argument("file1", type=str, help="Path to the first JSON file.")
    parser.add_argument("file2", type=str, help="Path to the second JSON file.")
    args = parser.parse_args()

    with open(args.file1, "r", encoding="utf-8") as f:
        json1 = json.load(f)
    with open(args.file2, "r", encoding="utf-8") as f:
        json2 = json.load(f)
    diff = DeepDiff(json1, json2, ignore_order=True)

    if diff:
        print("\n--- Differences Found ---")
        pprint(diff)
        print("\n--- End Differences ---")
        return 1
    else:
        print("\nNo differences found. The JSON files are identical.")
        return 0


if __name__ == "__main__":
    exit(main())

Expected behavior

应当一致!

Screenshots

Image

Version:

main

ff4cf80

Environment:

The output of go env.

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

C-bugThis is a bug-report. Bug-fix PRs use `C-enhancement` instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions